@douyinfe/semi-foundation 2.23.5 → 2.23.6

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.
@@ -159,23 +159,47 @@ $module: #{$prefix}-cascader;
159
159
  background: transparent;
160
160
  margin-left: $spacing-cascader_selection_tagInput-marginLeft;
161
161
  }
162
-
162
+
163
163
  .#{$prefix}-tagInput {
164
+ &-wrapper {
165
+ &-default {
166
+ min-height: $height-cascader_selection_tagInput_wrapper_default;
167
+ }
168
+
169
+ &-small {
170
+ min-height: $height-cascader_selection_tagInput_wrapper_small;
171
+ }
172
+
173
+ &-large {
174
+ min-height: $height-cascader_selection_tagInput_wrapper_large;
175
+ }
176
+ }
177
+
164
178
  .#{$prefix}-input-wrapper {
165
- height: $height-cascader_selection_tagInput_input_default;
179
+ // height: $height-cascader_selection_tagInput_input_default;
166
180
 
167
181
  margin-left: $spacing-cascader_selection_input-marginLeft;
168
182
  .#{$prefix}-input {
169
183
  padding-left: 0;
170
184
  }
171
- }
172
185
 
173
- .#{$prefix}-input-wrapper-small {
174
- height: $height-cascader_selection_tagInput_input_small;
175
- }
176
- .#{$prefix}-input-wrapper-large {
177
- height: $height-cascader_selection_tagInput_input_large;
186
+ &-default {
187
+ margin-top: $spacing-cascader_selection_tag-marginY;
188
+ margin-bottom: $spacing-cascader_selection_tag-marginY;
189
+ }
190
+
191
+ &-large {
192
+ margin-top: $spacing-cascader_selection_tag-marginY;
193
+ margin-bottom: $spacing-cascader_selection_tag-marginY;
194
+ }
178
195
  }
196
+
197
+ // .#{$prefix}-input-wrapper-small {
198
+ // height: $height-cascader_selection_tagInput_input_small;
199
+ // }
200
+ // .#{$prefix}-input-wrapper-large {
201
+ // height: $height-cascader_selection_tagInput_input_large;
202
+ // }
179
203
  }
180
204
 
181
205
  &-text {
@@ -93,9 +93,9 @@ $width-cascader_search-border: 1px; // 级联选择触搜索描边宽度
93
93
  $width-cascader-icon: 16px; // 级联选择图标尺寸
94
94
  $width-cascader_option: 150px; // 级联选择各级菜单宽度
95
95
  $height-cascader_option_list: 180px; // 级联选择菜单高度
96
- $height-cascader_selection_tagInput_input_small: 22px;
97
- $height-cascader_selection_tagInput_input_default: 30px;
98
- $height-cascader_selection_tagInput_input_large: 38px;
96
+ $height-cascader_selection_tagInput_wrapper_small: 22px; //级联选择多选搜索时搜索框最小高度 - 小尺寸
97
+ $height-cascader_selection_tagInput_wrapper_default: 30px; //级联选择多选搜索时搜索框最小高度 - 默认尺寸
98
+ $height-cascader_selection_tagInput_wrapper_large: 38px; //级联选择多选搜索时搜索框最小高度 - 大尺寸
99
99
  $height-cascader_selection_wrapper: 30px;
100
100
 
101
101
  $spacing-cascader_text-marginX: $spacing-base-tight; // 级联选择 prefix/suffix 文字水平内间距
@@ -136,18 +136,28 @@
136
136
  background: transparent;
137
137
  margin-left: -4px;
138
138
  }
139
+ .semi-cascader-selection .semi-tagInput-wrapper-default {
140
+ min-height: 30px;
141
+ }
142
+ .semi-cascader-selection .semi-tagInput-wrapper-small {
143
+ min-height: 22px;
144
+ }
145
+ .semi-cascader-selection .semi-tagInput-wrapper-large {
146
+ min-height: 38px;
147
+ }
139
148
  .semi-cascader-selection .semi-tagInput .semi-input-wrapper {
140
- height: 30px;
141
149
  margin-left: 4px;
142
150
  }
143
151
  .semi-cascader-selection .semi-tagInput .semi-input-wrapper .semi-input {
144
152
  padding-left: 0;
145
153
  }
146
- .semi-cascader-selection .semi-tagInput .semi-input-wrapper-small {
147
- height: 22px;
154
+ .semi-cascader-selection .semi-tagInput .semi-input-wrapper-default {
155
+ margin-top: 1px;
156
+ margin-bottom: 1px;
148
157
  }
149
158
  .semi-cascader-selection .semi-tagInput .semi-input-wrapper-large {
150
- height: 38px;
159
+ margin-top: 1px;
160
+ margin-bottom: 1px;
151
161
  }
152
162
  .semi-cascader-selection-text-inactive {
153
163
  color: var(--semi-color-text-2);
@@ -159,23 +159,47 @@ $module: #{$prefix}-cascader;
159
159
  background: transparent;
160
160
  margin-left: $spacing-cascader_selection_tagInput-marginLeft;
161
161
  }
162
-
162
+
163
163
  .#{$prefix}-tagInput {
164
+ &-wrapper {
165
+ &-default {
166
+ min-height: $height-cascader_selection_tagInput_wrapper_default;
167
+ }
168
+
169
+ &-small {
170
+ min-height: $height-cascader_selection_tagInput_wrapper_small;
171
+ }
172
+
173
+ &-large {
174
+ min-height: $height-cascader_selection_tagInput_wrapper_large;
175
+ }
176
+ }
177
+
164
178
  .#{$prefix}-input-wrapper {
165
- height: $height-cascader_selection_tagInput_input_default;
179
+ // height: $height-cascader_selection_tagInput_input_default;
166
180
 
167
181
  margin-left: $spacing-cascader_selection_input-marginLeft;
168
182
  .#{$prefix}-input {
169
183
  padding-left: 0;
170
184
  }
171
- }
172
185
 
