@douyinfe/semi-foundation 2.11.0 → 2.12.0-alpha.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.
@@ -294,7 +294,8 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
294
294
  }
295
295
 
296
296
  handleUpClick(event: any) {
297
- if (!this._isMouseButtonLeft(event)) {
297
+ const { readonly } = this.getProps();
298
+ if (!this._isMouseButtonLeft(event) || readonly) {
298
299
  return;
299
300
  }
300
301
  this._adapter.setClickUpOrDown(true);
@@ -314,7 +315,8 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
314
315
  }
315
316
 
316
317
  handleDownClick(event: any) {
317
- if (!this._isMouseButtonLeft(event)) {
318
+ const { readonly } = this.getProps();
319
+ if (!this._isMouseButtonLeft(event) || readonly) {
318
320
  return;
319
321
  }
320
322
  this._adapter.setClickUpOrDown(true);
@@ -321,7 +321,11 @@ class InputNumberFoundation extends _foundation.default {
321
321
  }
322
322
 
323
323
  handleUpClick(event) {
324
- if (!this._isMouseButtonLeft(event)) {
324
+ const {
325
+ readonly
326
+ } = this.getProps();
327
+
328
+ if (!this._isMouseButtonLeft(event) || readonly) {
325
329
  return;
326
330
  }
327
331
 
@@ -344,7 +348,11 @@ class InputNumberFoundation extends _foundation.default {
344
348
  }
345
349
 
346
350
  handleDownClick(event) {
347
- if (!this._isMouseButtonLeft(event)) {
351
+ const {
352
+ readonly
353
+ } = this.getProps();
354
+
355
+ if (!this._isMouseButtonLeft(event) || readonly) {
348
356
  return;
349
357
  }
350
358
 
@@ -19,5 +19,10 @@ declare class TabsFoundation<P = Record<string, any>, S = Record<string, any>> e
19
19
  handleTabListChange(): void;
20
20
  handleTabPanesChange(): void;
21
21
  handleTabDelete(tabKey: string): void;
22
+ handlePrevent: (event: any) => void;
23
+ handleKeyDown: (event: any, itemKey: string, closable: boolean) => void;
24
+ determineOrientation(event: any, tabs: HTMLElement[]): void;
25
+ handleDeleteKeyDown(event: any, tabs: HTMLElement[], itemKey: string, closable: boolean): void;
26
+ switchTabOnArrowPress(event: any, tabs: HTMLElement[]): void;
22
27
  }
23
28
  export default TabsFoundation;
@@ -12,14 +12,69 @@ exports.default = void 0;
12
12
 
13
13
  var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
14
14
 
15
+ var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
16
+
17
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
18
+
19
+ var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
20
+
15
21
  var _noop2 = _interopRequireDefault(require("lodash/noop"));
16
22
 
23
+ var _get2 = _interopRequireDefault(require("lodash/get"));
24
+
17
25
  var _foundation = _interopRequireDefault(require("../base/foundation"));
18
26
 
19
27
  class TabsFoundation extends _foundation.default {
20
28
  constructor(adapter) {
21
29
  super((0, _assign.default)({}, adapter));
22
30
  this.destroy = _noop2.default;
31
+
32
+ this.handlePrevent = event => {
33
+ event.stopPropagation();
34
+ event.preventDefault();
35
+ };
36
+
37
+ this.handleKeyDown = (event, itemKey, closable) => {
38
+ var _context;
39
+
40
+ const tabs = (0, _filter.default)(_context = [...event.target.parentNode.childNodes]).call(_context, item => {
41
+ var _context2;
42
+
43
+ return (0, _includes.default)(_context2 = (0, _get2.default)(item, 'attributes.data-tabkey.value', '')).call(_context2, 'semiTab') && item.ariaDisabled !== "true";
44
+ });
45
+
46
+ switch (event.key) {
47
+ case "ArrowLeft":
48
+ case "ArrowRight":
49
+ case "ArrowUp":
50
+ case "ArrowDown":
51
+ this.determineOrientation(event, tabs);
52
+ break;
53
+
54
+ case "Backspace":
55
+ case "Delete":
56
+ this.handleDeleteKeyDown(event, tabs, itemKey, closable);
57
+ break;
58
+
59
+ case "Enter":
60
+ case " ":
61
+ this.handleTabClick(itemKey, event);
62
+ this.handlePrevent(event);
63
+ break;
64
+
65
+ case "Home":
66
+ tabs[0].focus(); // focus first tab
67
+
68
+ this.handlePrevent(event);
69
+ break;
70
+
71
+ case "End":
72
+ tabs[tabs.length - 1].focus(); // focus last tab
73
+
74
+ this.handlePrevent(event);
75
+ break;
76
+ }
77
+ };
23
78
  }
24
79
 
25
80
  init() {
@@ -89,6 +144,59 @@ class TabsFoundation extends _foundation.default {
89
144
  this._adapter.notifyTabDelete(tabKey);
90
145
  }
91
146
 
147
+ determineOrientation(event, tabs) {
148
+ const {
149
+ tabPosition
150
+ } = this.getProps();
151
+ const isVertical = tabPosition === 'left';
152
+
153
+ if (isVertical) {
154
+ if (event.key === "ArrowUp" || event.key === "ArrowDown") {
155
+ this.switchTabOnArrowPress(event, tabs);
156
+ this.handlePrevent(event);
157
+ }
158
+ } else {
159
+ if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
160
+ this.switchTabOnArrowPress(event, tabs);
161
+ this.handlePrevent(event);
162
+ }
163
+ }
164
+ }
165
+
166
+ handleDeleteKeyDown(event, tabs, itemKey, closable) {
167
+ if (closable) {
168
+ this.handleTabDelete(itemKey);
169
+ const index = (0, _indexOf.default)(tabs).call(tabs, event.target); // Move focus to next element after deletion
170
+ // If the element is the last removable tab, focus to its previous tab
171
+
172
+ if (tabs.length !== 1) {
173
+ tabs[index + 1 >= tabs.length ? index - 1 : index + 1].focus();
174
+ }
175
+ }
176
+ }
177
+
178
+ switchTabOnArrowPress(event, tabs) {
179
+ const index = (0, _indexOf.default)(tabs).call(tabs, event.target);
180
+ const direction = {
181
+ "ArrowLeft": -1,
182
+ "ArrowUp": -1,
183
+ "ArrowRight": 1,
184
+ "ArrowDown": 1
185
+ };
186
+
187
+ if (direction[event.key]) {
188
+ if (index !== undefined) {
189
+ if (tabs[index + direction[event.key]]) {
190
+ tabs[index + direction[event.key]].focus();
191
+ } else if (event.key === "ArrowLeft" || event.key === "ArrowUp") {
192
+ tabs[tabs.length - 1].focus(); // focus last tab
193
+ } else if (event.key === "ArrowRight" || event.key == "ArrowDown") {
194
+ tabs[0].focus(); // focus first tab
195
+ }
196
+ }
197
+ }
198
+ }
199
+
92
200
  }
93
201
 
94
202
  var _default = TabsFoundation;
@@ -101,6 +101,10 @@
101
101
  width: 0;
102
102
  height: 0;
103
103
  }
104
+ .semi-tabs-bar-collapse .semi-overflow-list .semi-overflow-list-scroll-wrapper:focus-visible {
105
+ outline: 2px solid var(--semi-color-primary-light-active);
106
+ outline-offset: -2px;
107
+ }
104
108
  .semi-tabs-bar-collapse .semi-tabs-bar-arrow-start {
105
109
  margin-right: 4px;
106
110
  }
@@ -130,6 +134,10 @@
130
134
  .semi-tabs-bar-line.semi-tabs-bar-top .semi-tabs-tab:hover {
131
135
  border-bottom: 2px solid var(--semi-color-fill-0);
132
136
  }
137
+ .semi-tabs-bar-line.semi-tabs-bar-top .semi-tabs-tab:focus-visible {
138
+ outline: 2px solid var(--semi-color-primary-light-active);
139
+ outline-offset: -1px;
140
+ }
133
141
  .semi-tabs-bar-line.semi-tabs-bar-top .semi-tabs-tab:active {
134
142
  border-bottom: 2px solid var(--semi-color-fill-1);
135
143
  }
@@ -156,6 +164,10 @@
156
164
  border-left: 2px solid var(--semi-color-fill-0);
157
165
  background-color: var(--semi-color-fill-0);
158
166
  }
167
+ .semi-tabs-bar-line.semi-tabs-bar-left .semi-tabs-tab:focus-visible {
168
+ outline: 2px solid var(--semi-color-primary-light-active);
169
+ outline-offset: -2px;
170
+ }
159
171
  .semi-tabs-bar-line.semi-tabs-bar-left .semi-tabs-tab:active {
160
172
  border-left: 2px solid var(--semi-color-fill-1);
161
173
  background-color: var(--semi-color-fill-1);
@@ -241,6 +253,10 @@
241
253
  .semi-tabs-bar-card .semi-tabs-tab:hover {
242
254
  background: var(--semi-color-fill-0);
243
255
  }
256
+ .semi-tabs-bar-card .semi-tabs-tab:focus-visible {
257
+ outline: 2px solid var(--semi-color-primary-light-active);
258
+ outline-offset: -2px;
259
+ }
244
260
  .semi-tabs-bar-card .semi-tabs-tab:active {
245
261
  background: var(--semi-color-fill-1);
246
262
  }
@@ -263,6 +279,10 @@
263
279
  border: none;
264
280
  background-color: var(--semi-color-fill-0);
265
281
  }
282
+ .semi-tabs-bar-button .semi-tabs-tab:focus-visible {
283
+ outline: 2px solid var(--semi-color-primary-light-active);
284
+ outline-offset: -2px;
285
+ }
266
286
  .semi-tabs-bar-button .semi-tabs-tab:active {
267
287
  background-color: var(--semi-color-fill-1);
268
288
  }
@@ -283,6 +303,9 @@
283
303
  width: 100%;
284
304
  overflow: hidden;
285
305
  }
306
+ .semi-tabs-pane:focus-visible {
307
+ outline: 2px solid var(--semi-color-primary-light-active);
308
+ }
286
309
  .semi-tabs-pane-inactive, .semi-tabs-content-no-animated .semi-tabs-pane-inactive {
287
310
  display: none;
288
311
  }
@@ -124,6 +124,11 @@ $module: #{$prefix}-tabs;
124
124
  width: 0;
125
125
  height: 0;
126
126
  }
127
+
128
+ &:focus-visible {
129
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
130
+ outline-offset: $width-tabs-outline-offset;
131
+ }
127
132
  }
128
133
  }
