@douyinfe/semi-foundation 2.15.1 → 2.17.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.
- package/lib/cjs/slider/foundation.d.ts +9 -2
- package/lib/cjs/slider/foundation.js +195 -5
- package/lib/cjs/slider/slider.css +3 -0
- package/lib/cjs/slider/slider.scss +7 -5
- package/lib/cjs/slider/variables.scss +4 -4
- package/lib/cjs/tooltip/variables.scss +1 -1
- package/lib/cjs/treeSelect/treeSelect.css +2 -0
- package/lib/cjs/treeSelect/treeSelect.scss +2 -0
- package/lib/cjs/typography/typography.css +7 -0
- package/lib/cjs/typography/typography.scss +9 -1
- package/lib/es/slider/foundation.d.ts +9 -2
- package/lib/es/slider/foundation.js +192 -5
- package/lib/es/slider/slider.css +3 -0
- package/lib/es/slider/slider.scss +7 -5
- package/lib/es/slider/variables.scss +4 -4
- package/lib/es/tooltip/variables.scss +1 -1
- package/lib/es/treeSelect/treeSelect.css +2 -0
- package/lib/es/treeSelect/treeSelect.scss +2 -0
- package/lib/es/typography/typography.css +7 -0
- package/lib/es/typography/typography.scss +9 -1
- package/package.json +2 -2
- package/slider/foundation.ts +141 -9
- package/slider/slider.scss +7 -5
- package/slider/variables.scss +4 -4
- package/tooltip/variables.scss +1 -1
- package/treeSelect/treeSelect.scss +2 -0
- package/typography/typography.scss +9 -1
- package/utils/a11y.ts +2 -2
|
@@ -26,7 +26,7 @@ export interface SliderProps {
|
|
|
26
26
|
'aria-label'?: string;
|
|
27
27
|
'aria-labelledby'?: string;
|
|
28
28
|
'aria-valuetext'?: string;
|
|
29
|
-
getAriaValueText?: (value: number) => string;
|
|
29
|
+
getAriaValueText?: (value: number, index?: number) => string;
|
|
30
30
|
}
|
|
31
31
|
export interface SliderState {
|
|
32
32
|
currentValue: number | number[];
|
|
@@ -40,6 +40,8 @@ export interface SliderState {
|
|
|
40
40
|
clickValue: 0;
|
|
41
41
|
showBoundary: boolean;
|
|
42
42
|
isInRenderTree: boolean;
|
|
43
|
+
firstDotFocusVisible: boolean;
|
|
44
|
+
secondDotFocusVisible: boolean;
|
|
43
45
|
}
|
|
44
46
|
export interface SliderLengths {
|
|
45
47
|
sliderX: number;
|
|
@@ -53,7 +55,6 @@ export interface ScrollParentVal {
|
|
|
53
55
|
}
|
|
54
56
|
export interface OverallVars {
|
|
55
57
|
dragging: boolean[];
|
|
56
|
-
chooseMovePos: 'min' | 'max';
|
|
57
58
|
}
|
|
58
59
|
export interface SliderAdapter extends DefaultAdapter<SliderProps, SliderState> {
|
|
59
60
|
getSliderLengths: () => SliderLengths;
|
|
@@ -189,7 +190,13 @@ export default class SliderFoundation extends BaseFoundation<SliderAdapter> {
|
|
|
189
190
|
onHandleEnter: (pos: SliderState['focusPos']) => void;
|
|
190
191
|
onHandleLeave: () => void;
|
|
191
192
|
onHandleUp: (e: any) => boolean;
|
|
193
|
+
_handleValueDecreaseWithKeyBoard: (step: number, handler: 'min' | 'max') => number | any[];
|
|
194
|
+
_handleValueIncreaseWithKeyBoard: (step: number, handler: 'min' | 'max') => any;
|
|
195
|
+
_handleHomeKey: (handler: 'min' | 'max') => any;
|
|
196
|
+
_handleEndKey: (handler: 'min' | 'max') => any;
|
|
197
|
+
handleKeyDown: (event: any, handler: 'min' | 'max') => void;
|
|
192
198
|
onFocus: (e: any, handler: 'min' | 'max') => void;
|
|
199
|
+
onBlur: (e: any, handler: 'min' | 'max') => void;
|
|
193
200
|
handleWrapClick: (e: any) => void;
|
|
194
201
|
/**
|
|
195
202
|
* Move the slider to the current click position
|
|
@@ -14,10 +14,16 @@ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
|
|
|
14
14
|
|
|
15
15
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
16
16
|
|
|
17
|
+
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
18
|
+
|
|
17
19
|
var _foundation = _interopRequireDefault(require("../base/foundation"));
|
|
18
20
|
|
|
19
21
|
var _touchPolyfill = _interopRequireDefault(require("../utils/touchPolyfill"));
|
|
20
22
|
|
|
23
|
+
var _warning = _interopRequireDefault(require("../utils/warning"));
|
|
24
|
+
|
|
25
|
+
var _a11y = require("../utils/a11y");
|
|
26
|
+
|
|
21
27
|
/* eslint-disable no-param-reassign */
|
|
22
28
|
|
|
23
29
|
/* eslint-disable max-len */
|
|
@@ -547,8 +553,7 @@ class SliderFoundation extends _foundation.default {
|
|
|
547
553
|
const handleMaxDom = this._adapter.getMaxHandleEl().current;
|
|
548
554
|
|
|
549
555
|
if (e.target === handleMinDom || e.target === handleMaxDom) {
|
|
550
|
-
|
|
551
|
-
e.stopPropagation();
|
|
556
|
+
(0, _a11y.handlePrevent)(e);
|
|
552
557
|
const touch = (0, _touchPolyfill.default)(e.touches[0], e);
|
|
553
558
|
this.onHandleDown(touch, handler);
|
|
554
559
|
}
|
|
@@ -612,18 +617,203 @@ class SliderFoundation extends _foundation.default {
|
|
|
612
617
|
this._adapter.setDragging([dragging[0], false]);
|
|
613
618
|
}
|
|
614
619
|
|
|
615
|
-
this._adapter.setStateVal('isDrag', false);
|
|
616
|
-
|
|
620
|
+
this._adapter.setStateVal('isDrag', false);
|
|
617
621
|
|
|
618
622
|
this._adapter.onHandleLeave();
|
|
619
623
|
|
|
620
624
|
this._adapter.onHandleUpAfter();
|
|
621
625
|
|
|
622
626
|
return true;
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
this._handleValueDecreaseWithKeyBoard = (step, handler) => {
|
|
630
|
+
const {
|
|
631
|
+
min,
|
|
632
|
+
currentValue
|
|
633
|
+
} = this.getStates();
|
|
634
|
+
const {
|
|
635
|
+
range
|
|
636
|
+
} = this.getProps();
|
|
637
|
+
|
|
638
|
+
if (handler === 'min') {
|
|
639
|
+
if (range) {
|
|
640
|
+
let newMinValue = currentValue[0] - step;
|
|
641
|
+
newMinValue = newMinValue < min ? min : newMinValue;
|
|
642
|
+
return [newMinValue, currentValue[1]];
|
|
643
|
+
} else {
|
|
644
|
+
let newMinValue = currentValue - step;
|
|
645
|
+
newMinValue = newMinValue < min ? min : newMinValue;
|
|
646
|
+
return newMinValue;
|
|
647
|
+
}
|
|
648
|
+
} else {
|
|
649
|
+
let newMaxValue = currentValue[1] - step;
|
|
650
|
+
newMaxValue = newMaxValue < currentValue[0] ? currentValue[0] : newMaxValue;
|
|
651
|
+
return [currentValue[0], newMaxValue];
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
this._handleValueIncreaseWithKeyBoard = (step, handler) => {
|
|
656
|
+
const {
|
|
657
|
+
max,
|
|
658
|
+
currentValue
|
|
659
|
+
} = this.getStates();
|
|
660
|
+
const {
|
|
661
|
+
range
|
|
662
|
+
} = this.getProps();
|
|
663
|
+
|
|
664
|
+
if (handler === 'min') {
|
|
665
|
+
if (range) {
|
|
666
|
+
let newMinValue = currentValue[0] + step;
|
|
667
|
+
newMinValue = newMinValue > currentValue[1] ? currentValue[1] : newMinValue;
|
|
668
|
+
return [newMinValue, currentValue[1]];
|
|
669
|
+
} else {
|
|
670
|
+
let newMinValue = currentValue + step;
|
|
671
|
+
newMinValue = newMinValue > max ? max : newMinValue;
|
|
672
|
+
return newMinValue;
|
|
673
|
+
}
|
|
674
|
+
} else {
|
|
675
|
+
let newMaxValue = currentValue[1] + step;
|
|
676
|
+
newMaxValue = newMaxValue > max ? max : newMaxValue;
|
|
677
|
+
return [currentValue[0], newMaxValue];
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
this._handleHomeKey = handler => {
|
|
682
|
+
const {
|
|
683
|
+
min,
|
|
684
|
+
currentValue
|
|
685
|
+
} = this.getStates();
|
|
686
|
+
const {
|
|
687
|
+
range
|
|
688
|
+
} = this.getProps();
|
|
689
|
+
|
|
690
|
+
if (handler === 'min') {
|
|
691
|
+
if (range) {
|
|
692
|
+
return [min, currentValue[1]];
|
|
693
|
+
} else {
|
|
694
|
+
return min;
|
|
695
|
+
}
|
|
696
|
+
} else {
|
|
697
|
+
return [currentValue[0], currentValue[0]];
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
this._handleEndKey = handler => {
|
|
702
|
+
const {
|
|
703
|
+
max,
|
|
704
|
+
currentValue
|
|
705
|
+
} = this.getStates();
|
|
706
|
+
const {
|
|
707
|
+
range
|
|
708
|
+
} = this.getProps();
|
|
709
|
+
|
|
710
|
+
if (handler === 'min') {
|
|
711
|
+
if (range) {
|
|
712
|
+
return [currentValue[1], currentValue[1]];
|
|
713
|
+
} else {
|
|
714
|
+
return max;
|
|
715
|
+
}
|
|
716
|
+
} else {
|
|
717
|
+
return [currentValue[0], max];
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
this.handleKeyDown = (event, handler) => {
|
|
722
|
+
var _context;
|
|
723
|
+
|
|
724
|
+
const {
|
|
725
|
+
min,
|
|
726
|
+
max,
|
|
727
|
+
currentValue
|
|
728
|
+
} = this.getStates();
|
|
729
|
+
const {
|
|
730
|
+
step,
|
|
731
|
+
range
|
|
732
|
+
} = this.getProps();
|
|
733
|
+
let outputValue;
|
|
734
|
+
|
|
735
|
+
switch (event.key) {
|
|
736
|
+
case "ArrowLeft":
|
|
737
|
+
case "ArrowDown":
|
|
738
|
+
outputValue = this._handleValueDecreaseWithKeyBoard(step, handler);
|
|
739
|
+
break;
|
|
740
|
+
|
|
741
|
+
case "ArrowRight":
|
|
742
|
+
case "ArrowUp":
|
|
743
|
+
outputValue = this._handleValueIncreaseWithKeyBoard(step, handler);
|
|
744
|
+
break;
|
|
745
|
+
|
|
746
|
+
case "PageUp":
|
|
747
|
+
outputValue = this._handleValueIncreaseWithKeyBoard(10 * step, handler);
|
|
748
|
+
break;
|
|
749
|
+
|
|
750
|
+
case "PageDown":
|
|
751
|
+
outputValue = this._handleValueDecreaseWithKeyBoard(10 * step, handler);
|
|
752
|
+
break;
|
|
753
|
+
|
|
754
|
+
case "Home":
|
|
755
|
+
outputValue = this._handleHomeKey(handler);
|
|
756
|
+
break;
|
|
757
|
+
|
|
758
|
+
case "End":
|
|
759
|
+
outputValue = this._handleEndKey(handler);
|
|
760
|
+
break;
|
|
761
|
+
|
|
762
|
+
case 'default':
|
|
763
|
+
break;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
if ((0, _includes.default)(_context = ["ArrowLeft", "ArrowDown", "ArrowRight", "ArrowUp", "PageUp", "PageDown", "Home", "End"]).call(_context, event.key)) {
|
|
767
|
+
let update = true;
|
|
768
|
+
|
|
769
|
+
if ((0, _isArray.default)(currentValue)) {
|
|
770
|
+
update = !(currentValue[0] === outputValue[0] && currentValue[1] === outputValue[1]);
|
|
771
|
+
} else {
|
|
772
|
+
update = currentValue !== outputValue;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
if (update) {
|
|
776
|
+
this._adapter.updateCurrentValue(outputValue);
|
|
777
|
+
|
|
778
|
+
this._adapter.notifyChange(outputValue);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
(0, _a11y.handlePrevent)(event);
|
|
782
|
+
}
|
|
623
783
|
}; // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
624
784
|
|
|
625
785
|
|
|
626
|
-
this.onFocus = (e, handler) => {
|
|
786
|
+
this.onFocus = (e, handler) => {
|
|
787
|
+
(0, _a11y.handlePrevent)(e);
|
|
788
|
+
const {
|
|
789
|
+
target
|
|
790
|
+
} = e;
|
|
791
|
+
|
|
792
|
+
try {
|
|
793
|
+
if (target.matches(':focus-visible')) {
|
|
794
|
+
if (handler === 'min') {
|
|
795
|
+
this._adapter.setStateVal('firstDotFocusVisible', true);
|
|
796
|
+
} else {
|
|
797
|
+
this._adapter.setStateVal('secondDotFocusVisible', true);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
} catch (error) {
|
|
801
|
+
(0, _warning.default)(true, 'Warning: [Semi Slider] The current browser does not support the focus-visible');
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
this.onBlur = (e, handler) => {
|
|
806
|
+
const {
|
|
807
|
+
firstDotFocusVisible,
|
|
808
|
+
secondDotFocusVisible
|
|
809
|
+
} = this.getStates();
|
|
810
|
+
|
|
811
|
+
if (handler === 'min') {
|
|
812
|
+
firstDotFocusVisible && this._adapter.setStateVal('firstDotFocusVisible', false);
|
|
813
|
+
} else {
|
|
814
|
+
secondDotFocusVisible && this._adapter.setStateVal('secondDotFocusVisible', false);
|
|
815
|
+
}
|
|
816
|
+
};
|
|
627
817
|
|
|
628
818
|
this.handleWrapClick = e => {
|
|
629
819
|
const {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//@import '../theme/variables.scss';
|
|
2
|
-
@import
|
|
2
|
+
@import './variables.scss';
|
|
3
3
|
|
|
4
4
|
$module: #{$prefix}-slider;
|
|
5
5
|
|
|
@@ -29,7 +29,7 @@ $module: #{$prefix}-slider;
|
|
|
29
29
|
font-variant: tabular-nums;
|
|
30
30
|
line-height: $font-slider_rail-lineHeight;
|
|
31
31
|
list-style: none;
|
|
32
|
-
font-feature-settings:
|
|
32
|
+
font-feature-settings: 'tnum';
|
|
33
33
|
position: absolute;
|
|
34
34
|
height: $height-slider_rail;
|
|
35
35
|
cursor: pointer;
|
|
@@ -54,7 +54,11 @@ $module: #{$prefix}-slider;
|
|
|
54
54
|
border: none;
|
|
55
55
|
border-radius: 50%;
|
|
56
56
|
cursor: pointer;
|
|
57
|
-
transition: #fff .3s;
|
|
57
|
+
transition: #fff 0.3s;
|
|
58
|
+
|
|
59
|
+
&:focus-visible {
|
|
60
|
+
outline: $width-slider_handle-focus solid $color-slider_handle-focus;
|
|
61
|
+
}
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
&-handle:hover {
|
|
@@ -133,10 +137,8 @@ $module: #{$prefix}-slider;
|
|
|
133
137
|
text-align: center;
|
|
134
138
|
cursor: pointer;
|
|
135
139
|
transform: translate(-50%, 0) rotate(-180deg);
|
|
136
|
-
|
|
137
140
|
}
|
|
138
141
|
|
|
139
|
-
|
|
140
142
|
&-boundary {
|
|
141
143
|
position: relative;
|
|
142
144
|
font-size: $font-size-small;
|
|
@@ -11,9 +11,10 @@ $color-slider_handle_disabled-border-hover: var(--semi-color-white); // 禁用
|
|
|
11
11
|
$color-slider_handle_disabled-border: var(--semi-color-border); // 禁用滑动条圆形描边颜色 - 默认态
|
|
12
12
|
$color-slider_mark-text-default: var(--semi-color-text-2); // 滑动条刻度文字颜色
|
|
13
13
|
$color-slider_rail-bg-default: var(--semi-color-fill-0); // 滑动条轨道颜色 - 未填充
|
|
14
|
-
$color-slider_rail: rgba(0, 0, 0, .65);
|
|
14
|
+
$color-slider_rail: rgba(0, 0, 0, 0.65);
|
|
15
15
|
$color-slider_track-bg-default: var(--semi-color-primary); // 滑动条轨道颜色 - 已填充
|
|
16
16
|
$color-slider_track_disabled-bg: var(--semi-color-primary-disabled); // 禁用滑动条轨道颜色 - 已填充
|
|
17
|
+
$color-slider_handle-focus: var(--semi-color-primary-light-active); // 圆形按钮轮廓 - 聚焦
|
|
17
18
|
|
|
18
19
|
// Spacing
|
|
19
20
|
$spacing-slider-paddingX: 13px; // 滑动条整体水平内边距
|
|
@@ -33,7 +34,7 @@ $spacing-slider_boundary_min-left: 0;
|
|
|
33
34
|
$spacing-slider_boundary_max-right: 0;
|
|
34
35
|
$spacing-slider_vertical_marks-marginTop: -30px; // 垂直滑动条刻度标签顶部外边距
|
|
35
36
|
$spacing-slider_vertical_marks-marginLeft: 29px; // 垂直滑动条刻度标签左侧外边距
|
|
36
|
-
$spacing-slider_vertical_marks-reverse-marginLeft: -26px
|
|
37
|
+
$spacing-slider_vertical_marks-reverse-marginLeft: -26px; // 垂直滑动条刻度标签左侧外边距(标签在左侧时)
|
|
37
38
|
$spacing-slider_vertical_rail-top: 0; // 垂直滑动条轨道顶部距离
|
|
38
39
|
$spacing-slider_vertical_handle-marginTop: 0; // 垂直滑动条原型按钮顶部外边距
|
|
39
40
|
$spacing-slider_vertical_handle-marginLeft: -10px; // 垂直滑动条原型按钮左侧外边距
|
|
@@ -42,7 +43,6 @@ $spacing-slider_vertical_handle-marginLeft: -10px; // 垂直滑动条原型按
|
|
|
42
43
|
$radius-slider_rail: var(--semi-border-radius-small); // 滚动条未填充轨道圆角
|
|
43
44
|
$radius-slider_track: var(--semi-border-radius-small); // 滚动条已填充轨道圆角
|
|
44
45
|
|
|
45
|
-
|
|
46
46
|
// Width/Height
|
|
47
47
|
$height-slider_wrapper: 32px; // 滚动条容器整体高度
|
|
48
48
|
$height-slider_vertical_wrapper: 4px; // 垂直滚动条整体宽度
|
|
@@ -52,7 +52,7 @@ $width-slider_handle_clicked: 1px; // 滚动条圆形按钮按下后描边宽度
|
|
|
52
52
|
$height-slider_track: 4px; // 滚动条已填充轨道高度
|
|
53
53
|
$width-slider_dot: 4px; // 滚动条圆形刻度点宽度
|
|
54
54
|
$width-slider_handle_border_disabled: 1px; // 禁用滚动条圆形按钮按下后描边宽度
|
|
55
|
-
|
|
55
|
+
$width-slider_handle-focus: 2px; // 圆形按钮轮廓 - 聚焦
|
|
56
56
|
|
|
57
57
|
// Font
|
|
58
58
|
$font-slider_rail-fontSize: 14px; // 滚动条轨道文本字号
|
|
@@ -19,7 +19,7 @@ $spacing-tooltip_content-paddingBottom: $spacing-tight; // 工具提示内容底
|
|
|
19
19
|
|
|
20
20
|
$font-tooltip-fontSize: $font-size-regular; // 工具提示文本字号
|
|
21
21
|
$width-tooltip: 240px; // 工具提示宽度 - 默认
|
|
22
|
-
$width-tooltip_arrow: 24px; // 工具提示小三角箭头宽度 - 水平
|
|
22
|
+
$width-tooltip_arrow: 24px; // 工具提示小三角箭头宽度 - 水平 ignore-semi-css-trans
|
|
23
23
|
$height-tooltip_arrow: 7px; // 工具提示小三角箭头高度 - 水平
|
|
24
24
|
|
|
25
25
|
$height-tooltip_arrow_vertical: 24px; // 工具提示小三角箭头高度 - 垂直
|
|
@@ -188,6 +188,7 @@
|
|
|
188
188
|
.semi-tree-select-arrow {
|
|
189
189
|
display: inline-flex;
|
|
190
190
|
align-items: center;
|
|
191
|
+
flex-shrink: 0;
|
|
191
192
|
height: 100%;
|
|
192
193
|
justify-content: center;
|
|
193
194
|
width: 32px;
|
|
@@ -212,6 +213,7 @@
|
|
|
212
213
|
display: inline-flex;
|
|
213
214
|
align-items: center;
|
|
214
215
|
height: 100%;
|
|
216
|
+
flex-shrink: 0;
|
|
215
217
|
justify-content: center;
|
|
216
218
|
width: 32px;
|
|
217
219
|
color: var(--semi-color-text-2);
|
|
@@ -239,6 +239,7 @@ $module: #{$prefix}-tree-select;
|
|
|
239
239
|
// right: 0;
|
|
240
240
|
display: inline-flex;
|
|
241
241
|
align-items: center;
|
|
242
|
+
flex-shrink: 0;
|
|
242
243
|
height: 100%;
|
|
243
244
|
justify-content: center;
|
|
244
245
|
width: $width-treeSelect_arrow;
|
|
@@ -265,6 +266,7 @@ $module: #{$prefix}-tree-select;
|
|
|
265
266
|
display: inline-flex;
|
|
266
267
|
align-items: center;
|
|
267
268
|
height: 100%;
|
|
269
|
+
flex-shrink: 0;
|
|
268
270
|
justify-content: center;
|
|
269
271
|
width: $width-treeSelect_arrow;
|
|
270
272
|
color: $color-treeSelect_default-icon-default;
|
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
line-height: 20px;
|
|
8
8
|
font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
9
9
|
}
|
|
10
|
+
.semi-typography-text {
|
|
11
|
+
display: inline-block;
|
|
12
|
+
}
|
|
13
|
+
.semi-typography-text-icon {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
}
|
|
10
16
|
.semi-typography.semi-typography-secondary {
|
|
11
17
|
color: var(--semi-color-text-1);
|
|
12
18
|
}
|
|
@@ -38,6 +44,7 @@
|
|
|
38
44
|
color: var(--semi-color-link);
|
|
39
45
|
}
|
|
40
46
|
.semi-typography-icon {
|
|
47
|
+
display: inline-flex;
|
|
41
48
|
margin-right: 4px;
|
|
42
49
|
vertical-align: middle;
|
|
43
50
|
color: inherit;
|
|
@@ -6,6 +6,14 @@ $module: #{$prefix}-typography;
|
|
|
6
6
|
color: $color-typography_default-text-default;
|
|
7
7
|
@include font-size-regular;
|
|
8
8
|
|
|
9
|
+
&-text {
|
|
10
|
+
display: inline-block;
|
|
11
|
+
|
|
12
|
+
&-icon {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
&.#{$module}-secondary {
|
|
10
18
|
color: $color-typography_secondary-text-default;
|
|
11
19
|
}
|
|
@@ -45,7 +53,7 @@ $module: #{$prefix}-typography;
|
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
&-icon {
|
|
48
|
-
|
|
56
|
+
display: inline-flex;
|
|
49
57
|
margin-right: $spacing-typography_iconPrefix-marginRight;
|
|
50
58
|
vertical-align: middle;
|
|
51
59
|
color: inherit;
|
|
@@ -26,7 +26,7 @@ export interface SliderProps {
|
|
|
26
26
|
'aria-label'?: string;
|
|
27
27
|
'aria-labelledby'?: string;
|
|
28
28
|
'aria-valuetext'?: string;
|
|
29
|
-
getAriaValueText?: (value: number) => string;
|
|
29
|
+
getAriaValueText?: (value: number, index?: number) => string;
|
|
30
30
|
}
|
|
31
31
|
export interface SliderState {
|
|
32
32
|
currentValue: number | number[];
|
|
@@ -40,6 +40,8 @@ export interface SliderState {
|
|
|
40
40
|
clickValue: 0;
|
|
41
41
|
showBoundary: boolean;
|
|
42
42
|
isInRenderTree: boolean;
|
|
43
|
+
firstDotFocusVisible: boolean;
|
|
44
|
+
secondDotFocusVisible: boolean;
|
|
43
45
|
}
|
|
44
46
|
export interface SliderLengths {
|
|
45
47
|
sliderX: number;
|
|
@@ -53,7 +55,6 @@ export interface ScrollParentVal {
|
|
|
53
55
|
}
|
|
54
56
|
export interface OverallVars {
|
|
55
57
|
dragging: boolean[];
|
|
56
|
-
chooseMovePos: 'min' | 'max';
|
|
57
58
|
}
|
|
58
59
|
export interface SliderAdapter extends DefaultAdapter<SliderProps, SliderState> {
|
|
59
60
|
getSliderLengths: () => SliderLengths;
|
|
@@ -189,7 +190,13 @@ export default class SliderFoundation extends BaseFoundation<SliderAdapter> {
|
|
|
189
190
|
onHandleEnter: (pos: SliderState['focusPos']) => void;
|
|
190
191
|
onHandleLeave: () => void;
|
|
191
192
|
onHandleUp: (e: any) => boolean;
|
|
193
|
+
_handleValueDecreaseWithKeyBoard: (step: number, handler: 'min' | 'max') => number | any[];
|
|
194
|
+
_handleValueIncreaseWithKeyBoard: (step: number, handler: 'min' | 'max') => any;
|
|
195
|
+
_handleHomeKey: (handler: 'min' | 'max') => any;
|
|
196
|
+
_handleEndKey: (handler: 'min' | 'max') => any;
|
|
197
|
+
handleKeyDown: (event: any, handler: 'min' | 'max') => void;
|
|
192
198
|
onFocus: (e: any, handler: 'min' | 'max') => void;
|
|
199
|
+
onBlur: (e: any, handler: 'min' | 'max') => void;
|
|
193
200
|
handleWrapClick: (e: any) => void;
|
|
194
201
|
/**
|
|
195
202
|
* Move the slider to the current click position
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
2
2
|
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
3
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
3
4
|
|
|
4
5
|
/* eslint-disable no-param-reassign */
|
|
5
6
|
|
|
@@ -8,6 +9,8 @@ import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array
|
|
|
8
9
|
/* eslint-disable no-nested-ternary */
|
|
9
10
|
import BaseFoundation from '../base/foundation';
|
|
10
11
|
import touchEventPolyfill from '../utils/touchPolyfill';
|
|
12
|
+
import warning from '../utils/warning';
|
|
13
|
+
import { handlePrevent } from '../utils/a11y';
|
|
11
14
|
export default class SliderFoundation extends BaseFoundation {
|
|
12
15
|
constructor(adapter) {
|
|
13
16
|
var _this;
|
|
@@ -532,8 +535,7 @@ export default class SliderFoundation extends BaseFoundation {
|
|
|
532
535
|
const handleMaxDom = this._adapter.getMaxHandleEl().current;
|
|
533
536
|
|
|
534
537
|
if (e.target === handleMinDom || e.target === handleMaxDom) {
|
|
535
|
-
e
|
|
536
|
-
e.stopPropagation();
|
|
538
|
+
handlePrevent(e);
|
|
537
539
|
const touch = touchEventPolyfill(e.touches[0], e);
|
|
538
540
|
this.onHandleDown(touch, handler);
|
|
539
541
|
}
|
|
@@ -597,18 +599,203 @@ export default class SliderFoundation extends BaseFoundation {
|
|
|
597
599
|
this._adapter.setDragging([dragging[0], false]);
|
|
598
600
|
}
|
|
599
601
|
|
|
600
|
-
this._adapter.setStateVal('isDrag', false);
|
|
601
|
-
|
|
602
|
+
this._adapter.setStateVal('isDrag', false);
|
|
602
603
|
|
|
603
604
|
this._adapter.onHandleLeave();
|
|
604
605
|
|
|
605
606
|
this._adapter.onHandleUpAfter();
|
|
606
607
|
|
|
607
608
|
return true;
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
this._handleValueDecreaseWithKeyBoard = (step, handler) => {
|
|
612
|
+
const {
|
|
613
|
+
min,
|
|
614
|
+
currentValue
|
|
615
|
+
} = this.getStates();
|
|
616
|
+
const {
|
|
617
|
+
range
|
|
618
|
+
} = this.getProps();
|
|
619
|
+
|
|
620
|
+
if (handler === 'min') {
|
|
621
|
+
if (range) {
|
|
622
|
+
let newMinValue = currentValue[0] - step;
|
|
623
|
+
newMinValue = newMinValue < min ? min : newMinValue;
|
|
624
|
+
return [newMinValue, currentValue[1]];
|
|
625
|
+
} else {
|
|
626
|
+
let newMinValue = currentValue - step;
|
|
627
|
+
newMinValue = newMinValue < min ? min : newMinValue;
|
|
628
|
+
return newMinValue;
|
|
629
|
+
}
|
|
630
|
+
} else {
|
|
631
|
+
let newMaxValue = currentValue[1] - step;
|
|
632
|
+
newMaxValue = newMaxValue < currentValue[0] ? currentValue[0] : newMaxValue;
|
|
633
|
+
return [currentValue[0], newMaxValue];
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
this._handleValueIncreaseWithKeyBoard = (step, handler) => {
|
|
638
|
+
const {
|
|
639
|
+
max,
|
|
640
|
+
currentValue
|
|
641
|
+
} = this.getStates();
|
|
642
|
+
const {
|
|
643
|
+
range
|
|
644
|
+
} = this.getProps();
|
|
645
|
+
|
|
646
|
+
if (handler === 'min') {
|
|
647
|
+
if (range) {
|
|
648
|
+
let newMinValue = currentValue[0] + step;
|
|
649
|
+
newMinValue = newMinValue > currentValue[1] ? currentValue[1] : newMinValue;
|
|
650
|
+
return [newMinValue, currentValue[1]];
|
|
651
|
+
} else {
|
|
652
|
+
let newMinValue = currentValue + step;
|
|
653
|
+
newMinValue = newMinValue > max ? max : newMinValue;
|
|
654
|
+
return newMinValue;
|
|
655
|
+
}
|
|
656
|
+
} else {
|
|
657
|
+
let newMaxValue = currentValue[1] + step;
|
|
658
|
+
newMaxValue = newMaxValue > max ? max : newMaxValue;
|
|
659
|
+
return [currentValue[0], newMaxValue];
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
this._handleHomeKey = handler => {
|
|
664
|
+
const {
|
|
665
|
+
min,
|
|
666
|
+
currentValue
|
|
667
|
+
} = this.getStates();
|
|
668
|
+
const {
|
|
669
|
+
range
|
|
670
|
+
} = this.getProps();
|
|
671
|
+
|
|
672
|
+
if (handler === 'min') {
|
|
673
|
+
if (range) {
|
|
674
|
+
return [min, currentValue[1]];
|
|
675
|
+
} else {
|
|
676
|
+
return min;
|
|
677
|
+
}
|
|
678
|
+
} else {
|
|
679
|
+
return [currentValue[0], currentValue[0]];
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
this._handleEndKey = handler => {
|
|
684
|
+
const {
|
|
685
|
+
max,
|
|
686
|
+
currentValue
|
|
687
|
+
} = this.getStates();
|
|
688
|
+
const {
|
|
689
|
+
range
|
|
690
|
+
} = this.getProps();
|
|
691
|
+
|
|
692
|
+
if (handler === 'min') {
|
|
693
|
+
if (range) {
|
|
694
|
+
return [currentValue[1], currentValue[1]];
|
|
695
|
+
} else {
|
|
696
|
+
return max;
|
|
697
|
+
}
|
|
698
|
+
} else {
|
|
699
|
+
return [currentValue[0], max];
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
|
|
703
|
+
this.handleKeyDown = (event, handler) => {
|
|
704
|
+
var _context;
|
|
705
|
+
|
|
706
|
+
const {
|
|
707
|
+
min,
|
|
708
|
+
max,
|
|
709
|
+
currentValue
|
|
710
|
+
} = this.getStates();
|
|
711
|
+
const {
|
|
712
|
+
step,
|
|
713
|
+
range
|
|
714
|
+
} = this.getProps();
|
|
715
|
+
let outputValue;
|
|
716
|
+
|
|
717
|
+
switch (event.key) {
|
|
718
|
+
case "ArrowLeft":
|
|
719
|
+
case "ArrowDown":
|
|
720
|
+
outputValue = this._handleValueDecreaseWithKeyBoard(step, handler);
|
|
721
|
+
break;
|
|
722
|
+
|
|
723
|
+
case "ArrowRight":
|
|
724
|
+
case "ArrowUp":
|
|
725
|
+
outputValue = this._handleValueIncreaseWithKeyBoard(step, handler);
|
|
726
|
+
break;
|
|
727
|
+
|
|
728
|
+
case "PageUp":
|
|
729
|
+
outputValue = this._handleValueIncreaseWithKeyBoard(10 * step, handler);
|
|
730
|
+
break;
|
|
731
|
+
|
|
732
|
+
case "PageDown":
|
|
733
|
+
outputValue = this._handleValueDecreaseWithKeyBoard(10 * step, handler);
|
|
734
|
+
break;
|
|
735
|
+
|
|
736
|
+
case "Home":
|
|
737
|
+
outputValue = this._handleHomeKey(handler);
|
|
738
|
+
break;
|
|
739
|
+
|
|
740
|
+
case "End":
|
|
741
|
+
outputValue = this._handleEndKey(handler);
|
|
742
|
+
break;
|
|
743
|
+
|
|
744
|
+
case 'default':
|
|
745
|
+
break;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
if (_includesInstanceProperty(_context = ["ArrowLeft", "ArrowDown", "ArrowRight", "ArrowUp", "PageUp", "PageDown", "Home", "End"]).call(_context, event.key)) {
|
|
749
|
+
let update = true;
|
|
750
|
+
|
|
751
|
+
if (_Array$isArray(currentValue)) {
|
|
752
|
+
update = !(currentValue[0] === outputValue[0] && currentValue[1] === outputValue[1]);
|
|
753
|
+
} else {
|
|
754
|
+
update = currentValue !== outputValue;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
if (update) {
|
|
758
|
+
this._adapter.updateCurrentValue(outputValue);
|
|
759
|
+
|
|
760
|
+
this._adapter.notifyChange(outputValue);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
handlePrevent(event);
|
|
764
|
+
}
|
|
608
765
|
}; // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
609
766
|
|
|
610
767
|
|
|
611
|
-
this.onFocus = (e, handler) => {
|
|
768
|
+
this.onFocus = (e, handler) => {
|
|
769
|
+
handlePrevent(e);
|
|
770
|
+
const {
|
|
771
|
+
target
|
|
772
|
+
} = e;
|
|
773
|
+
|
|
774
|
+
try {
|
|
775
|
+
if (target.matches(':focus-visible')) {
|
|
776
|
+
if (handler === 'min') {
|
|
777
|
+
this._adapter.setStateVal('firstDotFocusVisible', true);
|
|
778
|
+
} else {
|
|
779
|
+
this._adapter.setStateVal('secondDotFocusVisible', true);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
} catch (error) {
|
|
783
|
+
warning(true, 'Warning: [Semi Slider] The current browser does not support the focus-visible');
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
this.onBlur = (e, handler) => {
|
|
788
|
+
const {
|
|
789
|
+
firstDotFocusVisible,
|
|
790
|
+
secondDotFocusVisible
|
|
791
|
+
} = this.getStates();
|
|
792
|
+
|
|
793
|
+
if (handler === 'min') {
|
|
794
|
+
firstDotFocusVisible && this._adapter.setStateVal('firstDotFocusVisible', false);
|
|
795
|
+
} else {
|
|
796
|
+
secondDotFocusVisible && this._adapter.setStateVal('secondDotFocusVisible', false);
|
|
797
|
+
}
|
|
798
|
+
};
|
|
612
799
|
|
|
613
800
|
this.handleWrapClick = e => {
|
|
614
801
|
const {
|
package/lib/es/slider/slider.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//@import '../theme/variables.scss';
|
|
2
|
-
@import
|
|
2
|
+
@import './variables.scss';
|
|
3
3
|
|
|
4
4
|
$module: #{$prefix}-slider;
|
|
5
5
|
|
|
@@ -29,7 +29,7 @@ $module: #{$prefix}-slider;
|
|
|
29
29
|
font-variant: tabular-nums;
|
|
30
30
|
line-height: $font-slider_rail-lineHeight;
|
|
31
31
|
list-style: none;
|
|
32
|
-
font-feature-settings:
|
|
32
|
+
font-feature-settings: 'tnum';
|
|
33
33
|
position: absolute;
|
|
34
34
|
height: $height-slider_rail;
|
|
35
35
|
cursor: pointer;
|
|
@@ -54,7 +54,11 @@ $module: #{$prefix}-slider;
|
|
|
54
54
|
border: none;
|
|
55
55
|
border-radius: 50%;
|
|
56
56
|
cursor: pointer;
|
|
57
|
-
transition: #fff .3s;
|
|
57
|
+
transition: #fff 0.3s;
|
|
58
|
+
|
|
59
|
+
&:focus-visible {
|
|
60
|
+
outline: $width-slider_handle-focus solid $color-slider_handle-focus;
|
|
61
|
+
}
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
&-handle:hover {
|
|
@@ -133,10 +137,8 @@ $module: #{$prefix}-slider;
|
|
|
133
137
|
text-align: center;
|
|
134
138
|
cursor: pointer;
|
|
135
139
|
transform: translate(-50%, 0) rotate(-180deg);
|
|
136
|
-
|
|
137
140
|
}
|
|
138
141
|
|
|
139
|
-
|
|
140
142
|
&-boundary {
|
|
141
143
|
position: relative;
|
|
142
144
|
font-size: $font-size-small;
|
|
@@ -11,9 +11,10 @@ $color-slider_handle_disabled-border-hover: var(--semi-color-white); // 禁用
|
|
|
11
11
|
$color-slider_handle_disabled-border: var(--semi-color-border); // 禁用滑动条圆形描边颜色 - 默认态
|
|
12
12
|
$color-slider_mark-text-default: var(--semi-color-text-2); // 滑动条刻度文字颜色
|
|
13
13
|
$color-slider_rail-bg-default: var(--semi-color-fill-0); // 滑动条轨道颜色 - 未填充
|
|
14
|
-
$color-slider_rail: rgba(0, 0, 0, .65);
|
|
14
|
+
$color-slider_rail: rgba(0, 0, 0, 0.65);
|
|
15
15
|
$color-slider_track-bg-default: var(--semi-color-primary); // 滑动条轨道颜色 - 已填充
|
|
16
16
|
$color-slider_track_disabled-bg: var(--semi-color-primary-disabled); // 禁用滑动条轨道颜色 - 已填充
|
|
17
|
+
$color-slider_handle-focus: var(--semi-color-primary-light-active); // 圆形按钮轮廓 - 聚焦
|
|
17
18
|
|
|
18
19
|
// Spacing
|
|
19
20
|
$spacing-slider-paddingX: 13px; // 滑动条整体水平内边距
|
|
@@ -33,7 +34,7 @@ $spacing-slider_boundary_min-left: 0;
|
|
|
33
34
|
$spacing-slider_boundary_max-right: 0;
|
|
34
35
|
$spacing-slider_vertical_marks-marginTop: -30px; // 垂直滑动条刻度标签顶部外边距
|
|
35
36
|
$spacing-slider_vertical_marks-marginLeft: 29px; // 垂直滑动条刻度标签左侧外边距
|
|
36
|
-
$spacing-slider_vertical_marks-reverse-marginLeft: -26px
|
|
37
|
+
$spacing-slider_vertical_marks-reverse-marginLeft: -26px; // 垂直滑动条刻度标签左侧外边距(标签在左侧时)
|
|
37
38
|
$spacing-slider_vertical_rail-top: 0; // 垂直滑动条轨道顶部距离
|
|
38
39
|
$spacing-slider_vertical_handle-marginTop: 0; // 垂直滑动条原型按钮顶部外边距
|
|
39
40
|
$spacing-slider_vertical_handle-marginLeft: -10px; // 垂直滑动条原型按钮左侧外边距
|
|
@@ -42,7 +43,6 @@ $spacing-slider_vertical_handle-marginLeft: -10px; // 垂直滑动条原型按
|
|
|
42
43
|
$radius-slider_rail: var(--semi-border-radius-small); // 滚动条未填充轨道圆角
|
|
43
44
|
$radius-slider_track: var(--semi-border-radius-small); // 滚动条已填充轨道圆角
|
|
44
45
|
|
|
45
|
-
|
|
46
46
|
// Width/Height
|
|
47
47
|
$height-slider_wrapper: 32px; // 滚动条容器整体高度
|
|
48
48
|
$height-slider_vertical_wrapper: 4px; // 垂直滚动条整体宽度
|
|
@@ -52,7 +52,7 @@ $width-slider_handle_clicked: 1px; // 滚动条圆形按钮按下后描边宽度
|
|
|
52
52
|
$height-slider_track: 4px; // 滚动条已填充轨道高度
|
|
53
53
|
$width-slider_dot: 4px; // 滚动条圆形刻度点宽度
|
|
54
54
|
$width-slider_handle_border_disabled: 1px; // 禁用滚动条圆形按钮按下后描边宽度
|
|
55
|
-
|
|
55
|
+
$width-slider_handle-focus: 2px; // 圆形按钮轮廓 - 聚焦
|
|
56
56
|
|
|
57
57
|
// Font
|
|
58
58
|
$font-slider_rail-fontSize: 14px; // 滚动条轨道文本字号
|
|
@@ -19,7 +19,7 @@ $spacing-tooltip_content-paddingBottom: $spacing-tight; // 工具提示内容底
|
|
|
19
19
|
|
|
20
20
|
$font-tooltip-fontSize: $font-size-regular; // 工具提示文本字号
|
|
21
21
|
$width-tooltip: 240px; // 工具提示宽度 - 默认
|
|
22
|
-
$width-tooltip_arrow: 24px; // 工具提示小三角箭头宽度 - 水平
|
|
22
|
+
$width-tooltip_arrow: 24px; // 工具提示小三角箭头宽度 - 水平 ignore-semi-css-trans
|
|
23
23
|
$height-tooltip_arrow: 7px; // 工具提示小三角箭头高度 - 水平
|
|
24
24
|
|
|
25
25
|
$height-tooltip_arrow_vertical: 24px; // 工具提示小三角箭头高度 - 垂直
|
|
@@ -188,6 +188,7 @@
|
|
|
188
188
|
.semi-tree-select-arrow {
|
|
189
189
|
display: inline-flex;
|
|
190
190
|
align-items: center;
|
|
191
|
+
flex-shrink: 0;
|
|
191
192
|
height: 100%;
|
|
192
193
|
justify-content: center;
|
|
193
194
|
width: 32px;
|
|
@@ -212,6 +213,7 @@
|
|
|
212
213
|
display: inline-flex;
|
|
213
214
|
align-items: center;
|
|
214
215
|
height: 100%;
|
|
216
|
+
flex-shrink: 0;
|
|
215
217
|
justify-content: center;
|
|
216
218
|
width: 32px;
|
|
217
219
|
color: var(--semi-color-text-2);
|
|
@@ -239,6 +239,7 @@ $module: #{$prefix}-tree-select;
|
|
|
239
239
|
// right: 0;
|
|
240
240
|
display: inline-flex;
|
|
241
241
|
align-items: center;
|
|
242
|
+
flex-shrink: 0;
|
|
242
243
|
height: 100%;
|
|
243
244
|
justify-content: center;
|
|
244
245
|
width: $width-treeSelect_arrow;
|
|
@@ -265,6 +266,7 @@ $module: #{$prefix}-tree-select;
|
|
|
265
266
|
display: inline-flex;
|
|
266
267
|
align-items: center;
|
|
267
268
|
height: 100%;
|
|
269
|
+
flex-shrink: 0;
|
|
268
270
|
justify-content: center;
|
|
269
271
|
width: $width-treeSelect_arrow;
|
|
270
272
|
color: $color-treeSelect_default-icon-default;
|
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
line-height: 20px;
|
|
8
8
|
font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
9
9
|
}
|
|
10
|
+
.semi-typography-text {
|
|
11
|
+
display: inline-block;
|
|
12
|
+
}
|
|
13
|
+
.semi-typography-text-icon {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
}
|
|
10
16
|
.semi-typography.semi-typography-secondary {
|
|
11
17
|
color: var(--semi-color-text-1);
|
|
12
18
|
}
|
|
@@ -38,6 +44,7 @@
|
|
|
38
44
|
color: var(--semi-color-link);
|
|
39
45
|
}
|
|
40
46
|
.semi-typography-icon {
|
|
47
|
+
display: inline-flex;
|
|
41
48
|
margin-right: 4px;
|
|
42
49
|
vertical-align: middle;
|
|
43
50
|
color: inherit;
|
|
@@ -6,6 +6,14 @@ $module: #{$prefix}-typography;
|
|
|
6
6
|
color: $color-typography_default-text-default;
|
|
7
7
|
@include font-size-regular;
|
|
8
8
|
|
|
9
|
+
&-text {
|
|
10
|
+
display: inline-block;
|
|
11
|
+
|
|
12
|
+
&-icon {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
&.#{$module}-secondary {
|
|
10
18
|
color: $color-typography_secondary-text-default;
|
|
11
19
|
}
|
|
@@ -45,7 +53,7 @@ $module: #{$prefix}-typography;
|
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
&-icon {
|
|
48
|
-
|
|
56
|
+
display: inline-flex;
|
|
49
57
|
margin-right: $spacing-typography_iconPrefix-marginRight;
|
|
50
58
|
vertical-align: middle;
|
|
51
59
|
color: inherit;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build:lib": "node ./scripts/compileLib.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"*.scss",
|
|
25
25
|
"*.css"
|
|
26
26
|
],
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "e78045febe3e4645c8afe6d42cfbcb4e97a67923",
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
30
30
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
package/slider/foundation.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
/* eslint-disable no-nested-ternary */
|
|
4
4
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
5
5
|
import touchEventPolyfill from '../utils/touchPolyfill';
|
|
6
|
-
|
|
6
|
+
import warning from '../utils/warning';
|
|
7
|
+
import { handlePrevent } from '../utils/a11y';
|
|
7
8
|
|
|
8
9
|
export interface Marks{
|
|
9
10
|
[key: number]: string;
|
|
@@ -34,7 +35,7 @@ export interface SliderProps{
|
|
|
34
35
|
'aria-label'?: string;
|
|
35
36
|
'aria-labelledby'?: string;
|
|
36
37
|
'aria-valuetext'?: string;
|
|
37
|
-
getAriaValueText?: (value: number) => string;
|
|
38
|
+
getAriaValueText?: (value: number, index?: number) => string;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
export interface SliderState {
|
|
@@ -49,6 +50,8 @@ export interface SliderState {
|
|
|
49
50
|
clickValue: 0;
|
|
50
51
|
showBoundary: boolean;
|
|
51
52
|
isInRenderTree: boolean;
|
|
53
|
+
firstDotFocusVisible: boolean;
|
|
54
|
+
secondDotFocusVisible: boolean;
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
export interface SliderLengths{
|
|
@@ -65,7 +68,6 @@ export interface ScrollParentVal{
|
|
|
65
68
|
|
|
66
69
|
export interface OverallVars{
|
|
67
70
|
dragging: boolean[];
|
|
68
|
-
chooseMovePos: 'min' | 'max';
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
export interface SliderAdapter extends DefaultAdapter<SliderProps, SliderState>{
|
|
@@ -514,8 +516,7 @@ export default class SliderFoundation extends BaseFoundation<SliderAdapter> {
|
|
|
514
516
|
const handleMinDom = this._adapter.getMinHandleEl().current;
|
|
515
517
|
const handleMaxDom = this._adapter.getMaxHandleEl().current;
|
|
516
518
|
if (e.target === handleMinDom || e.target === handleMaxDom) {
|
|
517
|
-
e
|
|
518
|
-
e.stopPropagation();
|
|
519
|
+
handlePrevent(e);
|
|
519
520
|
const touch = touchEventPolyfill(e.touches[0], e);
|
|
520
521
|
this.onHandleDown(touch, handler);
|
|
521
522
|
}
|
|
@@ -564,14 +565,147 @@ export default class SliderFoundation extends BaseFoundation<SliderAdapter> {
|
|
|
564
565
|
this._adapter.setDragging([dragging[0], false]);
|
|
565
566
|
}
|
|
566
567
|
this._adapter.setStateVal('isDrag', false);
|
|
567
|
-
// this._adapter.setStateVal('chooseMovePos', '');
|
|
568
568
|
this._adapter.onHandleLeave();
|
|
569
569
|
this._adapter.onHandleUpAfter();
|
|
570
570
|
return true;
|
|
571
571
|
};
|
|
572
572
|
|
|
573
|
+
_handleValueDecreaseWithKeyBoard = (step: number, handler: 'min'| 'max') => {
|
|
574
|
+
const { min, currentValue } = this.getStates();
|
|
575
|
+
const { range } = this.getProps();
|
|
576
|
+
if (handler === 'min') {
|
|
577
|
+
if (range) {
|
|
578
|
+
let newMinValue = currentValue[0] - step;
|
|
579
|
+
newMinValue = newMinValue < min ? min : newMinValue;
|
|
580
|
+
return [newMinValue, currentValue[1]];
|
|
581
|
+
} else {
|
|
582
|
+
let newMinValue = currentValue - step;
|
|
583
|
+
newMinValue = newMinValue < min ? min : newMinValue;
|
|
584
|
+
return newMinValue;
|
|
585
|
+
}
|
|
586
|
+
} else {
|
|
587
|
+
let newMaxValue = currentValue[1] - step;
|
|
588
|
+
newMaxValue = newMaxValue < currentValue[0] ? currentValue[0] : newMaxValue;
|
|
589
|
+
return [currentValue[0], newMaxValue];
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
_handleValueIncreaseWithKeyBoard = (step: number, handler: 'min'| 'max') => {
|
|
594
|
+
const { max, currentValue } = this.getStates();
|
|
595
|
+
const { range } = this.getProps();
|
|
596
|
+
if (handler === 'min') {
|
|
597
|
+
if (range) {
|
|
598
|
+
let newMinValue = currentValue[0] + step;
|
|
599
|
+
newMinValue = newMinValue > currentValue[1] ? currentValue[1] : newMinValue;
|
|
600
|
+
return [newMinValue, currentValue[1]];
|
|
601
|
+
} else {
|
|
602
|
+
let newMinValue = currentValue + step;
|
|
603
|
+
newMinValue = newMinValue > max ? max : newMinValue;
|
|
604
|
+
return newMinValue;
|
|
605
|
+
}
|
|
606
|
+
} else {
|
|
607
|
+
let newMaxValue = currentValue[1] + step;
|
|
608
|
+
newMaxValue = newMaxValue > max ? max : newMaxValue;
|
|
609
|
+
return [currentValue[0], newMaxValue];
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
_handleHomeKey = (handler: 'min'| 'max') => {
|
|
614
|
+
const { min, currentValue } = this.getStates();
|
|
615
|
+
const { range } = this.getProps();
|
|
616
|
+
if (handler === 'min') {
|
|
617
|
+
if (range) {
|
|
618
|
+
return [min, currentValue[1]];
|
|
619
|
+
} else {
|
|
620
|
+
return min;
|
|
621
|
+
}
|
|
622
|
+
} else {
|
|
623
|
+
return [currentValue[0], currentValue[0]];
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
_handleEndKey = (handler: 'min'| 'max') => {
|
|
628
|
+
const { max, currentValue } = this.getStates();
|
|
629
|
+
const { range } = this.getProps();
|
|
630
|
+
if (handler === 'min') {
|
|
631
|
+
if (range) {
|
|
632
|
+
return [currentValue[1], currentValue[1]];
|
|
633
|
+
} else {
|
|
634
|
+
return max;
|
|
635
|
+
}
|
|
636
|
+
} else {
|
|
637
|
+
return [currentValue[0], max];
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
handleKeyDown = (event: any, handler: 'min'| 'max') => {
|
|
642
|
+
const { min, max, currentValue } = this.getStates();
|
|
643
|
+
const { step, range } = this.getProps();
|
|
644
|
+
let outputValue;
|
|
645
|
+
switch (event.key) {
|
|
646
|
+
case "ArrowLeft":
|
|
647
|
+
case "ArrowDown":
|
|
648
|
+
outputValue = this._handleValueDecreaseWithKeyBoard(step, handler);
|
|
649
|
+
break;
|
|
650
|
+
case "ArrowRight":
|
|
651
|
+
case "ArrowUp":
|
|
652
|
+
outputValue = this._handleValueIncreaseWithKeyBoard(step, handler);
|
|
653
|
+
break;
|
|
654
|
+
case "PageUp":
|
|
655
|
+
outputValue = this._handleValueIncreaseWithKeyBoard(10 * step, handler);
|
|
656
|
+
break;
|
|
657
|
+
case "PageDown":
|
|
658
|
+
outputValue = this._handleValueDecreaseWithKeyBoard(10 * step, handler);
|
|
659
|
+
break;
|
|
660
|
+
case "Home":
|
|
661
|
+
outputValue = this._handleHomeKey(handler);
|
|
662
|
+
break;
|
|
663
|
+
case "End":
|
|
664
|
+
outputValue = this._handleEndKey(handler);
|
|
665
|
+
break;
|
|
666
|
+
case 'default':
|
|
667
|
+
break;
|
|
668
|
+
}
|
|
669
|
+
if (["ArrowLeft", "ArrowDown", "ArrowRight", "ArrowUp", "PageUp", "PageDown", "Home", "End"].includes(event.key)) {
|
|
670
|
+
let update = true;
|
|
671
|
+
if (Array.isArray(currentValue)) {
|
|
672
|
+
update = !(currentValue[0] === outputValue[0] && currentValue[1] === outputValue[1]);
|
|
673
|
+
} else {
|
|
674
|
+
update = currentValue !== outputValue;
|
|
675
|
+
}
|
|
676
|
+
if (update) {
|
|
677
|
+
this._adapter.updateCurrentValue(outputValue);
|
|
678
|
+
this._adapter.notifyChange(outputValue);
|
|
679
|
+
}
|
|
680
|
+
handlePrevent(event);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
573
684
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
574
|
-
onFocus = (e:any, handler: 'min'| 'max') => {
|
|
685
|
+
onFocus = (e: any, handler: 'min'| 'max') => {
|
|
686
|
+
handlePrevent(e);
|
|
687
|
+
const { target } = e;
|
|
688
|
+
try {
|
|
689
|
+
if (target.matches(':focus-visible')) {
|
|
690
|
+
if (handler === 'min') {
|
|
691
|
+
this._adapter.setStateVal('firstDotFocusVisible', true);
|
|
692
|
+
} else {
|
|
693
|
+
this._adapter.setStateVal('secondDotFocusVisible', true);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
} catch (error) {
|
|
697
|
+
warning(true, 'Warning: [Semi Slider] The current browser does not support the focus-visible');
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
onBlur = (e: any, handler: 'min'| 'max') => {
|
|
702
|
+
const { firstDotFocusVisible, secondDotFocusVisible } = this.getStates();
|
|
703
|
+
if (handler === 'min') {
|
|
704
|
+
firstDotFocusVisible && this._adapter.setStateVal('firstDotFocusVisible', false);
|
|
705
|
+
} else {
|
|
706
|
+
secondDotFocusVisible && this._adapter.setStateVal('secondDotFocusVisible', false);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
575
709
|
|
|
576
710
|
handleWrapClick = (e: any) => {
|
|
577
711
|
const { disabled, isDrag } = this._adapter.getStates();
|
|
@@ -648,6 +782,4 @@ export default class SliderFoundation extends BaseFoundation<SliderAdapter> {
|
|
|
648
782
|
return vertical ? y : x;
|
|
649
783
|
}
|
|
650
784
|
|
|
651
|
-
|
|
652
|
-
|
|
653
785
|
}
|
package/slider/slider.scss
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//@import '../theme/variables.scss';
|
|
2
|
-
@import
|
|
2
|
+
@import './variables.scss';
|
|
3
3
|
|
|
4
4
|
$module: #{$prefix}-slider;
|
|
5
5
|
|
|
@@ -29,7 +29,7 @@ $module: #{$prefix}-slider;
|
|
|
29
29
|
font-variant: tabular-nums;
|
|
30
30
|
line-height: $font-slider_rail-lineHeight;
|
|
31
31
|
list-style: none;
|
|
32
|
-
font-feature-settings:
|
|
32
|
+
font-feature-settings: 'tnum';
|
|
33
33
|
position: absolute;
|
|
34
34
|
height: $height-slider_rail;
|
|
35
35
|
cursor: pointer;
|
|
@@ -54,7 +54,11 @@ $module: #{$prefix}-slider;
|
|
|
54
54
|
border: none;
|
|
55
55
|
border-radius: 50%;
|
|
56
56
|
cursor: pointer;
|
|
57
|
-
transition: #fff .3s;
|
|
57
|
+
transition: #fff 0.3s;
|
|
58
|
+
|
|
59
|
+
&:focus-visible {
|
|
60
|
+
outline: $width-slider_handle-focus solid $color-slider_handle-focus;
|
|
61
|
+
}
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
&-handle:hover {
|
|
@@ -133,10 +137,8 @@ $module: #{$prefix}-slider;
|
|
|
133
137
|
text-align: center;
|
|
134
138
|
cursor: pointer;
|
|
135
139
|
transform: translate(-50%, 0) rotate(-180deg);
|
|
136
|
-
|
|
137
140
|
}
|
|
138
141
|
|
|
139
|
-
|
|
140
142
|
&-boundary {
|
|
141
143
|
position: relative;
|
|
142
144
|
font-size: $font-size-small;
|
package/slider/variables.scss
CHANGED
|
@@ -11,9 +11,10 @@ $color-slider_handle_disabled-border-hover: var(--semi-color-white); // 禁用
|
|
|
11
11
|
$color-slider_handle_disabled-border: var(--semi-color-border); // 禁用滑动条圆形描边颜色 - 默认态
|
|
12
12
|
$color-slider_mark-text-default: var(--semi-color-text-2); // 滑动条刻度文字颜色
|
|
13
13
|
$color-slider_rail-bg-default: var(--semi-color-fill-0); // 滑动条轨道颜色 - 未填充
|
|
14
|
-
$color-slider_rail: rgba(0, 0, 0, .65);
|
|
14
|
+
$color-slider_rail: rgba(0, 0, 0, 0.65);
|
|
15
15
|
$color-slider_track-bg-default: var(--semi-color-primary); // 滑动条轨道颜色 - 已填充
|
|
16
16
|
$color-slider_track_disabled-bg: var(--semi-color-primary-disabled); // 禁用滑动条轨道颜色 - 已填充
|
|
17
|
+
$color-slider_handle-focus: var(--semi-color-primary-light-active); // 圆形按钮轮廓 - 聚焦
|
|
17
18
|
|
|
18
19
|
// Spacing
|
|
19
20
|
$spacing-slider-paddingX: 13px; // 滑动条整体水平内边距
|
|
@@ -33,7 +34,7 @@ $spacing-slider_boundary_min-left: 0;
|
|
|
33
34
|
$spacing-slider_boundary_max-right: 0;
|
|
34
35
|
$spacing-slider_vertical_marks-marginTop: -30px; // 垂直滑动条刻度标签顶部外边距
|
|
35
36
|
$spacing-slider_vertical_marks-marginLeft: 29px; // 垂直滑动条刻度标签左侧外边距
|
|
36
|
-
$spacing-slider_vertical_marks-reverse-marginLeft: -26px
|
|
37
|
+
$spacing-slider_vertical_marks-reverse-marginLeft: -26px; // 垂直滑动条刻度标签左侧外边距(标签在左侧时)
|
|
37
38
|
$spacing-slider_vertical_rail-top: 0; // 垂直滑动条轨道顶部距离
|
|
38
39
|
$spacing-slider_vertical_handle-marginTop: 0; // 垂直滑动条原型按钮顶部外边距
|
|
39
40
|
$spacing-slider_vertical_handle-marginLeft: -10px; // 垂直滑动条原型按钮左侧外边距
|
|
@@ -42,7 +43,6 @@ $spacing-slider_vertical_handle-marginLeft: -10px; // 垂直滑动条原型按
|
|
|
42
43
|
$radius-slider_rail: var(--semi-border-radius-small); // 滚动条未填充轨道圆角
|
|
43
44
|
$radius-slider_track: var(--semi-border-radius-small); // 滚动条已填充轨道圆角
|
|
44
45
|
|
|
45
|
-
|
|
46
46
|
// Width/Height
|
|
47
47
|
$height-slider_wrapper: 32px; // 滚动条容器整体高度
|
|
48
48
|
$height-slider_vertical_wrapper: 4px; // 垂直滚动条整体宽度
|
|
@@ -52,7 +52,7 @@ $width-slider_handle_clicked: 1px; // 滚动条圆形按钮按下后描边宽度
|
|
|
52
52
|
$height-slider_track: 4px; // 滚动条已填充轨道高度
|
|
53
53
|
$width-slider_dot: 4px; // 滚动条圆形刻度点宽度
|
|
54
54
|
$width-slider_handle_border_disabled: 1px; // 禁用滚动条圆形按钮按下后描边宽度
|
|
55
|
-
|
|
55
|
+
$width-slider_handle-focus: 2px; // 圆形按钮轮廓 - 聚焦
|
|
56
56
|
|
|
57
57
|
// Font
|
|
58
58
|
$font-slider_rail-fontSize: 14px; // 滚动条轨道文本字号
|
package/tooltip/variables.scss
CHANGED
|
@@ -19,7 +19,7 @@ $spacing-tooltip_content-paddingBottom: $spacing-tight; // 工具提示内容底
|
|
|
19
19
|
|
|
20
20
|
$font-tooltip-fontSize: $font-size-regular; // 工具提示文本字号
|
|
21
21
|
$width-tooltip: 240px; // 工具提示宽度 - 默认
|
|
22
|
-
$width-tooltip_arrow: 24px; // 工具提示小三角箭头宽度 - 水平
|
|
22
|
+
$width-tooltip_arrow: 24px; // 工具提示小三角箭头宽度 - 水平 ignore-semi-css-trans
|
|
23
23
|
$height-tooltip_arrow: 7px; // 工具提示小三角箭头高度 - 水平
|
|
24
24
|
|
|
25
25
|
$height-tooltip_arrow_vertical: 24px; // 工具提示小三角箭头高度 - 垂直
|
|
@@ -239,6 +239,7 @@ $module: #{$prefix}-tree-select;
|
|
|
239
239
|
// right: 0;
|
|
240
240
|
display: inline-flex;
|
|
241
241
|
align-items: center;
|
|
242
|
+
flex-shrink: 0;
|
|
242
243
|
height: 100%;
|
|
243
244
|
justify-content: center;
|
|
244
245
|
width: $width-treeSelect_arrow;
|
|
@@ -265,6 +266,7 @@ $module: #{$prefix}-tree-select;
|
|
|
265
266
|
display: inline-flex;
|
|
266
267
|
align-items: center;
|
|
267
268
|
height: 100%;
|
|
269
|
+
flex-shrink: 0;
|
|
268
270
|
justify-content: center;
|
|
269
271
|
width: $width-treeSelect_arrow;
|
|
270
272
|
color: $color-treeSelect_default-icon-default;
|
|
@@ -6,6 +6,14 @@ $module: #{$prefix}-typography;
|
|
|
6
6
|
color: $color-typography_default-text-default;
|
|
7
7
|
@include font-size-regular;
|
|
8
8
|
|
|
9
|
+
&-text {
|
|
10
|
+
display: inline-block;
|
|
11
|
+
|
|
12
|
+
&-icon {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
&.#{$module}-secondary {
|
|
10
18
|
color: $color-typography_secondary-text-default;
|
|
11
19
|
}
|
|
@@ -45,7 +53,7 @@ $module: #{$prefix}-typography;
|
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
&-icon {
|
|
48
|
-
|
|
56
|
+
display: inline-flex;
|
|
49
57
|
margin-right: $spacing-typography_iconPrefix-marginRight;
|
|
50
58
|
vertical-align: middle;
|
|
51
59
|
color: inherit;
|
package/utils/a11y.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { get } from "lodash";
|
|
2
2
|
|
|
3
|
-
export function handlePrevent(event: any)
|
|
3
|
+
export function handlePrevent(event: any) {
|
|
4
4
|
event.stopPropagation();
|
|
5
5
|
event.preventDefault();
|
|
6
6
|
}
|
|
@@ -47,7 +47,7 @@ export function setFocusToPreviousMenuItem (itemNodes: HTMLElement[], currentIte
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// set focus to the next item in item list
|
|
50
|
-
export function
|
|
50
|
+
export function setFocusToNextMenuitem (itemNodes: HTMLElement[], currentItem: HTMLElement): void {
|
|
51
51
|
let newMenuItem: HTMLElement, index: number;
|
|
52
52
|
|
|
53
53
|
if (itemNodes.length > 0){
|