173
- .#{$prefix}-input-wrapper-small {
174
- height: $height-cascader_selection_tagInput_input_small;
175
- }
176
- .#{$prefix}-input-wrapper-large {
177
- height: $height-cascader_selection_tagInput_input_large;
186
+ &-default {
187
+ margin-top: $spacing-cascader_selection_tag-marginY;
188
+ margin-bottom: $spacing-cascader_selection_tag-marginY;
189
+ }
190
+
191
+ &-large {
192
+ margin-top: $spacing-cascader_selection_tag-marginY;
193
+ margin-bottom: $spacing-cascader_selection_tag-marginY;
194
+ }
178
195
  }
196
+
197
+ // .#{$prefix}-input-wrapper-small {
198
+ // height: $height-cascader_selection_tagInput_input_small;
199
+ // }
200
+ // .#{$prefix}-input-wrapper-large {
201
+ // height: $height-cascader_selection_tagInput_input_large;
202
+ // }
179
203
  }
180
204
 
181
205
  &-text {
@@ -93,9 +93,9 @@ $width-cascader_search-border: 1px; // 级联选择触搜索描边宽度
93
93
  $width-cascader-icon: 16px; // 级联选择图标尺寸
94
94
  $width-cascader_option: 150px; // 级联选择各级菜单宽度
95
95
  $height-cascader_option_list: 180px; // 级联选择菜单高度
96
- $height-cascader_selection_tagInput_input_small: 22px;
97
- $height-cascader_selection_tagInput_input_default: 30px;
98
- $height-cascader_selection_tagInput_input_large: 38px;
96
+ $height-cascader_selection_tagInput_wrapper_small: 22px; //级联选择多选搜索时搜索框最小高度 - 小尺寸
97
+ $height-cascader_selection_tagInput_wrapper_default: 30px; //级联选择多选搜索时搜索框最小高度 - 默认尺寸
98
+ $height-cascader_selection_tagInput_wrapper_large: 38px; //级联选择多选搜索时搜索框最小高度 - 大尺寸
99
99
  $height-cascader_selection_wrapper: 30px;
100
100
 
101
101
  $spacing-cascader_text-marginX: $spacing-base-tight; // 级联选择 prefix/suffix 文字水平内间距
@@ -42,6 +42,10 @@ export interface SelectAdapter<P = Record<string, any>, S = Record<string, any>>
42
42
  getActiveElement(): any;
43
43
  setIsFocusInContainer(isFocusInContainer: boolean): void;
44
44
  getIsFocusInContainer(): boolean;
45
+ on(eventName: string, eventCallback: () => void): void;
46
+ off(eventName: string): void;
47
+ emit(eventName: string): void;
48
+ once(eventName: string, eventCallback: () => void): void;
45
49
  }
46
50
  declare type LabelValue = string | number;
47
51
  declare type PropValue = LabelValue | Record<string, any>;
@@ -67,7 +71,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
67
71
  handleClick(e: any): void;
68
72
  open(acInput?: string, originalOptions?: BasicOptionProps[]): void;
69
73
  toggle2SearchInput(isShow: boolean): void;
70
- close(e?: any): void;
74
+ close(e?: any, closeCb?: () => void): void;
71
75
  onSelect(option: BasicOptionProps, optionIndex: number, event: MouseEvent | KeyboardEvent): void;
72
76
  _handleSingleSelect({ value, label, ...rest }: BasicOptionProps, event: any): void;
73
77
  _handleMultipleSelect({ value, label, ...rest }: BasicOptionProps, event: MouseEvent | KeyboardEvent): void;
@@ -126,5 +130,6 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
126
130
  checkMultipleProps(props?: Record<string, any>): void;
127
131
  updateScrollTop(): void;
128
132
  updateIsFullTags(): void;
133
+ handlePopoverClose(): void;
129
134
  }
130
135
  export {};
@@ -430,16 +430,8 @@ class SelectFoundation extends _foundation.default {
430
430
  }
431
431
  }
432
432
 
433
- close(e) {
433
+ close(e, closeCb) {
434
434
  // to support A11y, closing the panel trigger does not necessarily lose focus
435
- const isFilterable = this._isFilterable();
436
-
437
- if (isFilterable) {
438
- // this.unBindKeyBoardEvent();
439
- this.clearInput();
440
- this.toggle2SearchInput(false);
441
- }
442
-
443
435
  this._adapter.closeMenu();
444
436
 
445
437
  this._adapter.notifyDropdownVisibleChange(false);
@@ -450,6 +442,22 @@ class SelectFoundation extends _foundation.default {
450
442
 
451
443
  this._adapter.unregisterClickOutsideHandler(); // this._adapter.updateFocusState(false);
452
444
 
445
+
446
+ const isFilterable = this._isFilterable();
447
+
448
+ if (isFilterable) {
449
+ this.toggle2SearchInput(false);
450
+ }
451
+
452
+ this._adapter.once('popoverClose', () => {
453
+ if (isFilterable) {
454
+ this.clearInput();
455
+ }
456
+
457
+ if (closeCb) {
458
+ closeCb();
459
+ }
460
+ });
453
461
  }
454
462
 
455
463
  onSelect(option, optionIndex, event) {
@@ -493,21 +501,24 @@ class SelectFoundation extends _foundation.default {
493
501
  value,
494
502
  label
495
503
  }, rest)); // If it is a controlled component, directly notify
504
+ // Make sure that the operations of updating updateOptions are done after the animation ends
505
+ // otherwise the content will be updated when the popup layer is not collapsed, and it looks like it will flash once when it is closed
496
506
 
497
507
 
498
508
  if (this._isControlledComponent()) {
499
- this._notifyChange(selections);
500
-
501
- this.close(event);
509
+ this.close(event, () => {
510
+ this._notifyChange(selections);
511
+ });
502
512
  } else {
503
513
  this._adapter.updateSelection(selections); // notify user
504
514
 
505
515
 
506
- this._notifyChange(selections); // Update the selected item in the drop-down box
507
-
516
+ this._notifyChange(selections);
508
517
 
509
- this.close(event);
510
- this.updateOptionsActiveStatus(selections);
518
+ this.close(event, () => {
519
+ // Update the selected item in the drop-down box
520
+ this.updateOptionsActiveStatus(selections);
521
+ });
511
522
  }
512
523
  }