129
134
 
@@ -164,6 +169,11 @@ $module: #{$prefix}-tabs;
164
169
  &:hover {
165
170
  border-bottom: $width-tabs_bar_line_tab-border solid $color-tabs_tab_line_default-border-hover;
166
171
  }
172
+
173
+ &:focus-visible {
174
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
175
+ outline-offset: $width-tabs_bar_line-outline-offset;
176
+ }
167
177
 
168
178
  &:active {
169
179
  border-bottom: $width-tabs_bar_line_tab-border solid $color-tabs_tab_line_default-border-active;
@@ -202,6 +212,11 @@ $module: #{$prefix}-tabs;
202
212
  border-left: $width-tabs_bar_line_tab-border solid $color-tabs_tab_line_default-border-hover;
203
213
  background-color: $color-tabs_tab_line_vertical-bg-hover;
204
214
  }
215
+
216
+ &:focus-visible {
217
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
218
+ outline-offset: $width-tabs-outline-offset;
219
+ }
205
220
 
206
221
  &:active {
207
222
  border-left: $width-tabs_bar_line_tab-border solid $color-tabs_tab_line_default-border-active;
@@ -327,6 +342,11 @@ $module: #{$prefix}-tabs;
327
342
  &:hover {
328
343
  background: $color-tabs_tab_card-bg-hover;
329
344
  }
345
+
346
+ &:focus-visible {
347
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
348
+ outline-offset: $width-tabs-outline-offset;
349
+ }
330
350
 
331
351
  &:active {
332
352
  background: $color-tabs_tab_card-bg-active;
@@ -365,6 +385,11 @@ $module: #{$prefix}-tabs;
365
385
  border: none;
366
386
  background-color: $color-tabs_tab_button-bg-hover;
367
387
  }
388
+
389
+ &:focus-visible {
390
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
391
+ outline-offset: $width-tabs-outline-offset;
392
+ }
368
393
 
369
394
  &:active {
370
395
  background-color: $color-tabs_tab_button-bg-active;
@@ -393,13 +418,17 @@ $module: #{$prefix}-tabs;
393
418
  height: 100%;
394
419
  padding: $spacing-tabs_content_left-paddingY $spacing-tabs_content_left-paddingX;
395
420
  }
396
-
421
+
397
422
  &-pane {
398
423
  width: 100%;
399
424
  overflow: hidden;
400
425
  // position: absolute;
401
426
  // flex-shrink: 0;
402
427
  // position: absolute;
428
+
429
+ &:focus-visible {
430
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
431
+ }
403
432
  }
404
433
 
405
434
  &-pane-inactive,
@@ -44,6 +44,8 @@ $color-tabs_tab-icon-hover: var(--semi-color-text-0); // 页签图标颜色 -
44
44
  $color-tabs_tab-icon-active: var(--semi-color-text-0); // 页签图标颜色 - 按下
45
45
  $color-tabs_tab_selected-icon-default: var(--semi-color-primary); // 页签图标颜色 - 选中
46
46
 
47
+ $color-tabs_tab-outline-focus: var(--semi-color-primary-light-active); // 页签轮廓 - 聚焦
48
+
47
49
 
48
50
  $font-tabs_tab-fontWeight: $font-weight-regular; // 页签文本字重 - 默认
49
51
  $font-tabs_tab_active-fontWeight: $font-weight-bold; // 页签文本字重 - 选中
@@ -54,6 +56,9 @@ $width-tabs_bar_line-border: $border-thickness-control; // 线条式页签底部
54
56
  $width-tabs_bar_line_tab-border: 2px; // 页签标示线宽度
55
57
 
56
58
  $width-tabs_bar_card-border: $border-thickness-control; // 卡片式页签底部分割线宽度
59
+ $width-tabs-outline: 2px; // 聚焦轮廓宽度
60
+ $width-tabs-outline-offset: -2px; // 聚焦轮廓偏移宽度
61
+ $width-tabs_bar_line-outline-offset: -1px; // 线条式页签聚焦轮廓偏移宽度
57
62
 
58
63
  $height-tabs_bar_extra_large: 50px; // 大尺寸页签高度
59
64
  $font-tabs_bar_extra_large-lineHeight: $height-tabs_bar_extra_large; // 大尺寸页签文字行高
@@ -19,6 +19,9 @@
19
19
  height: 20px;
20
20
  padding: 2px 8px;
21
21
  }
22
+ .semi-tag-default:focus-visible, .semi-tag-small:focus-visible {
23
+ outline: 2px solid var(--semi-color-primary-light-active);
24
+ }
22
25
  .semi-tag-large {
23
26
  font-size: 12px;
24
27
  line-height: 16px;
@@ -26,6 +29,9 @@
26
29
  padding: 4px 8px;
27
30
  height: 24px;
28
31
  }
32
+ .semi-tag-large:focus-visible {
33
+ outline: 2px solid var(--semi-color-primary-light-active);
34
+ }
29
35
  .semi-tag-invisible {
30
36
  display: none;
31
37
  }
@@ -392,6 +398,10 @@
392
398
  color: var(--semi-color-text-0);
393
399
  }
394
400
 
401
+ .semi-tag-solid .semi-tag-close {
402
+ color: var(--semi-color-white);
403
+ }
404
+
395
405
  .semi-rtl .semi-tag,
396
406
  .semi-portal-rtl .semi-tag {
397
407
  direction: rtl;
@@ -25,12 +25,18 @@ $types: "ghost", "solid", "light";
25
25
  @include font-size-small;
26
26
  height: $height-tag_small;
27
27
  padding: $spacing-tag_small-paddingY $spacing-tag_small-paddingX;
28
+ &:focus-visible {
29
+ outline: $width-tag-outline solid $color-tag-outline-focus;
30
+ }
28
31
  }
29
32
 
30
33
  &-large {
31
34
  @include font-size-small;
32
35
  padding: $spacing-tag_large-paddingY $spacing-tag_large-paddingX;
33
36
  height: $height-tag_large;
37
+ &:focus-visible {
38
+ outline: $width-tag-outline solid $color-tag-outline-focus;
39
+ }
34
40
  }
35
41
 
36
42
  &-invisible {
@@ -46,12 +52,13 @@ $types: "ghost", "solid", "light";
46
52
  &-close {
47
53
  @include all-center;
48
54
  color: $color-tag_close-icon-default;
49
- padding-left: $spacing-tag_close-paddingLeft;
55
+ padding-left: $spacing-tag_close-paddingLeft;
50
56
  cursor: pointer;
51
57
  }
52
58
 
53
59
  &-closable {
54
- padding: $spacing-tag_closable-paddingTop $spacing-tag_closable-paddingRight $spacing-tag_closable-paddingBottom $spacing-tag_closable-paddingLeft;
60
+ padding: $spacing-tag_closable-paddingTop $spacing-tag_closable-paddingRight $spacing-tag_closable-paddingBottom
61
+ $spacing-tag_closable-paddingLeft;
55
62
  }
56
63
 
57
64
  &-avatar-square,
@@ -62,10 +69,10 @@ $types: "ghost", "solid", "light";
62
69
  }
63
70
 
64
71
  &-avatar-square {
65
- padding: $spacing-tag_avatar_square-paddingTop $spacing-tag_avatar_square-paddingRight $spacing-tag_avatar_square-paddingBottom $spacing-tag_avatar_square-paddingLeft;
72
+ padding: $spacing-tag_avatar_square-paddingTop $spacing-tag_avatar_square-paddingRight
73
+ $spacing-tag_avatar_square-paddingBottom $spacing-tag_avatar_square-paddingLeft;
66
74
 
67
75
  .#{$prefix}-avatar {
68
-
69
76
  & > img {
70
77
  background-color: $color-tag_avatar_square_img-bg-default;
71
78
  }
@@ -73,10 +80,12 @@ $types: "ghost", "solid", "light";
73
80
  }
74
81
 
75
82
  &-avatar-circle {
76
- padding: $spacing-tag_avatar_circle-paddingTop $spacing-tag_avatar_circle-paddingRight $spacing-tag_avatar_circle-paddingBottom $spacing-tag_avatar_circle-paddingLeft;
83
+ padding: $spacing-tag_avatar_circle-paddingTop $spacing-tag_avatar_circle-paddingRight
84
+ $spacing-tag_avatar_circle-paddingBottom $spacing-tag_avatar_circle-paddingLeft;
77
85
  }
78
86
 
79
- &-avatar-square.#{$module}-default, &-avatar-square.#{$module}-small {
87
+ &-avatar-square.#{$module}-default,
88
+ &-avatar-square.#{$module}-small {
80
89
  .#{$prefix}-avatar {
81
90
  width: $height-tag_small;
82
91
  height: $height-tag_small;
@@ -179,4 +188,10 @@ $types: "ghost", "solid", "light";
179
188
  color: $color-tag_avatar-text-default;
180
189
  }
181
190
 
182
- @import "./rtl.scss";
191
+ .#{$module}-solid {
192
+ .#{$module}-close {
193
+ color: $color-tag_close-icon_deep-default;
194
+ }
195
+ }
196
+
197
+ @import './rtl.scss';
@@ -7,12 +7,16 @@ $color-tag_white-border-default: rgba(var(--semi-grey-2), 0.7); // 白色标签
7
7
  $color-tag_white-text-default: var(--semi-color-text-0); // 白色标签文字颜色 - 默认
8
8
  $color-tag_white-icon-default: var(--semi-color-text-2); // 白色标签图标颜色 - 默认
9
9
 
10
+ $color-tag-outline-focus: var(--semi-color-primary-light-active); // 标签轮廓 - 聚焦
11
+
10
12
  $width-tag_avatar_circle_small: 16px; // 头像标签圆角 - 小尺寸
11
13
  $width-tag_avatar_circle_large: 20px; // 头像标签圆角 - 大尺寸
12
14
 
13
15
  $width-tag-border: 1px; // 标签描边宽度
14
16
  $width-tag_avatar-border: $width-tag-border; // 头像标签描边宽度
15
17
 
18
+ $width-tag-outline: 2px; // 标签轮廓宽度
19
+
16
20
  $height-tag_small: 20px; // 小尺寸标签高度
17
21
  $height-tag_large: 24px; // 大尺寸标签高度
18
22
  $radius-tag: var(--semi-border-radius-small); // 标签圆角大小
@@ -24,6 +28,7 @@ $spacing-tag_large-paddingY: 4px; // 大尺寸标签垂直方向内边距
24
28
  $spacing-tag_large-paddingX: $spacing-tight; // 大尺寸标签水平方向内边距
25
29
 
26
30
  $color-tag_close-icon-default: var(--semi-color-text-2); // 可删除的标签删除按钮颜色
31
+ $color-tag_close-icon_deep-default: var(--semi-color-white); // 深色模式下可删除的标签删除按钮颜色
27
32
  $spacing-tag_close-paddingLeft: $spacing-extra-tight; // 可删除的标签删除按钮左侧内边距
28
33
  $spacing-tag_closable-paddingTop: $spacing-extra-tight; // 可删除的标签删除按钮顶部内边距
29
34
  $spacing-tag_closable-paddingRight: $spacing-extra-tight; // 可删除的标签删除按钮右侧内边距
@@ -0,0 +1 @@
1
+ export declare function handlePrevent(event: any): void;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+
5
+ _Object$defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+
9
+ exports.handlePrevent = handlePrevent;
10
+
11
+ function handlePrevent(event) {
12
+ event.stopPropagation();
13
+ event.preventDefault();
14
+ }
@@ -296,7 +296,11 @@ class InputNumberFoundation extends BaseFoundation {
296
296
  }