513
524
 
@@ -1398,6 +1409,10 @@ class SelectFoundation extends _foundation.default {
1398
1409
  }
1399
1410
  }
1400
1411
 
1412
+ handlePopoverClose() {
1413
+ this._adapter.emit('popoverClose');
1414
+ }
1415
+
1401
1416
  }
1402
1417
 
1403
1418
  exports.default = SelectFoundation;
@@ -134,7 +134,6 @@
134
134
  .semi-tagInput-wrapper .semi-tagInput-wrapper-input {
135
135
  flex-grow: 1;
136
136
  width: min-content;
137
- min-width: 38px;
138
137
  border: none;
139
138
  outline: none;
140
139
  background-color: transparent;
@@ -169,7 +169,7 @@ $module: #{$prefix}-tagInput;
169
169
  & &-input {
170
170
  flex-grow: 1;
171
171
  width: min-content;
172
- min-width: 38px;
172
+ // min-width: 38px;
173
173
  border: none;
174
174
  outline: none;
175
175
  background-color: transparent;
@@ -1142,23 +1142,26 @@ class Tooltip extends _foundation.default {
1142
1142
 
1143
1143
 
1144
1144
  if (this.isTB(position)) {
1145
- isHeightOverFlow = isViewYOverFlow && isContainerYOverFlow;
1145
+ isHeightOverFlow = isViewYOverFlow && isContainerYOverFlow; // Related PR: https://github.com/DouyinFE/semi-design/pull/1297
1146
+ // If clientRight or restClientRight less than 0, means that the left and right parts of the trigger are blocked
1147
+ // Then the display of the wrapper will also be affected, make width overflow to offset the wrapper
1146
1148
 
1147
1149
  if (position === 'top' || position === 'bottom') {
1148
- isWidthOverFlow = isViewXOverFlowSideHalf && isContainerXOverFlowSideHalf;
1150
+ isWidthOverFlow = isViewXOverFlowSideHalf && isContainerXOverFlowSideHalf || clientRight < 0 || restClientRight < 0;
1149
1151
  } else {
1150
- isWidthOverFlow = isViewXOverFlowSide && isContainerXOverFlowSide;
1152
+ isWidthOverFlow = isViewXOverFlowSide && isContainerXOverFlowSide || clientRight < 0 || restClientRight < 0;
1151
1153
  }
1152
1154
  } // 左右方向 left and right
1153
1155
 
1154
1156
 
1155
1157
  if (this.isLR(position)) {
1156
- isWidthOverFlow = isViewXOverFlow && isContainerXOverFlow;
1158
+ isWidthOverFlow = isViewXOverFlow && isContainerXOverFlow; // If clientTop or restClientTop less than 0, means that the top and bottom parts of the trigger are blocked
1159
+ // Then the display of the wrapper will also be affected, make height overflow to offset the wrapper
1157
1160
 
1158
1161
  if (position === 'left' || position === 'right') {
1159
- isHeightOverFlow = isViewYOverFlowSideHalf && isContainerYOverFlowSideHalf;
1162
+ isHeightOverFlow = isViewYOverFlowSideHalf && isContainerYOverFlowSideHalf || clientTop < 0 || restClientTop < 0;
1160
1163
  } else {
1161
- isHeightOverFlow = isViewYOverFlowSide && isContainerYOverFlowSide;
1164
+ isHeightOverFlow = isViewYOverFlowSide && isContainerYOverFlowSide || clientTop < 0 || restClientTop < 0;
1162
1165
  }
1163
1166
  }
1164
1167
  }
@@ -144,17 +144,25 @@
144
144
  padding-left: 4px;
145
145
  padding-right: 4px;
146
146
  }
147
- .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper .semi-input-wrapper {
148
- height: 30px;
147
+ .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper-default {
148
+ min-height: 30px;
149
+ }
150
+ .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper-small {
151
+ min-height: 22px;
152
+ }
153
+ .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper-large {
154
+ min-height: 38px;
149
155
  }
150
156
  .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper .semi-input-wrapper .semi-input {
151
157
  padding-left: 0;
152
158
  }
153
- .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper .semi-input-wrapper-small {
154
- height: 22px;
159
+ .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper .semi-input-wrapper-default {
160
+ margin-top: 1px;
161
+ margin-bottom: 1px;
155
162
  }
156
163
  .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper .semi-input-wrapper-large {
157
- height: 38px;
164
+ margin-top: 1px;
165
+ margin-bottom: 1px;
158
166
  }
159
167
  .semi-tree-select-multiple-tagInput-notEmpty .semi-tagInput {
160
168
  margin-left: -4px;
@@ -172,24 +172,46 @@ $module: #{$prefix}-tree-select;
172
172
  border: hidden;
173
173
  background: transparent;
174
174
 
175
- .#{$prefix}-tagInput-wrapper{
175
+ .#{$prefix}-tagInput-wrapper {
176
176
  padding-left: $spacing-treeSelect_selection_tagInput_wrapper-paddingX;
177
177
  padding-right: $spacing-treeSelect_selection_tagInput_wrapper-paddingX;
178
178
 
179
- .#{$prefix}-input-wrapper {
180
- height: $height-treeSelect_selection_tagInput_input_default;
179
+ &-default {
180
+ min-height: $height-treeSelect_selection_tagInput_wrapper_default;
181
+ }
181
182
 
183
+ &-small {
184
+ min-height: $height-treeSelect_selection_tagInput_wrapper_small;
185
+ }
186
+
187
+ &-large {
188
+ min-height: $height-treeSelect_selection_tagInput_wrapper_large;
189
+ }
190
+
191
+ .#{$prefix}-input-wrapper {
192
+ // height: $height-treeSelect_selection_tagInput_input_default;
193
+
182
194
  .#{$prefix}-input {
183
195
  padding-left: 0;
184
196
  }
197
+
198
+ &-default {
199
+ margin-top: $spacing-treeSelect_tag-marginY;
200
+ margin-bottom: $spacing-treeSelect_tag-marginY;
201
+ }
202
+
203
+ &-large {
204
+ margin-top: $spacing-treeSelect_tag-marginY;
205
+ margin-bottom: $spacing-treeSelect_tag-marginY;
206
+ }
185
207
  }
186
208
 
187
- .#{$prefix}-input-wrapper-small {
188
- height: $height-treeSelect_selection_tagInput_input_small;
189
- }
190
- .#{$prefix}-input-wrapper-large {
191
- height: $height-treeSelect_selection_tagInput_input_large;
192
- }
209
+ // .#{$prefix}-input-wrapper-small {
210
+ // height: $height-treeSelect_selection_tagInput_input_small;
211
+ // }
212
+ // .#{$prefix}-input-wrapper-large {
213
+ // height: $height-treeSelect_selection_tagInput_input_large;
214
+ // }
193
215
  }
194
216
  }
195
217
  }
@@ -87,6 +87,6 @@ $font-treeSelect_insertLabel-fontWeight: 600; // 带搜索的树前缀标签文
87
87
  $width-treeSelect_arrow: 32px; // 树选择器展开箭头宽度
88
88
  $width-treeSelect_option: 230px; // 树选择器菜单项宽度
89
89
  $height-treeSelect_popover: 300px; // 树选择器菜单高度
90
- $height-treeSelect_selection_tagInput_input_small: 22px; // 树选择器多选标签高度 - 小尺寸
91
- $height-treeSelect_selection_tagInput_input_default: 30px; // 树选择器多选标签高度 - 默认尺寸
92
- $height-treeSelect_selection_tagInput_input_large: 38px; // 树选择器多选标签高度 - 大尺寸
90
+ $height-treeSelect_selection_tagInput_wrapper_small: 22px; // 树选择器多选搜索,搜索框在选择框时选择框最小高度 - 小尺寸
91
+ $height-treeSelect_selection_tagInput_wrapper_default: 30px; // 树选择器多选搜索,搜索框在选择框时选择框最小高度 - 默认尺寸
92
+ $height-treeSelect_selection_tagInput_wrapper_large: 38px; // 树选择器多选搜索,搜索框在选择框时选择框最小高度 - 大尺寸
@@ -2,6 +2,6 @@ export default class Event {
2
2
  _eventMap: Map<string, ((...arg: any) => void)[]>;
3
3
  on(event: string, callback: (...arg: any) => void): this;
4
4
  once(event: string, callback: (...arg: any) => void): void;
5
- off(event: string, callback: null | (() => void)): this;
5
+ off(event: string, callback?: null | (() => void)): this;
6
6
  emit(event: string, ...args: any[]): boolean;
7
7
  }
@@ -136,18 +136,28 @@
136
136
  background: transparent;
137
137
  margin-left: -4px;
138
138
  }
139
+ .semi-cascader-selection .semi-tagInput-wrapper-default {
140
+ min-height: 30px;
141
+ }
142
+ .semi-cascader-selection .semi-tagInput-wrapper-small {
143
+ min-height: 22px;
144
+ }
145
+ .semi-cascader-selection .semi-tagInput-wrapper-large {
146
+ min-height: 38px;
147
+ }
139
148
  .semi-cascader-selection .semi-tagInput .semi-input-wrapper {
140
- height: 30px;
141
149
  margin-left: 4px;
142
150
  }
143
151
  .semi-cascader-selection .semi-tagInput .semi-input-wrapper .semi-input {
144
152
  padding-left: 0;
145
153
  }
146
- .semi-cascader-selection .semi-tagInput .semi-input-wrapper-small {
147
- height: 22px;
154
+ .semi-cascader-selection .semi-tagInput .semi-input-wrapper-default {
155
+ margin-top: 1px;
156
+ margin-bottom: 1px;
148
157
  }
149
158
  .semi-cascader-selection .semi-tagInput .semi-input-wrapper-large {
150
- height: 38px;
159
+ margin-top: 1px;
160
+ margin-bottom: 1px;
151
161
  }
152
162
  .semi-cascader-selection-text-inactive {
153
163
  color: var(--semi-color-text-2);
@@ -159,23 +159,47 @@ $module: #{$prefix}-cascader;
159
159
  background: transparent;
160
160
  margin-left: $spacing-cascader_selection_tagInput-marginLeft;
161
161
  }
162
-
162
+
163
163
  .#{$prefix}-tagInput {
164
+ &-wrapper {
165
+ &-default {
166
+ min-height: $height-cascader_selection_tagInput_wrapper_default;
167
+ }
168
+
169
+ &-small {
170
+ min-height: $height-cascader_selection_tagInput_wrapper_small;
171
+ }
172
+
173
+ &-large {
174
+ min-height: $height-cascader_selection_tagInput_wrapper_large;
175
+ }
176
+ }
177
+
164
178
  .#{$prefix}-input-wrapper {
165
- height: $height-cascader_selection_tagInput_input_default;
179
+ // height: $height-cascader_selection_tagInput_input_default;
166
180
 
167
181
  margin-left: $spacing-cascader_selection_input-marginLeft;
168
182
  .#{$prefix}-input {
169
183
  padding-left: 0;
170
184
  }
171
- }
172
185
 
173
- .#{$prefix}-input-wrapper-small {
174
- height: $height-cascader_selection_tagInput_input_small;
175
- }
176
- .#{$prefix}-input-wrapper-large {
177
- height: $height-cascader_selection_tagInput_input_large;
186
+ &-default {
187
+ margin-top: $spacing-cascader_selection_tag-marginY;
188
+ margin-bottom: $spacing-cascader_selection_tag-marginY;
189
+ }
190
+
191
+ &-large {
192
+ margin-top: $spacing-cascader_selection_tag-marginY;
193
+ margin-bottom: $spacing-cascader_selection_tag-marginY;
194
+ }
178
195
  }
196
+
197
+ // .#{$prefix}-input-wrapper-small {
198
+ // height: $height-cascader_selection_tagInput_input_small;
199
+ // }
200
+ // .#{$prefix}-input-wrapper-large {
201
+ // height: $height-cascader_selection_tagInput_input_large;
202
+ // }
179
203
  }
180
204
 