297
297
 
298
298
  handleUpClick(event) {
299
- if (!this._isMouseButtonLeft(event)) {
299
+ const {
300
+ readonly
301
+ } = this.getProps();
302
+
303
+ if (!this._isMouseButtonLeft(event) || readonly) {
300
304
  return;
301
305
  }
302
306
 
@@ -319,7 +323,11 @@ class InputNumberFoundation extends BaseFoundation {
319
323
  }
320
324
 
321
325
  handleDownClick(event) {
322
- if (!this._isMouseButtonLeft(event)) {
326
+ const {
327
+ readonly
328
+ } = this.getProps();
329
+
330
+ if (!this._isMouseButtonLeft(event) || readonly) {
323
331
  return;
324
332
  }
325
333
 
@@ -19,5 +19,10 @@ declare class TabsFoundation<P = Record<string, any>, S = Record<string, any>> e
19
19
  handleTabListChange(): void;
20
20
  handleTabPanesChange(): void;
21
21
  handleTabDelete(tabKey: string): void;
22
+ handlePrevent: (event: any) => void;
23
+ handleKeyDown: (event: any, itemKey: string, closable: boolean) => void;
24
+ determineOrientation(event: any, tabs: HTMLElement[]): void;
25
+ handleDeleteKeyDown(event: any, tabs: HTMLElement[], itemKey: string, closable: boolean): void;
26
+ switchTabOnArrowPress(event: any, tabs: HTMLElement[]): void;
22
27
  }
23
28
  export default TabsFoundation;
@@ -1,11 +1,62 @@
1
1
  import _noop from "lodash/noop";
2
+ import _get from "lodash/get";
2
3
  import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
4
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
5
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
6
+ import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
3
7
  import BaseFoundation from '../base/foundation';
4
8
 
5
9
  class TabsFoundation extends BaseFoundation {
6
10
  constructor(adapter) {
7
11
  super(_Object$assign({}, adapter));
8
12
  this.destroy = _noop;
13
+
14
+ this.handlePrevent = event => {
15
+ event.stopPropagation();
16
+ event.preventDefault();
17
+ };
18
+
19
+ this.handleKeyDown = (event, itemKey, closable) => {
20
+ var _context;
21
+
22
+ const tabs = _filterInstanceProperty(_context = [...event.target.parentNode.childNodes]).call(_context, item => {
23
+ var _context2;
24
+
25
+ return _includesInstanceProperty(_context2 = _get(item, 'attributes.data-tabkey.value', '')).call(_context2, 'semiTab') && item.ariaDisabled !== "true";
26
+ });
27
+
28
+ switch (event.key) {
29
+ case "ArrowLeft":
30
+ case "ArrowRight":
31
+ case "ArrowUp":
32
+ case "ArrowDown":
33
+ this.determineOrientation(event, tabs);
34
+ break;
35
+
36
+ case "Backspace":
37
+ case "Delete":
38
+ this.handleDeleteKeyDown(event, tabs, itemKey, closable);
39
+ break;
40
+
41
+ case "Enter":
42
+ case " ":
43
+ this.handleTabClick(itemKey, event);
44
+ this.handlePrevent(event);
45
+ break;
46
+
47
+ case "Home":
48
+ tabs[0].focus(); // focus first tab
49
+
50
+ this.handlePrevent(event);
51
+ break;
52
+
53
+ case "End":
54
+ tabs[tabs.length - 1].focus(); // focus last tab
55
+
56
+ this.handlePrevent(event);
57
+ break;
58
+ }
59
+ };
9
60
  }
10
61
 
11
62
  init() {
@@ -75,6 +126,62 @@ class TabsFoundation extends BaseFoundation {
75
126
  this._adapter.notifyTabDelete(tabKey);
76
127
  }
77
128
 
129
+ determineOrientation(event, tabs) {
130
+ const {
131
+ tabPosition
132
+ } = this.getProps();
133
+ const isVertical = tabPosition === 'left';
134
+
135
+ if (isVertical) {
136
+ if (event.key === "ArrowUp" || event.key === "ArrowDown") {
137
+ this.switchTabOnArrowPress(event, tabs);
138
+ this.handlePrevent(event);
139
+ }
140
+ } else {
141
+ if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
142
+ this.switchTabOnArrowPress(event, tabs);
143
+ this.handlePrevent(event);
144
+ }
145
+ }
146
+ }
147
+
148
+ handleDeleteKeyDown(event, tabs, itemKey, closable) {
149
+ if (closable) {
150
+ this.handleTabDelete(itemKey);
151
+
152
+ const index = _indexOfInstanceProperty(tabs).call(tabs, event.target); // Move focus to next element after deletion
153
+ // If the element is the last removable tab, focus to its previous tab
154
+
155
+
156
+ if (tabs.length !== 1) {
157
+ tabs[index + 1 >= tabs.length ? index - 1 : index + 1].focus();
158
+ }
159
+ }
160
+ }
161
+
162
+ switchTabOnArrowPress(event, tabs) {
163
+ const index = _indexOfInstanceProperty(tabs).call(tabs, event.target);
164
+
165
+ const direction = {
166
+ "ArrowLeft": -1,
167
+ "ArrowUp": -1,
168
+ "ArrowRight": 1,
169
+ "ArrowDown": 1
170
+ };
171
+
172
+ if (direction[event.key]) {
173
+ if (index !== undefined) {
174
+ if (tabs[index + direction[event.key]]) {
175
+ tabs[index + direction[event.key]].focus();
176
+ } else if (event.key === "ArrowLeft" || event.key === "ArrowUp") {
177
+ tabs[tabs.length - 1].focus(); // focus last tab
178
+ } else if (event.key === "ArrowRight" || event.key == "ArrowDown") {
179
+ tabs[0].focus(); // focus first tab
180
+ }
181
+ }
182
+ }
183
+ }
184
+
78
185
  }
79
186
 
80
187
  export default TabsFoundation;
@@ -101,6 +101,10 @@
101
101
  width: 0;
102
102
  height: 0;
103
103
  }
104
+ .semi-tabs-bar-collapse .semi-overflow-list .semi-overflow-list-scroll-wrapper:focus-visible {
105
+ outline: 2px solid var(--semi-color-primary-light-active);
106
+ outline-offset: -2px;
107
+ }
104
108
  .semi-tabs-bar-collapse .semi-tabs-bar-arrow-start {
105
109
  margin-right: 4px;
106
110
  }
@@ -130,6 +134,10 @@
130
134
  .semi-tabs-bar-line.semi-tabs-bar-top .semi-tabs-tab:hover {
131
135
  border-bottom: 2px solid var(--semi-color-fill-0);
132
136
  }
137
+ .semi-tabs-bar-line.semi-tabs-bar-top .semi-tabs-tab:focus-visible {
138
+ outline: 2px solid var(--semi-color-primary-light-active);
139
+ outline-offset: -1px;
140
+ }
133
141
  .semi-tabs-bar-line.semi-tabs-bar-top .semi-tabs-tab:active {
134
142
  border-bottom: 2px solid var(--semi-color-fill-1);
135
143
  }
@@ -156,6 +164,10 @@
156
164
  border-left: 2px solid var(--semi-color-fill-0);
157
165
  background-color: var(--semi-color-fill-0);
158
166
  }
167
+ .semi-tabs-bar-line.semi-tabs-bar-left .semi-tabs-tab:focus-visible {
168
+ outline: 2px solid var(--semi-color-primary-light-active);
169
+ outline-offset: -2px;
170
+ }
159
171
  .semi-tabs-bar-line.semi-tabs-bar-left .semi-tabs-tab:active {
160
172
  border-left: 2px solid var(--semi-color-fill-1);
161
173
  background-color: var(--semi-color-fill-1);
@@ -241,6 +253,10 @@
241
253
  .semi-tabs-bar-card .semi-tabs-tab:hover {
242
254
  background: var(--semi-color-fill-0);
243
255
  }
256
+ .semi-tabs-bar-card .semi-tabs-tab:focus-visible {
257
+ outline: 2px solid var(--semi-color-primary-light-active);
258
+ outline-offset: -2px;
259
+ }
244
260
  .semi-tabs-bar-card .semi-tabs-tab:active {
245
261
  background: var(--semi-color-fill-1);
246
262
  }
@@ -263,6 +279,10 @@
263
279
  border: none;
264
280
  background-color: var(--semi-color-fill-0);
265
281
  }
282
+ .semi-tabs-bar-button .semi-tabs-tab:focus-visible {
283
+ outline: 2px solid var(--semi-color-primary-light-active);
284
+ outline-offset: -2px;
285
+ }
266
286
  .semi-tabs-bar-button .semi-tabs-tab:active {
267
287
  background-color: var(--semi-color-fill-1);
268
288
  }
@@ -283,6 +303,9 @@
283
303
  width: 100%;
284
304
  overflow: hidden;
285
305
  }