181
205
  &-text {
@@ -93,9 +93,9 @@ $width-cascader_search-border: 1px; // 级联选择触搜索描边宽度
93
93
  $width-cascader-icon: 16px; // 级联选择图标尺寸
94
94
  $width-cascader_option: 150px; // 级联选择各级菜单宽度
95
95
  $height-cascader_option_list: 180px; // 级联选择菜单高度
96
- $height-cascader_selection_tagInput_input_small: 22px;
97
- $height-cascader_selection_tagInput_input_default: 30px;
98
- $height-cascader_selection_tagInput_input_large: 38px;
96
+ $height-cascader_selection_tagInput_wrapper_small: 22px; //级联选择多选搜索时搜索框最小高度 - 小尺寸
97
+ $height-cascader_selection_tagInput_wrapper_default: 30px; //级联选择多选搜索时搜索框最小高度 - 默认尺寸
98
+ $height-cascader_selection_tagInput_wrapper_large: 38px; //级联选择多选搜索时搜索框最小高度 - 大尺寸
99
99
  $height-cascader_selection_wrapper: 30px;
100
100
 
101
101
  $spacing-cascader_text-marginX: $spacing-base-tight; // 级联选择 prefix/suffix 文字水平内间距
@@ -42,6 +42,10 @@ export interface SelectAdapter<P = Record<string, any>, S = Record<string, any>>
42
42
  getActiveElement(): any;
43
43
  setIsFocusInContainer(isFocusInContainer: boolean): void;
44
44
  getIsFocusInContainer(): boolean;
45
+ on(eventName: string, eventCallback: () => void): void;
46
+ off(eventName: string): void;
47
+ emit(eventName: string): void;
48
+ once(eventName: string, eventCallback: () => void): void;
45
49
  }
46
50
  declare type LabelValue = string | number;
47
51
  declare type PropValue = LabelValue | Record<string, any>;
@@ -67,7 +71,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
67
71
  handleClick(e: any): void;
68
72
  open(acInput?: string, originalOptions?: BasicOptionProps[]): void;
69
73
  toggle2SearchInput(isShow: boolean): void;
70
- close(e?: any): void;
74
+ close(e?: any, closeCb?: () => void): void;
71
75
  onSelect(option: BasicOptionProps, optionIndex: number, event: MouseEvent | KeyboardEvent): void;
72
76
  _handleSingleSelect({ value, label, ...rest }: BasicOptionProps, event: any): void;
73
77
  _handleMultipleSelect({ value, label, ...rest }: BasicOptionProps, event: MouseEvent | KeyboardEvent): void;
@@ -126,5 +130,6 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
126
130
  checkMultipleProps(props?: Record<string, any>): void;
127
131
  updateScrollTop(): void;
128
132
  updateIsFullTags(): void;
133
+ handlePopoverClose(): void;
129
134
  }
130
135
  export {};
@@ -408,16 +408,8 @@ export default class SelectFoundation extends BaseFoundation {
408
408
  }
409
409
  }
410
410
 
411
- close(e) {
411
+ close(e, closeCb) {
412
412
  // to support A11y, closing the panel trigger does not necessarily lose focus
413
- const isFilterable = this._isFilterable();
414
-
415
- if (isFilterable) {
416
- // this.unBindKeyBoardEvent();
417
- this.clearInput();
418
- this.toggle2SearchInput(false);
419
- }
420
-
421
413
  this._adapter.closeMenu();
422
414
 
423
415
  this._adapter.notifyDropdownVisibleChange(false);
@@ -428,6 +420,22 @@ export default class SelectFoundation extends BaseFoundation {
428
420
 
429
421
  this._adapter.unregisterClickOutsideHandler(); // this._adapter.updateFocusState(false);
430
422
 
423
+
424
+ const isFilterable = this._isFilterable();
425
+
426
+ if (isFilterable) {
427
+ this.toggle2SearchInput(false);
428
+ }
429
+
430
+ this._adapter.once('popoverClose', () => {
431
+ if (isFilterable) {
432
+ this.clearInput();
433
+ }
434
+
435
+ if (closeCb) {
436
+ closeCb();
437
+ }
438
+ });
431
439
  }
432
440
 
433
441
  onSelect(option, optionIndex, event) {
@@ -471,21 +479,24 @@ export default class SelectFoundation extends BaseFoundation {
471
479
  value,
472
480
  label
473
481
  }, rest)); // If it is a controlled component, directly notify
482
+ // Make sure that the operations of updating updateOptions are done after the animation ends
483
+ // otherwise the content will be updated when the popup layer is not collapsed, and it looks like it will flash once when it is closed
474
484
 
475
485
 
476
486
  if (this._isControlledComponent()) {
477
- this._notifyChange(selections);
478
-
479
- this.close(event);
487
+ this.close(event, () => {
488
+ this._notifyChange(selections);
489
+ });
480
490
  } else {
481
491
  this._adapter.updateSelection(selections); // notify user
482
492
 
483
493
 
484
- this._notifyChange(selections); // Update the selected item in the drop-down box
485
-
494
+ this._notifyChange(selections);
486
495
 
487
- this.close(event);
488
- this.updateOptionsActiveStatus(selections);
496
+ this.close(event, () => {
497
+ // Update the selected item in the drop-down box
498
+ this.updateOptionsActiveStatus(selections);
499
+ });
489
500
  }
490
501
  }
491
502
 
@@ -1376,4 +1387,8 @@ export default class SelectFoundation extends BaseFoundation {
1376
1387
  }
1377
1388
  }
1378
1389
 
1390
+ handlePopoverClose() {
1391
+ this._adapter.emit('popoverClose');
1392
+ }
1393
+
1379
1394
  }
@@ -134,7 +134,6 @@
134
134
  .semi-tagInput-wrapper .semi-tagInput-wrapper-input {
135
135
  flex-grow: 1;
136
136
  width: min-content;
137
- min-width: 38px;
138
137
  border: none;
139
138
  outline: none;
140
139
  background-color: transparent;
@@ -169,7 +169,7 @@ $module: #{$prefix}-tagInput;
169
169
  & &-input {
170
170
  flex-grow: 1;
171
171
  width: min-content;
172
- min-width: 38px;
172
+ // min-width: 38px;
173
173
  border: none;
174
174
  outline: none;
175
175
  background-color: transparent;
@@ -1132,23 +1132,26 @@ export default class Tooltip extends BaseFoundation {
1132
1132
 
1133
1133
 
1134
1134
  if (this.isTB(position)) {
1135
- isHeightOverFlow = isViewYOverFlow && isContainerYOverFlow;
1135
+ isHeightOverFlow = isViewYOverFlow && isContainerYOverFlow; // Related PR: https://github.com/DouyinFE/semi-design/pull/1297
1136
+ // If clientRight or restClientRight less than 0, means that the left and right parts of the trigger are blocked
1137
+ // Then the display of the wrapper will also be affected, make width overflow to offset the wrapper
1136
1138
 
1137
1139
  if (position === 'top' || position === 'bottom') {
1138
- isWidthOverFlow = isViewXOverFlowSideHalf && isContainerXOverFlowSideHalf;
1140
+ isWidthOverFlow = isViewXOverFlowSideHalf && isContainerXOverFlowSideHalf || clientRight < 0 || restClientRight < 0;
1139
1141
  } else {
1140
- isWidthOverFlow = isViewXOverFlowSide && isContainerXOverFlowSide;
1142
+ isWidthOverFlow = isViewXOverFlowSide && isContainerXOverFlowSide || clientRight < 0 || restClientRight < 0;
1141
1143
  }
1142
1144
  } // 左右方向 left and right
1143
1145
 
1144
1146
 
1145
1147
  if (this.isLR(position)) {
1146
- isWidthOverFlow = isViewXOverFlow && isContainerXOverFlow;
1148
+ isWidthOverFlow = isViewXOverFlow && isContainerXOverFlow; // If clientTop or restClientTop less than 0, means that the top and bottom parts of the trigger are blocked
1149
+ // Then the display of the wrapper will also be affected, make height overflow to offset the wrapper
1147
1150
 
1148
1151
  if (position === 'left' || position === 'right') {
1149
- isHeightOverFlow = isViewYOverFlowSideHalf && isContainerYOverFlowSideHalf;
1152
+ isHeightOverFlow = isViewYOverFlowSideHalf && isContainerYOverFlowSideHalf || clientTop < 0 || restClientTop < 0;
1150
1153
  } else {
1151
- isHeightOverFlow = isViewYOverFlowSide && isContainerYOverFlowSide;
1154
+ isHeightOverFlow = isViewYOverFlowSide && isContainerYOverFlowSide || clientTop < 0 || restClientTop < 0;
1152
1155
  }
1153
1156
  }
1154
1157
  }
@@ -144,17 +144,25 @@
144
144
  padding-left: 4px;
145
145
  padding-right: 4px;
146
146
  }
147
- .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper .semi-input-wrapper {
148
- height: 30px;
147
+ .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper-default {
148
+ min-height: 30px;
149
+ }
150
+ .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper-small {
151
+ min-height: 22px;
152
+ }
153
+ .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper-large {
154
+ min-height: 38px;
149
155
  }
150
156
  .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper .semi-input-wrapper .semi-input {
151
157
  padding-left: 0;
152
158
  }
153
- .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper .semi-input-wrapper-small {
154
- height: 22px;
159
+ .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper .semi-input-wrapper-default {
160
+ margin-top: 1px;
161
+ margin-bottom: 1px;
155
162
  }
156
163
  .semi-tree-select-selection .semi-tagInput .semi-tagInput-wrapper .semi-input-wrapper-large {
157
- height: 38px;
164
+ margin-top: 1px;
165
+ margin-bottom: 1px;
158
166
  }
159
167
  .semi-tree-select-multiple-tagInput-notEmpty .semi-tagInput {
160
168
  margin-left: -4px;
@@ -172,24 +172,46 @@ $module: #{$prefix}-tree-select;
172
172
  border: hidden;
173
173
  background: transparent;
174
174
 
175
- .#{$prefix}-tagInput-wrapper{
175
+ .#{$prefix}-tagInput-wrapper {
176
176
  padding-left: $spacing-treeSelect_selection_tagInput_wrapper-paddingX;
177
177
  padding-right: $spacing-treeSelect_selection_tagInput_wrapper-paddingX;
178
178
 
179
- .#{$prefix}-input-wrapper {
180
- height: $height-treeSelect_selection_tagInput_input_default;
179
+ &-default {
180
+ min-height: $height-treeSelect_selection_tagInput_wrapper_default;
181
+ }
181
182
 
183
+ &-small {
184
+ min-height: $height-treeSelect_selection_tagInput_wrapper_small;
185
+ }
186
+
187
+ &-large {
188
+ min-height: $height-treeSelect_selection_tagInput_wrapper_large;
189
+ }
190
+
191
+ .#{$prefix}-input-wrapper {
192
+ // height: $height-treeSelect_selection_tagInput_input_default;
193
+
182
194
  .#{$prefix}-input {
183
195
  padding-left: 0;
184
196
  }
197
+
198
+ &-default {
199
+ margin-top: $spacing-treeSelect_tag-marginY;
200
+ margin-bottom: $spacing-treeSelect_tag-marginY;
201
+ }
202
+
203
+ &-large {
204
+ margin-top: $spacing-treeSelect_tag-marginY;
205
+ margin-bottom: $spacing-treeSelect_tag-marginY;
206
+ }
185
207
  }
186
208
 
187
- .#{$prefix}-input-wrapper-small {
188
- height: $height-treeSelect_selection_tagInput_input_small;
189
- }
190
- .#{$prefix}-input-wrapper-large {
191
- height: $height-treeSelect_selection_tagInput_input_large;
192
- }
209
+ // .#{$prefix}-input-wrapper-small {
210
+ // height: $height-treeSelect_selection_tagInput_input_small;
211
+ // }
212
+ // .#{$prefix}-input-wrapper-large {
213
+ // height: $height-treeSelect_selection_tagInput_input_large;
214
+ // }
193
215
  }
194
216
  }
195
217
  }