306
+ .semi-tabs-pane:focus-visible {
307
+ outline: 2px solid var(--semi-color-primary-light-active);
308
+ }
286
309
  .semi-tabs-pane-inactive, .semi-tabs-content-no-animated .semi-tabs-pane-inactive {
287
310
  display: none;
288
311
  }
@@ -124,6 +124,11 @@ $module: #{$prefix}-tabs;
124
124
  width: 0;
125
125
  height: 0;
126
126
  }
127
+
128
+ &:focus-visible {
129
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
130
+ outline-offset: $width-tabs-outline-offset;
131
+ }
127
132
  }
128
133
  }
129
134
 
@@ -164,6 +169,11 @@ $module: #{$prefix}-tabs;
164
169
  &:hover {
165
170
  border-bottom: $width-tabs_bar_line_tab-border solid $color-tabs_tab_line_default-border-hover;
166
171
  }
172
+
173
+ &:focus-visible {
174
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
175
+ outline-offset: $width-tabs_bar_line-outline-offset;
176
+ }
167
177
 
168
178
  &:active {
169
179
  border-bottom: $width-tabs_bar_line_tab-border solid $color-tabs_tab_line_default-border-active;
@@ -202,6 +212,11 @@ $module: #{$prefix}-tabs;
202
212
  border-left: $width-tabs_bar_line_tab-border solid $color-tabs_tab_line_default-border-hover;
203
213
  background-color: $color-tabs_tab_line_vertical-bg-hover;
204
214
  }
215
+
216
+ &:focus-visible {
217
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
218
+ outline-offset: $width-tabs-outline-offset;
219
+ }
205
220
 
206
221
  &:active {
207
222
  border-left: $width-tabs_bar_line_tab-border solid $color-tabs_tab_line_default-border-active;
@@ -327,6 +342,11 @@ $module: #{$prefix}-tabs;
327
342
  &:hover {
328
343
  background: $color-tabs_tab_card-bg-hover;
329
344
  }
345
+
346
+ &:focus-visible {
347
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
348
+ outline-offset: $width-tabs-outline-offset;
349
+ }
330
350
 
331
351
  &:active {
332
352
  background: $color-tabs_tab_card-bg-active;
@@ -365,6 +385,11 @@ $module: #{$prefix}-tabs;
365
385
  border: none;
366
386
  background-color: $color-tabs_tab_button-bg-hover;
367
387
  }
388
+
389
+ &:focus-visible {
390
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
391
+ outline-offset: $width-tabs-outline-offset;
392
+ }
368
393
 
369
394
  &:active {
370
395
  background-color: $color-tabs_tab_button-bg-active;
@@ -393,13 +418,17 @@ $module: #{$prefix}-tabs;
393
418
  height: 100%;
394
419
  padding: $spacing-tabs_content_left-paddingY $spacing-tabs_content_left-paddingX;
395
420
  }
396
-
421
+
397
422
  &-pane {
398
423
  width: 100%;
399
424
  overflow: hidden;
400
425
  // position: absolute;
401
426
  // flex-shrink: 0;
402
427
  // position: absolute;
428
+
429
+ &:focus-visible {
430
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
431
+ }
403
432
  }
404
433
 
405
434
  &-pane-inactive,
@@ -44,6 +44,8 @@ $color-tabs_tab-icon-hover: var(--semi-color-text-0); // 页签图标颜色 -
44
44
  $color-tabs_tab-icon-active: var(--semi-color-text-0); // 页签图标颜色 - 按下
45
45
  $color-tabs_tab_selected-icon-default: var(--semi-color-primary); // 页签图标颜色 - 选中
46
46
 
47
+ $color-tabs_tab-outline-focus: var(--semi-color-primary-light-active); // 页签轮廓 - 聚焦
48
+
47
49
 
48
50
  $font-tabs_tab-fontWeight: $font-weight-regular; // 页签文本字重 - 默认
49
51
  $font-tabs_tab_active-fontWeight: $font-weight-bold; // 页签文本字重 - 选中
@@ -54,6 +56,9 @@ $width-tabs_bar_line-border: $border-thickness-control; // 线条式页签底部
54
56
  $width-tabs_bar_line_tab-border: 2px; // 页签标示线宽度
55
57
 
56
58
  $width-tabs_bar_card-border: $border-thickness-control; // 卡片式页签底部分割线宽度
59
+ $width-tabs-outline: 2px; // 聚焦轮廓宽度
60
+ $width-tabs-outline-offset: -2px; // 聚焦轮廓偏移宽度
61
+ $width-tabs_bar_line-outline-offset: -1px; // 线条式页签聚焦轮廓偏移宽度
57
62
 
58
63
  $height-tabs_bar_extra_large: 50px; // 大尺寸页签高度
59
64
  $font-tabs_bar_extra_large-lineHeight: $height-tabs_bar_extra_large; // 大尺寸页签文字行高
@@ -19,6 +19,9 @@
19
19
  height: 20px;
20
20
  padding: 2px 8px;
21
21
  }
22
+ .semi-tag-default:focus-visible, .semi-tag-small:focus-visible {
23
+ outline: 2px solid var(--semi-color-primary-light-active);
24
+ }
22
25
  .semi-tag-large {
23
26
  font-size: 12px;
24
27
  line-height: 16px;
@@ -26,6 +29,9 @@
26
29
  padding: 4px 8px;
27
30
  height: 24px;
28
31
  }
32
+ .semi-tag-large:focus-visible {
33
+ outline: 2px solid var(--semi-color-primary-light-active);
34
+ }
29
35
  .semi-tag-invisible {
30
36
  display: none;
31
37
  }
@@ -392,6 +398,10 @@
392
398
  color: var(--semi-color-text-0);