@@ -87,6 +87,6 @@ $font-treeSelect_insertLabel-fontWeight: 600; // 带搜索的树前缀标签文
87
87
  $width-treeSelect_arrow: 32px; // 树选择器展开箭头宽度
88
88
  $width-treeSelect_option: 230px; // 树选择器菜单项宽度
89
89
  $height-treeSelect_popover: 300px; // 树选择器菜单高度
90
- $height-treeSelect_selection_tagInput_input_small: 22px; // 树选择器多选标签高度 - 小尺寸
91
- $height-treeSelect_selection_tagInput_input_default: 30px; // 树选择器多选标签高度 - 默认尺寸
92
- $height-treeSelect_selection_tagInput_input_large: 38px; // 树选择器多选标签高度 - 大尺寸
90
+ $height-treeSelect_selection_tagInput_wrapper_small: 22px; // 树选择器多选搜索,搜索框在选择框时选择框最小高度 - 小尺寸
91
+ $height-treeSelect_selection_tagInput_wrapper_default: 30px; // 树选择器多选搜索,搜索框在选择框时选择框最小高度 - 默认尺寸
92
+ $height-treeSelect_selection_tagInput_wrapper_large: 38px; // 树选择器多选搜索,搜索框在选择框时选择框最小高度 - 大尺寸
@@ -2,6 +2,6 @@ export default class Event {
2
2
  _eventMap: Map<string, ((...arg: any) => void)[]>;
3
3
  on(event: string, callback: (...arg: any) => void): this;
4
4
  once(event: string, callback: (...arg: any) => void): void;
5
- off(event: string, callback: null | (() => void)): this;
5
+ off(event: string, callback?: null | (() => void)): this;
6
6
  emit(event: string, ...args: any[]): boolean;
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.23.5",
3
+ "version": "2.23.6",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
@@ -23,7 +23,7 @@
23
23
  "*.scss",
24
24
  "*.css"
25
25
  ],
26
- "gitHead": "c3cd98419912c96831a20c5a9f8ce33295b19d5d",
26
+ "gitHead": "d6064611e073d549b28c0ba5395bff3efd74e0ad",
27
27
  "devDependencies": {
28
28
  "@babel/plugin-transform-runtime": "^7.15.8",
29
29
  "@babel/preset-env": "^7.15.8",
@@ -50,7 +50,11 @@ export interface SelectAdapter<P = Record<string, any>, S = Record<string, any>>
50
50
  getFocusableElements(node: any): any[];
51
51
  getActiveElement(): any;
52
52
  setIsFocusInContainer(isFocusInContainer: boolean): void;
53
- getIsFocusInContainer(): boolean
53
+ getIsFocusInContainer(): boolean;
54
+ on(eventName: string, eventCallback: () => void): void;
55
+ off(eventName: string): void;
56
+ emit(eventName: string): void;
57
+ once(eventName: string, eventCallback: () => void): void
54
58
  }
55
59
 
56
60
  type LabelValue = string | number;
@@ -364,14 +368,8 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
364
368
  }
365
369
  }
366
370
 
367
- close(e?: any) {
371
+ close(e?: any, closeCb?: () => void) {
368
372
  // to support A11y, closing the panel trigger does not necessarily lose focus
369
- const isFilterable = this._isFilterable();
370
- if (isFilterable) {
371
- // this.unBindKeyBoardEvent();
372
- this.clearInput();
373
- this.toggle2SearchInput(false);
374
- }
375
373
 
376
374
  this._adapter.closeMenu();
377
375
  this._adapter.notifyDropdownVisibleChange(false);
@@ -380,6 +378,20 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
380
378
  // this._notifyBlur(e);
381
379
  this._adapter.unregisterClickOutsideHandler();
382
380
  // this._adapter.updateFocusState(false);
381
+
382
+ const isFilterable = this._isFilterable();
383
+ if (isFilterable) {
384
+ this.toggle2SearchInput(false);
385
+ }
386
+
387
+ this._adapter.once('popoverClose', () => {
388
+ if (isFilterable) {
389
+ this.clearInput();
390
+ }
391
+ if (closeCb) {
392
+ closeCb();
393
+ }
394
+ });
383
395
  }
384
396
 
385
397
  onSelect(option: BasicOptionProps, optionIndex: number, event: MouseEvent | KeyboardEvent) {
@@ -407,18 +419,22 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
407
419
  const selections = new Map().set(label, { value, label, ...rest });
408
420
  // First trigger onSelect, then trigger onChange
409
421
  this._notifySelect(value, { value, label, ...rest });
410
-
411
422
  // If it is a controlled component, directly notify
423
+ // Make sure that the operations of updating updateOptions are done after the animation ends
424
+ // otherwise the content will be updated when the popup layer is not collapsed, and it looks like it will flash once when it is closed
412
425
  if (this._isControlledComponent()) {
413
- this._notifyChange(selections);
414
- this.close(event);
426
+ this.close(event, () => {
427
+ this._notifyChange(selections);
428
+ });
415
429
  } else {
416
430
  this._adapter.updateSelection(selections);
417
431
  // notify user
418
432
  this._notifyChange(selections);
419
- // Update the selected item in the drop-down box
420
- this.close(event);
421
- this.updateOptionsActiveStatus(selections);
433
+
434
+ this.close(event, () => {
435
+ // Update the selected item in the drop-down box
436
+ this.updateOptionsActiveStatus(selections);
437
+ });
422
438
  }
423
439
  }
424
440
 
@@ -1093,4 +1109,8 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
1093
1109
  });
1094
1110
  }
1095
1111
  }
1112
+
1113
+ handlePopoverClose() {
1114
+ this._adapter.emit('popoverClose');
1115
+ }
1096
1116
  }