393
399
  }
394
400
 
401
+ .semi-tag-solid .semi-tag-close {
402
+ color: var(--semi-color-white);
403
+ }
404
+
395
405
  .semi-rtl .semi-tag,
396
406
  .semi-portal-rtl .semi-tag {
397
407
  direction: rtl;
@@ -25,12 +25,18 @@ $types: "ghost", "solid", "light";
25
25
  @include font-size-small;
26
26
  height: $height-tag_small;
27
27
  padding: $spacing-tag_small-paddingY $spacing-tag_small-paddingX;
28
+ &:focus-visible {
29
+ outline: $width-tag-outline solid $color-tag-outline-focus;
30
+ }
28
31
  }
29
32
 
30
33
  &-large {
31
34
  @include font-size-small;
32
35
  padding: $spacing-tag_large-paddingY $spacing-tag_large-paddingX;
33
36
  height: $height-tag_large;
37
+ &:focus-visible {
38
+ outline: $width-tag-outline solid $color-tag-outline-focus;
39
+ }
34
40
  }
35
41
 
36
42
  &-invisible {
@@ -46,12 +52,13 @@ $types: "ghost", "solid", "light";
46
52
  &-close {
47
53
  @include all-center;
48
54
  color: $color-tag_close-icon-default;
49
- padding-left: $spacing-tag_close-paddingLeft;
55
+ padding-left: $spacing-tag_close-paddingLeft;
50
56
  cursor: pointer;
51
57
  }
52
58
 
53
59
  &-closable {
54
- padding: $spacing-tag_closable-paddingTop $spacing-tag_closable-paddingRight $spacing-tag_closable-paddingBottom $spacing-tag_closable-paddingLeft;
60
+ padding: $spacing-tag_closable-paddingTop $spacing-tag_closable-paddingRight $spacing-tag_closable-paddingBottom
61
+ $spacing-tag_closable-paddingLeft;
55
62
  }
56
63
 
57
64
  &-avatar-square,
@@ -62,10 +69,10 @@ $types: "ghost", "solid", "light";
62
69
  }
63
70
 
64
71
  &-avatar-square {
65
- padding: $spacing-tag_avatar_square-paddingTop $spacing-tag_avatar_square-paddingRight $spacing-tag_avatar_square-paddingBottom $spacing-tag_avatar_square-paddingLeft;
72
+ padding: $spacing-tag_avatar_square-paddingTop $spacing-tag_avatar_square-paddingRight
73
+ $spacing-tag_avatar_square-paddingBottom $spacing-tag_avatar_square-paddingLeft;
66
74
 
67
75
  .#{$prefix}-avatar {
68
-
69
76
  & > img {
70
77
  background-color: $color-tag_avatar_square_img-bg-default;
71
78
  }
@@ -73,10 +80,12 @@ $types: "ghost", "solid", "light";
73
80
  }
74
81
 
75
82
  &-avatar-circle {
76
- padding: $spacing-tag_avatar_circle-paddingTop $spacing-tag_avatar_circle-paddingRight $spacing-tag_avatar_circle-paddingBottom $spacing-tag_avatar_circle-paddingLeft;
83
+ padding: $spacing-tag_avatar_circle-paddingTop $spacing-tag_avatar_circle-paddingRight
84
+ $spacing-tag_avatar_circle-paddingBottom $spacing-tag_avatar_circle-paddingLeft;
77
85
  }
78
86
 
79
- &-avatar-square.#{$module}-default, &-avatar-square.#{$module}-small {
87
+ &-avatar-square.#{$module}-default,
88
+ &-avatar-square.#{$module}-small {
80
89
  .#{$prefix}-avatar {
81
90
  width: $height-tag_small;
82
91
  height: $height-tag_small;
@@ -179,4 +188,10 @@ $types: "ghost", "solid", "light";
179
188
  color: $color-tag_avatar-text-default;
180
189
  }
181
190
 
182
- @import "./rtl.scss";
191
+ .#{$module}-solid {
192
+ .#{$module}-close {
193
+ color: $color-tag_close-icon_deep-default;
194
+ }
195
+ }
196
+
197
+ @import './rtl.scss';
@@ -7,12 +7,16 @@ $color-tag_white-border-default: rgba(var(--semi-grey-2), 0.7); // 白色标签
7
7
  $color-tag_white-text-default: var(--semi-color-text-0); // 白色标签文字颜色 - 默认
8
8
  $color-tag_white-icon-default: var(--semi-color-text-2); // 白色标签图标颜色 - 默认
9
9
 
10
+ $color-tag-outline-focus: var(--semi-color-primary-light-active); // 标签轮廓 - 聚焦
11
+
10
12
  $width-tag_avatar_circle_small: 16px; // 头像标签圆角 - 小尺寸
11
13
  $width-tag_avatar_circle_large: 20px; // 头像标签圆角 - 大尺寸
12
14
 
13
15
  $width-tag-border: 1px; // 标签描边宽度
14
16
  $width-tag_avatar-border: $width-tag-border; // 头像标签描边宽度
15
17
 
18
+ $width-tag-outline: 2px; // 标签轮廓宽度
19
+
16
20
  $height-tag_small: 20px; // 小尺寸标签高度
17
21
  $height-tag_large: 24px; // 大尺寸标签高度
18
22
  $radius-tag: var(--semi-border-radius-small); // 标签圆角大小
@@ -24,6 +28,7 @@ $spacing-tag_large-paddingY: 4px; // 大尺寸标签垂直方向内边距
24
28
  $spacing-tag_large-paddingX: $spacing-tight; // 大尺寸标签水平方向内边距
25
29
 
26
30
  $color-tag_close-icon-default: var(--semi-color-text-2); // 可删除的标签删除按钮颜色
31
+ $color-tag_close-icon_deep-default: var(--semi-color-white); // 深色模式下可删除的标签删除按钮颜色
27
32
  $spacing-tag_close-paddingLeft: $spacing-extra-tight; // 可删除的标签删除按钮左侧内边距
28
33
  $spacing-tag_closable-paddingTop: $spacing-extra-tight; // 可删除的标签删除按钮顶部内边距
29
34
  $spacing-tag_closable-paddingRight: $spacing-extra-tight; // 可删除的标签删除按钮右侧内边距
@@ -0,0 +1 @@
1
+ export declare function handlePrevent(event: any): void;
@@ -0,0 +1,4 @@
1
+ export function handlePrevent(event) {
2
+ event.stopPropagation();
3
+ event.preventDefault();
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.11.0",
3
+ "version": "2.12.0-alpha.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@babel/runtime-corejs3": "^7.15.4",
11
- "@douyinfe/semi-animation": "2.11.0",
11
+ "@douyinfe/semi-animation": "^2.12.0-alpha.0",
12
12
  "async-validator": "^3.5.0",
13
13
  "classnames": "^2.2.6",
14
14
  "date-fns": "^2.9.0",
@@ -24,7 +24,7 @@
24
24
  "*.scss",
25
25
  "*.css"
26
26
  ],