@@ -169,7 +169,7 @@ $module: #{$prefix}-tagInput;
169
169
  & &-input {
170
170
  flex-grow: 1;
171
171
  width: min-content;
172
- min-width: 38px;
172
+ // min-width: 38px;
173
173
  border: none;
174
174
  outline: none;
175
175
  background-color: transparent;
@@ -1002,19 +1002,24 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
1002
1002
  // 上下方向 top and bottom
1003
1003
  if (this.isTB(position)){
1004
1004
  isHeightOverFlow = isViewYOverFlow && isContainerYOverFlow;
1005
+ // Related PR: https://github.com/DouyinFE/semi-design/pull/1297
1006
+ // If clientRight or restClientRight less than 0, means that the left and right parts of the trigger are blocked
1007
+ // Then the display of the wrapper will also be affected, make width overflow to offset the wrapper
1005
1008
  if (position === 'top' || position === 'bottom') {
1006
- isWidthOverFlow = isViewXOverFlowSideHalf && isContainerXOverFlowSideHalf;
1009
+ isWidthOverFlow = isViewXOverFlowSideHalf && isContainerXOverFlowSideHalf || (clientRight < 0 || restClientRight < 0);
1007
1010
  } else {
1008
- isWidthOverFlow = isViewXOverFlowSide && isContainerXOverFlowSide;
1011
+ isWidthOverFlow = isViewXOverFlowSide && isContainerXOverFlowSide || (clientRight < 0 || restClientRight < 0);
1009
1012
  }
1010
1013
  }
1011
1014
  // 左右方向 left and right
1012
1015
  if (this.isLR(position)){
1013
1016
  isWidthOverFlow = isViewXOverFlow && isContainerXOverFlow;
1017
+ // If clientTop or restClientTop less than 0, means that the top and bottom parts of the trigger are blocked
1018
+ // Then the display of the wrapper will also be affected, make height overflow to offset the wrapper
1014
1019
  if (position === 'left' || position === 'right') {
1015
- isHeightOverFlow = isViewYOverFlowSideHalf && isContainerYOverFlowSideHalf;
1020
+ isHeightOverFlow = isViewYOverFlowSideHalf && isContainerYOverFlowSideHalf || (clientTop < 0 || restClientTop < 0);
1016
1021
  } else {
1017
- isHeightOverFlow = isViewYOverFlowSide && isContainerYOverFlowSide;
1022
+ isHeightOverFlow = isViewYOverFlowSide && isContainerYOverFlowSide || (clientTop < 0 || restClientTop < 0);
1018
1023
  }
1019
1024
  }
1020
1025
  }
@@ -172,24 +172,46 @@ $module: #{$prefix}-tree-select;
172
172
  border: hidden;
173
173
  background: transparent;
174
174
 
175
- .#{$prefix}-tagInput-wrapper{
175
+ .#{$prefix}-tagInput-wrapper {
176
176
  padding-left: $spacing-treeSelect_selection_tagInput_wrapper-paddingX;
177
177
  padding-right: $spacing-treeSelect_selection_tagInput_wrapper-paddingX;
178
178
 
179
- .#{$prefix}-input-wrapper {
180
- height: $height-treeSelect_selection_tagInput_input_default;
179
+ &-default {
180
+ min-height: $height-treeSelect_selection_tagInput_wrapper_default;
181
+ }
181
182
 
183
+ &-small {
184
+ min-height: $height-treeSelect_selection_tagInput_wrapper_small;
185
+ }
186
+
187
+ &-large {
188
+ min-height: $height-treeSelect_selection_tagInput_wrapper_large;
189
+ }
190
+
191
+ .#{$prefix}-input-wrapper {
192
+ // height: $height-treeSelect_selection_tagInput_input_default;
193
+
182
194
  .#{$prefix}-input {
183
195
  padding-left: 0;
184
196
  }
197
+
198
+ &-default {
199
+ margin-top: $spacing-treeSelect_tag-marginY;
200
+ margin-bottom: $spacing-treeSelect_tag-marginY;
201
+ }
202
+
203
+ &-large {
204
+ margin-top: $spacing-treeSelect_tag-marginY;
205
+ margin-bottom: $spacing-treeSelect_tag-marginY;
206
+ }
185
207
  }
186
208
 
187
- .#{$prefix}-input-wrapper-small {
188
- height: $height-treeSelect_selection_tagInput_input_small;
189
- }
190
- .#{$prefix}-input-wrapper-large {
191
- height: $height-treeSelect_selection_tagInput_input_large;
192
- }
209
+ // .#{$prefix}-input-wrapper-small {
210
+ // height: $height-treeSelect_selection_tagInput_input_small;
211
+ // }
212
+ // .#{$prefix}-input-wrapper-large {
213
+ // height: $height-treeSelect_selection_tagInput_input_large;
214
+ // }
193
215
  }
194
216
  }
195
217
  }
@@ -87,6 +87,6 @@ $font-treeSelect_insertLabel-fontWeight: 600; // 带搜索的树前缀标签文
87
87
  $width-treeSelect_arrow: 32px; // 树选择器展开箭头宽度
88
88
  $width-treeSelect_option: 230px; // 树选择器菜单项宽度
89
89
  $height-treeSelect_popover: 300px; // 树选择器菜单高度
90
- $height-treeSelect_selection_tagInput_input_small: 22px; // 树选择器多选标签高度 - 小尺寸
91
- $height-treeSelect_selection_tagInput_input_default: 30px; // 树选择器多选标签高度 - 默认尺寸
92
- $height-treeSelect_selection_tagInput_input_large: 38px; // 树选择器多选标签高度 - 大尺寸
90
+ $height-treeSelect_selection_tagInput_wrapper_small: 22px; // 树选择器多选搜索,搜索框在选择框时选择框最小高度 - 小尺寸
91
+ $height-treeSelect_selection_tagInput_wrapper_default: 30px; // 树选择器多选搜索,搜索框在选择框时选择框最小高度 - 默认尺寸
92
+ $height-treeSelect_selection_tagInput_wrapper_large: 38px; // 树选择器多选搜索,搜索框在选择框时选择框最小高度 - 大尺寸
package/utils/Event.ts CHANGED
@@ -23,7 +23,7 @@ export default class Event {
23
23
  }
24
24
  }
25
25
 
26
- off(event: string, callback: null | (() => void)) {
26
+ off(event: string, callback?: null | (() => void)) {
27
27
  if (event) {
28
28
  if (typeof callback === 'function') {
29
29
  const callbacks = this._eventMap.get(event);