27
- "gitHead": "f7a5cae3d9190faff4a08c5a4da23927a1ab86e5",
27
+ "gitHead": "2a4f34115b9dd03fc3c40b1edcc421bf64a3024b",
28
28
  "devDependencies": {
29
29
  "@babel/plugin-proposal-decorators": "^7.15.8",
30
30
  "@babel/plugin-transform-runtime": "^7.15.8",
@@ -1,5 +1,5 @@
1
1
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
2
- import { noop } from 'lodash';
2
+ import { get, noop } from 'lodash';
3
3
 
4
4
  export interface TabsAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
5
5
  collectPane: () => void;
@@ -72,6 +72,95 @@ class TabsFoundation<P = Record<string, any>, S = Record<string, any>> extends B
72
72
  handleTabDelete(tabKey: string): void {
73
73
  this._adapter.notifyTabDelete(tabKey);
74
74
  }
75
+
76
+ handlePrevent = (event: any) => {
77
+ event.stopPropagation();
78
+ event.preventDefault();
79
+ }
80
+
81
+ handleKeyDown = (event: any, itemKey: string, closable: boolean) => {
82
+ const tabs = [...event.target.parentNode.childNodes].filter(item => {
83
+ return get(item, 'attributes.data-tabkey.value', '').includes('semiTab') && item.ariaDisabled!=="true";
84
+ });
85
+
86
+ switch (event.key) {
87
+ case "ArrowLeft":
88
+ case "ArrowRight":
89
+ case "ArrowUp":
90
+ case "ArrowDown":
91
+ this.determineOrientation(event, tabs);
92
+ break;
93
+ case "Backspace":
94
+ case "Delete":
95
+ this.handleDeleteKeyDown(event, tabs, itemKey, closable);
96
+ break;
97
+ case "Enter":
98
+ case " ":
99
+ this.handleTabClick(itemKey, event);
100
+ this.handlePrevent(event);
101
+ break;
102
+ case "Home":
103
+ tabs[0].focus(); // focus first tab
104
+ this.handlePrevent(event);
105
+ break;
106
+ case "End":
107
+ tabs[tabs.length - 1].focus(); // focus last tab
108
+ this.handlePrevent(event);
109
+ break;
110
+ }
111
+ }
112
+
113
+ determineOrientation(event: any, tabs: HTMLElement[]): void {
114
+ const { tabPosition } = this.getProps();
115
+ const isVertical = tabPosition === 'left';
116
+
117
+ if (isVertical) {
118
+ if (event.key === "ArrowUp" || event.key === "ArrowDown") {
119
+ this.switchTabOnArrowPress(event, tabs);
120
+ this.handlePrevent(event);
121
+ }
122
+ } else {
123
+ if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
124
+ this.switchTabOnArrowPress(event, tabs);
125
+ this.handlePrevent(event);
126
+ }
127
+ }
128
+ }
129
+
130
+ handleDeleteKeyDown(event:any, tabs: HTMLElement[], itemKey: string, closable: boolean): void {
131
+ if (closable) {
132
+ this.handleTabDelete(itemKey);
133
+ const index = tabs.indexOf(event.target);
134
+ // Move focus to next element after deletion
135
+ // If the element is the last removable tab, focus to its previous tab
136
+ if (tabs.length !== 1 ){
137
+ tabs[index + 1 >= tabs.length ? index - 1 : index + 1].focus();
138
+ }
139
+ }
140
+ }
141
+
142
+ switchTabOnArrowPress(event: any, tabs: HTMLElement[]): void {
143
+ const index = tabs.indexOf(event.target);
144
+
145
+ const direction = {
146
+ "ArrowLeft": -1,
147
+ "ArrowUp": -1,
148
+ "ArrowRight": 1,
149
+ "ArrowDown": 1,
150
+ };
151
+
152
+ if (direction[event.key]) {
153
+ if (index !== undefined) {
154
+ if (tabs[index + direction[event.key]]) {
155
+ tabs[index+ direction[event.key]].focus();
156
+ } else if (event.key === "ArrowLeft" || event.key === "ArrowUp") {
157
+ tabs[tabs.length - 1].focus(); // focus last tab
158
+ } else if (event.key === "ArrowRight" || event.key == "ArrowDown") {
159
+ tabs[0].focus(); // focus first tab
160
+ }
161
+ }
162
+ }
163
+ }
75
164
  }
76
165
 
77
166
  export default TabsFoundation;
package/tabs/tabs.scss CHANGED
@@ -124,6 +124,11 @@ $module: #{$prefix}-tabs;
124
124
  width: 0;
125
125
  height: 0;
126
126
  }
127
+
128
+ &:focus-visible {
129
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
130
+ outline-offset: $width-tabs-outline-offset;
131
+ }
127
132
  }
128
133
  }
129
134
 
@@ -164,6 +169,11 @@ $module: #{$prefix}-tabs;
164
169
  &:hover {
165
170
  border-bottom: $width-tabs_bar_line_tab-border solid $color-tabs_tab_line_default-border-hover;
166
171
  }
172
+
173
+ &:focus-visible {
174
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
175
+ outline-offset: $width-tabs_bar_line-outline-offset;
176
+ }
167
177
 
168
178
  &:active {
169
179
  border-bottom: $width-tabs_bar_line_tab-border solid $color-tabs_tab_line_default-border-active;
@@ -202,6 +212,11 @@ $module: #{$prefix}-tabs;
202
212
  border-left: $width-tabs_bar_line_tab-border solid $color-tabs_tab_line_default-border-hover;
203
213
  background-color: $color-tabs_tab_line_vertical-bg-hover;
204
214
  }
215
+
216
+ &:focus-visible {
217
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
218
+ outline-offset: $width-tabs-outline-offset;
219
+ }
205
220
 
206
221
  &:active {
207
222
  border-left: $width-tabs_bar_line_tab-border solid $color-tabs_tab_line_default-border-active;
@@ -327,6 +342,11 @@ $module: #{$prefix}-tabs;
327
342
  &:hover {
328
343
  background: $color-tabs_tab_card-bg-hover;
329
344
  }
345
+
346
+ &:focus-visible {
347
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
348
+ outline-offset: $width-tabs-outline-offset;
349
+ }
330
350
 
331
351
  &:active {
332
352
  background: $color-tabs_tab_card-bg-active;
@@ -365,6 +385,11 @@ $module: #{$prefix}-tabs;
365
385
  border: none;
366
386
  background-color: $color-tabs_tab_button-bg-hover;
367
387
  }
388
+
389
+ &:focus-visible {
390
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
391
+ outline-offset: $width-tabs-outline-offset;
392
+ }
368
393
 
369
394
  &:active {
370
395
  background-color: $color-tabs_tab_button-bg-active;
@@ -393,13 +418,17 @@ $module: #{$prefix}-tabs;
393
418
  height: 100%;
394
419
  padding: $spacing-tabs_content_left-paddingY $spacing-tabs_content_left-paddingX;
395
420
  }
396
-
421
+
397
422
  &-pane {
398
423
  width: 100%;
399
424
  overflow: hidden;
400
425
  // position: absolute;
401
426
  // flex-shrink: 0;
402
427
  // position: absolute;
428
+
429
+ &:focus-visible {
430
+ outline: $width-tabs-outline solid $color-tabs_tab-outline-focus;
431
+ }
403
432
  }
404
433
 
405
434
  &-pane-inactive,
@@ -44,6 +44,8 @@ $color-tabs_tab-icon-hover: var(--semi-color-text-0); // 页签图标颜色 -
44
44
  $color-tabs_tab-icon-active: var(--semi-color-text-0); // 页签图标颜色 - 按下
45
45
  $color-tabs_tab_selected-icon-default: var(--semi-color-primary); // 页签图标颜色 - 选中
46
46
 
47
+ $color-tabs_tab-outline-focus: var(--semi-color-primary-light-active); // 页签轮廓 - 聚焦
48
+
47
49
 
48
50
  $font-tabs_tab-fontWeight: $font-weight-regular; // 页签文本字重 - 默认
49
51
  $font-tabs_tab_active-fontWeight: $font-weight-bold; // 页签文本字重 - 选中
@@ -54,6 +56,9 @@ $width-tabs_bar_line-border: $border-thickness-control; // 线条式页签底部
54
56
  $width-tabs_bar_line_tab-border: 2px; // 页签标示线宽度
55
57
 
56
58
  $width-tabs_bar_card-border: $border-thickness-control; // 卡片式页签底部分割线宽度
59
+ $width-tabs-outline: 2px; // 聚焦轮廓宽度
60
+ $width-tabs-outline-offset: -2px; // 聚焦轮廓偏移宽度
61
+ $width-tabs_bar_line-outline-offset: -1px; // 线条式页签聚焦轮廓偏移宽度
57
62
 
58
63
  $height-tabs_bar_extra_large: 50px; // 大尺寸页签高度
59
64
  $font-tabs_bar_extra_large-lineHeight: $height-tabs_bar_extra_large; // 大尺寸页签文字行高
package/tag/tag.scss CHANGED
@@ -25,12 +25,18 @@ $types: "ghost", "solid", "light";
25
25
  @include font-size-small;
26
26
  height: $height-tag_small;
27
27
  padding: $spacing-tag_small-paddingY $spacing-tag_small-paddingX;
28
+ &:focus-visible {
29
+ outline: $width-tag-outline solid $color-tag-outline-focus;
30
+ }
28
31
  }
29
32
 
30
33
  &-large {
31
34
  @include font-size-small;
32
35
  padding: $spacing-tag_large-paddingY $spacing-tag_large-paddingX;
33
36
  height: $height-tag_large;
37
+ &:focus-visible {
38
+ outline: $width-tag-outline solid $color-tag-outline-focus;
39
+ }
34
40
  }
35
41
 
36
42
  &-invisible {
@@ -46,12 +52,13 @@ $types: "ghost", "solid", "light";
46
52
  &-close {
47
53
  @include all-center;
48
54
  color: $color-tag_close-icon-default;
49
- padding-left: $spacing-tag_close-paddingLeft;
55
+ padding-left: $spacing-tag_close-paddingLeft;
50
56
  cursor: pointer;
51
57
  }
52
58
 
53
59
  &-closable {
54
- padding: $spacing-tag_closable-paddingTop $spacing-tag_closable-paddingRight $spacing-tag_closable-paddingBottom $spacing-tag_closable-paddingLeft;
60
+ padding: $spacing-tag_closable-paddingTop $spacing-tag_closable-paddingRight $spacing-tag_closable-paddingBottom
61
+ $spacing-tag_closable-paddingLeft;
55
62
  }
56
63
 
57
64
  &-avatar-square,
@@ -62,10 +69,10 @@ $types: "ghost", "solid", "light";
62
69
  }
63
70
 
64
71
  &-avatar-square {
65
- padding: $spacing-tag_avatar_square-paddingTop $spacing-tag_avatar_square-paddingRight $spacing-tag_avatar_square-paddingBottom $spacing-tag_avatar_square-paddingLeft;
72
+ padding: $spacing-tag_avatar_square-paddingTop $spacing-tag_avatar_square-paddingRight
73
+ $spacing-tag_avatar_square-paddingBottom $spacing-tag_avatar_square-paddingLeft;
66
74
 
67
75
  .#{$prefix}-avatar {
68
-
69
76
  & > img {
70
77
  background-color: $color-tag_avatar_square_img-bg-default;
71
78
  }
@@ -73,10 +80,12 @@ $types: "ghost", "solid", "light";
73
80
  }
74
81
 
75
82
  &-avatar-circle {
76
- padding: $spacing-tag_avatar_circle-paddingTop $spacing-tag_avatar_circle-paddingRight $spacing-tag_avatar_circle-paddingBottom $spacing-tag_avatar_circle-paddingLeft;
83
+ padding: $spacing-tag_avatar_circle-paddingTop $spacing-tag_avatar_circle-paddingRight
84
+ $spacing-tag_avatar_circle-paddingBottom $spacing-tag_avatar_circle-paddingLeft;
77
85
  }
78
86
 
79
- &-avatar-square.#{$module}-default, &-avatar-square.#{$module}-small {
87
+ &-avatar-square.#{$module}-default,
88
+ &-avatar-square.#{$module}-small {
80
89
  .#{$prefix}-avatar {
81
90
  width: $height-tag_small;
82
91
  height: $height-tag_small;
@@ -179,4 +188,10 @@ $types: "ghost", "solid", "light";
179
188
  color: $color-tag_avatar-text-default;
180
189
  }
181
190
 
182
- @import "./rtl.scss";
191
+ .#{$module}-solid {
192
+ .#{$module}-close {
193
+ color: $color-tag_close-icon_deep-default;
194
+ }
195
+ }
196
+
197
+ @import './rtl.scss';
@@ -7,12 +7,16 @@ $color-tag_white-border-default: rgba(var(--semi-grey-2), 0.7); // 白色标签
7
7
  $color-tag_white-text-default: var(--semi-color-text-0); // 白色标签文字颜色 - 默认
8
8
  $color-tag_white-icon-default: var(--semi-color-text-2); // 白色标签图标颜色 - 默认
9
9
 
10
+ $color-tag-outline-focus: var(--semi-color-primary-light-active); // 标签轮廓 - 聚焦
11
+
10
12
  $width-tag_avatar_circle_small: 16px; // 头像标签圆角 - 小尺寸
11
13
  $width-tag_avatar_circle_large: 20px; // 头像标签圆角 - 大尺寸
12
14
 
13
15
  $width-tag-border: 1px; // 标签描边宽度
14
16
  $width-tag_avatar-border: $width-tag-border; // 头像标签描边宽度
15
17
 
18
+ $width-tag-outline: 2px; // 标签轮廓宽度
19
+
16
20
  $height-tag_small: 20px; // 小尺寸标签高度
17
21
  $height-tag_large: 24px; // 大尺寸标签高度
18
22
  $radius-tag: var(--semi-border-radius-small); // 标签圆角大小
@@ -24,6 +28,7 @@ $spacing-tag_large-paddingY: 4px; // 大尺寸标签垂直方向内边距
24
28
  $spacing-tag_large-paddingX: $spacing-tight; // 大尺寸标签水平方向内边距
25
29
 
26
30
  $color-tag_close-icon-default: var(--semi-color-text-2); // 可删除的标签删除按钮颜色
31
+ $color-tag_close-icon_deep-default: var(--semi-color-white); // 深色模式下可删除的标签删除按钮颜色
27
32
  $spacing-tag_close-paddingLeft: $spacing-extra-tight; // 可删除的标签删除按钮左侧内边距
28
33
  $spacing-tag_closable-paddingTop: $spacing-extra-tight; // 可删除的标签删除按钮顶部内边距
29
34
  $spacing-tag_closable-paddingRight: $spacing-extra-tight; // 可删除的标签删除按钮右侧内边距
package/utils/a11y.ts ADDED
@@ -0,0 +1,4 @@
1
+ export function handlePrevent(event: any) {
2
+ event.stopPropagation();
3
+ event.preventDefault();
4
+ }