@douyinfe/semi-ui 2.15.1 → 2.16.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.
@@ -50,7 +50,9 @@ export default class Slider extends BaseComponent {
50
50
  const {
51
51
  chooseMovePos,
52
52
  isDrag,
53
- isInRenderTree
53
+ isInRenderTree,
54
+ firstDotFocusVisible,
55
+ secondDotFocusVisible
54
56
  } = this.state;
55
57
  const stylePos = vertical ? 'top' : 'left';
56
58
  const percentInfo = this.foundation.getMinAndMaxPercent(this.state.currentValue);
@@ -76,7 +78,7 @@ export default class Slider extends BaseComponent {
76
78
  currentValue
77
79
  } = this.state;
78
80
  const commonAria = {
79
- 'aria-label': ariaLabel,
81
+ 'aria-label': ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : disabled ? 'Disabled Slider' : undefined,
80
82
  'aria-labelledby': ariaLabelledby,
81
83
  'aria-disabled': disabled
82
84
  };
@@ -88,7 +90,7 @@ export default class Slider extends BaseComponent {
88
90
  position: "top",
89
91
  trigger: "custom",
90
92
  rePosKey: minPercent,
91
- visible: isInRenderTree && tipVisible.min,
93
+ visible: isInRenderTree && (tipVisible.min || firstDotFocusVisible),
92
94
  className: "".concat(cssClasses.HANDLE, "-tooltip")
93
95
  }, /*#__PURE__*/React.createElement("span", _Object$assign({
94
96
  onMouseOver: this.foundation.checkAndUpdateIsInRenderTreeState,
@@ -120,20 +122,28 @@ export default class Slider extends BaseComponent {
120
122
  onTouchEnd: e => {
121
123
  this.foundation.onHandleUp(e);
122
124
  },
123
- onFocus: e => this.foundation.onFocus(e, 'min'),
125
+ onKeyDown: e => {
126
+ this.foundation.handleKeyDown(e, 'min');
127
+ },
128
+ onFocus: e => {
129
+ this.foundation.onFocus(e, 'min');
130
+ },
131
+ onBlur: e => {
132
+ this.foundation.onBlur(e, 'min');
133
+ },
124
134
  role: "slider",
125
- tabIndex: 0
135
+ "aria-valuetext": getAriaValueText ? getAriaValueText(currentValue, 0) : ariaValueText,
136
+ tabIndex: disabled ? -1 : 0
126
137
  }, commonAria, {
127
138
  "aria-valuenow": currentValue,
128
139
  "aria-valuemax": max,
129
- "aria-valuemin": min,
130
- "aria-valuetext": getAriaValueText ? getAriaValueText(currentValue) : ariaValueText
140
+ "aria-valuemin": min
131
141
  }))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
132
142
  content: tipChildren.min,
133
143
  position: "top",
134
144
  trigger: "custom",
135
145
  rePosKey: minPercent,
136
- visible: isInRenderTree && tipVisible.min,
146
+ visible: isInRenderTree && (tipVisible.min || firstDotFocusVisible),
137
147
  className: "".concat(cssClasses.HANDLE, "-tooltip")
138
148
  }, /*#__PURE__*/React.createElement("span", _Object$assign({
139
149
  ref: this.minHanleEl,
@@ -164,12 +174,20 @@ export default class Slider extends BaseComponent {
164
174
  onTouchEnd: e => {
165
175
  this.foundation.onHandleUp(e);
166
176
  },
167
- onFocus: e => this.foundation.onFocus(e, 'min'),
177
+ onKeyDown: e => {
178
+ this.foundation.handleKeyDown(e, 'min');
179
+ },
180
+ onFocus: e => {
181
+ this.foundation.onFocus(e, 'min');
182
+ },
183
+ onBlur: e => {
184
+ this.foundation.onBlur(e, 'min');
185
+ },
168
186
  role: "slider",
169
- tabIndex: 0
187
+ tabIndex: disabled ? -1 : 0
170
188
  }, commonAria, {
189
+ "aria-valuetext": getAriaValueText ? getAriaValueText(currentValue[0], 0) : ariaValueText,
171
190
  "aria-valuenow": currentValue[0],
172
- "aria-valuetext": getAriaValueText ? getAriaValueText(currentValue[0]) : ariaValueText,
173
191
  "aria-valuemax": currentValue[1],
174
192
  "aria-valuemin": min
175
193
  }))), /*#__PURE__*/React.createElement(Tooltip, {
@@ -177,7 +195,7 @@ export default class Slider extends BaseComponent {
177
195
  position: "top",
178
196
  trigger: "custom",
179
197
  rePosKey: maxPercent,
180
- visible: isInRenderTree && tipVisible.max,
198
+ visible: isInRenderTree && (tipVisible.max || secondDotFocusVisible),
181
199
  className: "".concat(cssClasses.HANDLE, "-tooltip")
182
200
  }, /*#__PURE__*/React.createElement("span", _Object$assign({
183
201
  ref: this.maxHanleEl,
@@ -208,12 +226,20 @@ export default class Slider extends BaseComponent {
208
226
  onTouchEnd: e => {
209
227
  this.foundation.onHandleUp(e);
210
228
  },
211
- onFocus: e => this.foundation.onFocus(e, 'min'),
229
+ onKeyDown: e => {
230
+ this.foundation.handleKeyDown(e, 'max');
231
+ },
232
+ onFocus: e => {
233
+ this.foundation.onFocus(e, 'max');
234
+ },
235
+ onBlur: e => {
236
+ this.foundation.onBlur(e, 'max');
237
+ },
212
238
  role: "slider",
213
- tabIndex: 0
239
+ tabIndex: disabled ? -1 : 0
214
240
  }, commonAria, {
241
+ "aria-valuetext": getAriaValueText ? getAriaValueText(currentValue[1], 1) : ariaValueText,
215
242
  "aria-valuenow": currentValue[1],
216
- "aria-valuetext": getAriaValueText ? getAriaValueText(currentValue[1]) : ariaValueText,
217
243
  "aria-valuemax": max,
218
244
  "aria-valuemin": currentValue[0]
219
245
  }))));
@@ -314,6 +340,13 @@ export default class Slider extends BaseComponent {
314
340
  return labelContent;
315
341
  };
316
342
 
343
+ this._getAriaValueText = (value, index) => {
344
+ const {
345
+ getAriaValueText
346
+ } = this.props;
347
+ return getAriaValueText ? getAriaValueText(value, index) : value;
348
+ };
349
+
317
350
  let {
318
351
  value
319
352
  } = this.props;
@@ -334,14 +367,14 @@ export default class Slider extends BaseComponent {
334
367
  isDrag: false,
335
368
  clickValue: 0,
336
369
  showBoundary: false,
337
- isInRenderTree: true
370
+ isInRenderTree: true,
371
+ firstDotFocusVisible: false,
372
+ secondDotFocusVisible: false
338
373
  };
339
374
  this.sliderEl = /*#__PURE__*/React.createRef();
340
375
  this.minHanleEl = /*#__PURE__*/React.createRef();
341
376
  this.maxHanleEl = /*#__PURE__*/React.createRef();
342
- this.dragging = [false, false]; // this.chooseMovePos = 'min';
343
- // this.isDrag = false;
344
-
377
+ this.dragging = [false, false];
345
378
  this.foundation = new SliderFoundation(this.adapter);
346
379
  this.eventListenerSet = new _Set();
347
380
  }
@@ -408,8 +441,7 @@ export default class Slider extends BaseComponent {
408
441
  return flag;
409
442
  },
410
443
  getOverallVars: () => ({
411
- dragging: this.dragging,
412
- chooseMovePos: this.chooseMovePos
444
+ dragging: this.dragging
413
445
  }),
414
446
  updateDisabled: disabled => {
415
447
  this.setState({
@@ -443,9 +475,6 @@ export default class Slider extends BaseComponent {
443
475
  getMinHandleEl: () => this.minHanleEl,
444
476
  getMaxHandleEl: () => this.maxHanleEl,
445
477
  onHandleDown: e => {
446
- e.stopPropagation();
447
- e.preventDefault();
448
-
449
478
  this._addEventListener(document.body, 'mousemove', this.foundation.onHandleMove, false);
450
479
 
451
480
  this._addEventListener(document.body, 'mouseup', this.foundation.onHandleUp, false);
@@ -568,37 +597,55 @@ export default class Slider extends BaseComponent {
568
597
  }
569
598
 
570
599
  render() {
600
+ var _context5;
601
+
602
+ const {
603
+ disabled,
604
+ currentValue,
605
+ min,
606
+ max
607
+ } = this.state;
608
+ const {
609
+ vertical,
610
+ verticalReverse,
611
+ style,
612
+ railStyle,
613
+ range,
614
+ className
615
+ } = this.props;
571
616
  const wrapperClass = cls("".concat(prefixCls, "-wrapper"), {
572
- ["".concat(prefixCls, "-disabled")]: this.state.disabled,
573
- ["".concat(cssClasses.VERTICAL, "-wrapper")]: this.props.vertical,
574
- ["".concat(prefixCls, "-reverse")]: this.props.vertical && this.props.verticalReverse
575
- }, this.props.className);
617
+ ["".concat(prefixCls, "-disabled")]: disabled,
618
+ ["".concat(cssClasses.VERTICAL, "-wrapper")]: vertical,
619
+ ["".concat(prefixCls, "-reverse")]: vertical && verticalReverse
620
+ }, className);
576
621
  const boundaryClass = cls("".concat(prefixCls, "-boundary"), {
577
622
  ["".concat(prefixCls, "-boundary-show")]: this.props.showBoundary && this.state.showBoundary
578
623
  });
579
624
  const sliderCls = cls({
580
- ["".concat(prefixCls)]: !this.props.vertical,
581
- [cssClasses.VERTICAL]: this.props.vertical
625
+ ["".concat(prefixCls)]: !vertical,
626
+ [cssClasses.VERTICAL]: vertical
582
627
  });
628
+ const ariaLabel = range ? _concatInstanceProperty(_context5 = "Range: ".concat(this._getAriaValueText(currentValue[0], 0), " to ")).call(_context5, this._getAriaValueText(currentValue[1], 1)) : undefined;
583
629
  const slider = /*#__PURE__*/React.createElement("div", {
584
630
  className: wrapperClass,
585
- style: this.props.style,
631
+ style: style,
586
632
  ref: this.sliderEl,
633
+ "aria-label": ariaLabel,
587
634
  onMouseEnter: () => this.foundation.handleWrapperEnter(),
588
635
  onMouseLeave: () => this.foundation.handleWrapperLeave()
589
636
  }, /*#__PURE__*/React.createElement("div", {
590
637
  className: "".concat(prefixCls, "-rail"),
591
638
  onClick: this.foundation.handleWrapClick,
592
- style: this.props.railStyle
639
+ style: railStyle
593
640
  }), this.renderTrack(), this.renderStepDot(), /*#__PURE__*/React.createElement("div", null, this.renderHandle()), this.renderLabel(), /*#__PURE__*/React.createElement("div", {
594
641
  className: boundaryClass
595
642
  }, /*#__PURE__*/React.createElement("span", {
596
643
  className: "".concat(prefixCls, "-boundary-min")
597
- }, this.state.min), /*#__PURE__*/React.createElement("span", {
644
+ }, min), /*#__PURE__*/React.createElement("span", {
598
645
  className: "".concat(prefixCls, "-boundary-max")
599
- }, this.state.max)));
646
+ }, max)));
600
647
 
601
- if (!this.props.vertical) {
648
+ if (!vertical) {
602
649
  return /*#__PURE__*/React.createElement("div", {
603
650
  className: sliderCls
604
651
  }, slider);
@@ -651,7 +698,8 @@ Slider.propTypes = {
651
698
  className: PropTypes.string,
652
699
  showBoundary: PropTypes.bool,
653
700
  railStyle: PropTypes.object,
654
- verticalReverse: PropTypes.bool
701
+ verticalReverse: PropTypes.bool,
702
+ getAriaValueText: PropTypes.func
655
703
  };
656
704
  Slider.defaultProps = {
657
705
  // allowClear: false,
@@ -63,6 +63,11 @@ export interface ResolvedDataItem extends DataItem {
63
63
  };
64
64
  _optionKey?: string | number;
65
65
  }
66
+ export interface DraggableResolvedDataItem {
67
+ key?: string | number;
68
+ index?: number;
69
+ item?: ResolvedDataItem;
70
+ }
66
71
  export declare type DataSource = Array<DataItem> | Array<GroupItem> | Array<TreeItem>;
67
72
  interface HeaderConfig {
68
73
  totalContent: string;
@@ -419,16 +419,8 @@ class Transfer extends BaseComponent {
419
419
  type,
420
420
  showPath
421
421
  } = this.props;
422
- let newItem = item;
423
422
 
424
- if (draggable) {
425
- newItem = _Object$assign(_Object$assign({}, item), {
426
- key: item._optionKey
427
- });
428
- delete newItem._optionKey;
429
- }
430
-
431
- const onRemove = () => this.foundation.handleSelectOrRemove(newItem);
423
+ const onRemove = () => this.foundation.handleSelectOrRemove(item);
432
424
 
433
425
  const rightItemCls = cls({
434
426
  ["".concat(prefixcls, "-item")]: true,
@@ -456,7 +448,7 @@ class Transfer extends BaseComponent {
456
448
  React.createElement("div", {
457
449
  role: "listitem",
458
450
  className: rightItemCls,
459
- key: newItem.key
451
+ key: item.key
460
452
  }, draggable ? /*#__PURE__*/React.createElement(DragHandle, null) : null, /*#__PURE__*/React.createElement("div", {
461
453
  className: "".concat(prefixcls, "-right-item-text")
462
454
  }, label), /*#__PURE__*/React.createElement(IconClose, {
@@ -483,7 +475,7 @@ class Transfer extends BaseComponent {
483
475
 
484
476
  renderRightSortableList(selectedData) {
485
477
  // when choose some items && draggable is true
486
- const SortableItem = SortableElement(item => this.renderRightItem(item));
478
+ const SortableItem = SortableElement(props => this.renderRightItem(props.item));
487
479
  const SortableList = SortableContainer(_ref => {
488
480
  let {
489
481
  items
@@ -494,14 +486,12 @@ class Transfer extends BaseComponent {
494
486
  "aria-label": "Selected list"
495
487
  }, _mapInstanceProperty(items).call(items, (item, index) =>
496
488
  /*#__PURE__*/
497
- // sortableElement will take over the property 'key', so use another '_optionKey' to pass
498
489
  // @ts-ignore skip SortableItem type check
499
- React.createElement(SortableItem, _Object$assign({
490
+ React.createElement(SortableItem, {
500
491
  key: item.label,
501
- index: index
502
- }, item, {
503
- _optionKey: item.key
504
- })))) // eslint-disable-next-line @typescript-eslint/ban-ts-comment
492
+ index: index,
493
+ item: item
494
+ }))) // eslint-disable-next-line @typescript-eslint/ban-ts-comment
505
495
  // @ts-ignore see reasons: https://github.com/clauderic/react-sortable-hoc/issues/206
506
496
  ;
507
497
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.15.1",
3
+ "version": "2.16.0",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -15,18 +15,18 @@
15
15
  "dependencies": {
16
16
  "@babel/runtime-corejs3": "^7.15.4",
17
17
  "@douyinfe/semi-animation": "2.12.0",
18
- "@douyinfe/semi-animation-react": "2.15.1",
19
- "@douyinfe/semi-foundation": "2.15.1",
20
- "@douyinfe/semi-icons": "2.15.1",
18
+ "@douyinfe/semi-animation-react": "2.16.0",
19
+ "@douyinfe/semi-foundation": "2.16.0",
20
+ "@douyinfe/semi-icons": "2.16.0",
21
21
  "@douyinfe/semi-illustrations": "2.15.0",
22
- "@douyinfe/semi-theme-default": "2.15.1",
23
- "@types/react-window": "^1.8.2",
22
+ "@douyinfe/semi-theme-default": "2.16.0",
24
23
  "async-validator": "^3.5.0",
25
24
  "classnames": "^2.2.6",
26
25
  "copy-text-to-clipboard": "^2.1.1",
27
26
  "date-fns": "^2.9.0",
28
27
  "date-fns-tz": "^1.0.10",
29
28
  "lodash": "^4.17.21",
29
+ "prop-types": "^15.7.2",
30
30
  "react-resizable": "^1.8.0",
31
31
  "react-sortable-hoc": "^2.0.0",
32
32
  "react-window": "^1.8.2",
@@ -35,9 +35,6 @@
35
35
  "utility-types": "^3.10.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "@types/react": ">=16.0.0",
39
- "@types/react-dom": ">=16.0.0",
40
- "prop-types": "15.7.2",
41
38
  "react": ">=16.0.0",
42
39
  "react-dom": ">=16.0.0"
43
40
  },
@@ -69,15 +66,18 @@
69
66
  ],
70
67
  "author": "",
71
68
  "license": "MIT",
72
- "gitHead": "c17dbc08573d010f8ecfe60834412acd9e7ca154",
69
+ "gitHead": "71f3e6a9ae6f7794c993617dd3d94f565539ac49",
73
70
  "devDependencies": {
74
71
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
72
  "@babel/plugin-transform-runtime": "^7.15.8",
76
73
  "@babel/preset-env": "^7.15.8",
77
74
  "@babel/preset-react": "^7.14.5",
78
- "@douyinfe/semi-scss-compile": "2.15.1",
75
+ "@douyinfe/semi-scss-compile": "2.16.0",
79
76
  "@storybook/addon-knobs": "^6.3.1",
80
77
  "@types/lodash": "^4.14.176",
78
+ "@types/react": ">=16.0.0",
79
+ "@types/react-dom": ">=16.0.0",
80
+ "@types/react-window": "^1.8.2",
81
81
  "babel-loader": "^8.2.2",
82
82
  "babel-plugin-lodash": "^3.3.4",
83
83
  "case-sensitive-paths-webpack-plugin": "^2.4.0",
@@ -81,7 +81,7 @@ function CustomRender(props) {
81
81
  name: '夏可漫',
82
82
  email: 'xiakeman@example.com',
83
83
  avatar:
84
- 'https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/avatarDemo.jpeg',
84
+ 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/dy.png',
85
85
  },
86
86
  {
87
87
  name: '申悦',
@@ -113,7 +113,8 @@ export const HorizontalSlider = () => (
113
113
  <div style={divStyle}>
114
114
  <div>marks</div>
115
115
  <Slider
116
- marks={{ 20: '20c', 40: '40c' }}
116
+ marks={{ 20: '20°C', 40: '40°C' }}
117
+ getAriaValueText={(value) => `${value}°C`}
117
118
  defaultValue={[0, 100]}
118
119
  range={true}
119
120
  onChange={value => {
@@ -124,7 +125,8 @@ export const HorizontalSlider = () => (
124
125
  <div style={divStyle}>
125
126
  <div>inclued</div>
126
127
  <Slider
127
- marks={{ 20: '20c', 40: '40c' }}
128
+ marks={{ 20: '20°C', 40: '40°C' }}
129
+ getAriaValueText={(value) => `${value}°C`}
128
130
  included={false}
129
131
  defaultValue={[0, 100]}
130
132
  range={true}
package/slider/index.tsx CHANGED
@@ -51,6 +51,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
51
51
  showBoundary: PropTypes.bool,
52
52
  railStyle: PropTypes.object,
53
53
  verticalReverse: PropTypes.bool,
54
+ getAriaValueText: PropTypes.func,
54
55
  } as any;
55
56
 
56
57
  static defaultProps: Partial<SliderProps> = {
@@ -77,7 +78,6 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
77
78
  private maxHanleEl: React.RefObject<HTMLDivElement>;
78
79
  private dragging: boolean[];
79
80
  private eventListenerSet: Set<() => void>;
80
- private chooseMovePos: 'min' | 'max';
81
81
  foundation: SliderFoundation;
82
82
 
83
83
  constructor(props: SliderProps) {
@@ -98,14 +98,14 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
98
98
  isDrag: false,
99
99
  clickValue: 0,
100
100
  showBoundary: false,
101
- isInRenderTree: true
101
+ isInRenderTree: true,
102
+ firstDotFocusVisible: false,
103
+ secondDotFocusVisible: false,
102
104
  };
103
105
  this.sliderEl = React.createRef();
104
106
  this.minHanleEl = React.createRef();
105
107
  this.maxHanleEl = React.createRef();
106
108
  this.dragging = [false, false];
107
- // this.chooseMovePos = 'min';
108
- // this.isDrag = false;
109
109
  this.foundation = new SliderFoundation(this.adapter);
110
110
  this.eventListenerSet = new Set();
111
111
  }
@@ -165,7 +165,6 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
165
165
  },
166
166
  getOverallVars: () => ({
167
167
  dragging: this.dragging,
168
- chooseMovePos: this.chooseMovePos,
169
168
  }),
170
169
  updateDisabled: (disabled: boolean) => {
171
170
  this.setState({ disabled });
@@ -189,8 +188,6 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
189
188
  getMinHandleEl: () => this.minHanleEl,
190
189
  getMaxHandleEl: () => this.maxHanleEl,
191
190
  onHandleDown: (e: React.MouseEvent) => {
192
- e.stopPropagation();
193
- e.preventDefault();
194
191
  this._addEventListener(document.body, 'mousemove', this.foundation.onHandleMove, false);
195
192
  this._addEventListener(document.body, 'mouseup', this.foundation.onHandleUp, false);
196
193
  this._addEventListener(document.body, 'touchmove', this.foundation.onHandleTouchMove, false);
@@ -287,7 +284,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
287
284
 
288
285
  renderHandle = () => {
289
286
  const { vertical, range, tooltipVisible, tipFormatter, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, 'aria-valuetext': ariaValueText, getAriaValueText, disabled } = this.props;
290
- const { chooseMovePos, isDrag, isInRenderTree } = this.state;
287
+ const { chooseMovePos, isDrag, isInRenderTree, firstDotFocusVisible, secondDotFocusVisible } = this.state;
291
288
  const stylePos = vertical ? 'top' : 'left';
292
289
  const percentInfo = this.foundation.getMinAndMaxPercent(this.state.currentValue);
293
290
  const minPercent = percentInfo.min;
@@ -307,7 +304,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
307
304
  const { min, max, currentValue } = this.state;
308
305
 
309
306
  const commonAria = {
310
- 'aria-label': ariaLabel,
307
+ 'aria-label': ariaLabel ?? (disabled ? 'Disabled Slider' : undefined),
311
308
  'aria-labelledby': ariaLabelledby,
312
309
  'aria-disabled': disabled
313
310
  };
@@ -319,7 +316,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
319
316
  position="top"
320
317
  trigger="custom"
321
318
  rePosKey={minPercent}
322
- visible={isInRenderTree && tipVisible.min}
319
+ visible={isInRenderTree && (tipVisible.min || firstDotFocusVisible)}
323
320
  className={`${cssClasses.HANDLE}-tooltip`}
324
321
  >
325
322
  <span
@@ -352,24 +349,32 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
352
349
  onTouchEnd={e => {
353
350
  this.foundation.onHandleUp(e);
354
351
  }}
355
- onFocus={e => this.foundation.onFocus(e, 'min')}
352
+ onKeyDown={(e)=>{
353
+ this.foundation.handleKeyDown(e, 'min');
354
+ }}
355
+ onFocus={e => {
356
+ this.foundation.onFocus(e, 'min');
357
+ }}
358
+ onBlur={(e) => {
359
+ this.foundation.onBlur(e, 'min');
360
+ }}
356
361
  role="slider"
357
- tabIndex={0}
362
+ aria-valuetext={getAriaValueText ? getAriaValueText(currentValue as number, 0) : ariaValueText}
363
+ tabIndex={disabled ? -1 : 0}
358
364
  {...commonAria}
359
365
  aria-valuenow={currentValue as number}
360
366
  aria-valuemax={max}
361
367
  aria-valuemin={min}
362
- aria-valuetext={getAriaValueText ? getAriaValueText(currentValue as number) : ariaValueText}
363
368
  />
364
369
  </Tooltip>
365
370
  ) : (
366
371
  <React.Fragment>
367
- <Tooltip
372
+ <Tooltip
368
373
  content={tipChildren.min}
369
374
  position="top"
370
375
  trigger="custom"
371
376
  rePosKey={minPercent}
372
- visible={isInRenderTree && tipVisible.min}
377
+ visible={isInRenderTree && (tipVisible.min || firstDotFocusVisible)}
373
378
  className={`${cssClasses.HANDLE}-tooltip`}
374
379
  >
375
380
  <span
@@ -401,12 +406,20 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
401
406
  onTouchEnd={e => {
402
407
  this.foundation.onHandleUp(e);
403
408
  }}
404
- onFocus={e => this.foundation.onFocus(e, 'min')}
409
+ onKeyDown={(e)=>{
410
+ this.foundation.handleKeyDown(e, 'min');
411
+ }}
412
+ onFocus={e => {
413
+ this.foundation.onFocus(e, 'min');
414
+ }}
415
+ onBlur={(e) => {
416
+ this.foundation.onBlur(e, 'min');
417
+ }}
405
418
  role="slider"
406
- tabIndex={0}
419
+ tabIndex={disabled ? -1 : 0}
407
420
  {...commonAria}
421
+ aria-valuetext={getAriaValueText ? getAriaValueText(currentValue[0], 0) : ariaValueText}
408
422
  aria-valuenow={currentValue[0]}
409
- aria-valuetext={getAriaValueText ? getAriaValueText(currentValue[0]) : ariaValueText}
410
423
  aria-valuemax={currentValue[1]}
411
424
  aria-valuemin={min}
412
425
  />
@@ -416,7 +429,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
416
429
  position="top"
417
430
  trigger="custom"
418
431
  rePosKey={maxPercent}
419
- visible={isInRenderTree && tipVisible.max}
432
+ visible={isInRenderTree && (tipVisible.max || secondDotFocusVisible)}
420
433
  className={`${cssClasses.HANDLE}-tooltip`}
421
434
  >
422
435
  <span
@@ -448,12 +461,20 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
448
461
  onTouchEnd={e => {
449
462
  this.foundation.onHandleUp(e);
450
463
  }}
451
- onFocus={e => this.foundation.onFocus(e, 'min')}
464
+ onKeyDown={e =>{
465
+ this.foundation.handleKeyDown(e, 'max');
466
+ }}
467
+ onFocus={e => {
468
+ this.foundation.onFocus(e, 'max');
469
+ }}
470
+ onBlur={(e) => {
471
+ this.foundation.onBlur(e, 'max');
472
+ }}
452
473
  role="slider"
453
- tabIndex={0}
474
+ tabIndex={disabled ? -1 : 0}
454
475
  {...commonAria}
476
+ aria-valuetext={getAriaValueText ? getAriaValueText(currentValue[1], 1) : ariaValueText}
455
477
  aria-valuenow={currentValue[1]}
456
- aria-valuetext={getAriaValueText ? getAriaValueText(currentValue[1]) : ariaValueText}
457
478
  aria-valuemax={max}
458
479
  aria-valuemin={currentValue[0]}
459
480
  />
@@ -538,29 +559,38 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
538
559
  return labelContent;
539
560
  };
540
561
 
562
+ _getAriaValueText = (value: number, index?: number) => {
563
+ const { getAriaValueText } = this.props;
564
+ return getAriaValueText ? getAriaValueText(value, index) : value;
565
+ }
566
+
541
567
 
542
568
  render() {
569
+ const { disabled, currentValue, min, max } = this.state;
570
+ const { vertical, verticalReverse, style, railStyle, range, className } = this.props;
543
571
  const wrapperClass = cls(
544
572
  `${prefixCls}-wrapper`,
545
573
  {
546
- [`${prefixCls}-disabled`]: this.state.disabled,
547
- [`${cssClasses.VERTICAL}-wrapper`]: this.props.vertical,
548
- [`${prefixCls}-reverse`]: this.props.vertical && this.props.verticalReverse
574
+ [`${prefixCls}-disabled`]: disabled,
575
+ [`${cssClasses.VERTICAL}-wrapper`]: vertical,
576
+ [`${prefixCls}-reverse`]: vertical && verticalReverse
549
577
  },
550
- this.props.className
578
+ className
551
579
  );
552
580
  const boundaryClass = cls(`${prefixCls}-boundary`, {
553
581
  [`${prefixCls}-boundary-show`]: this.props.showBoundary && this.state.showBoundary,
554
582
  });
555
583
  const sliderCls = cls({
556
- [`${prefixCls}`]: !this.props.vertical,
557
- [cssClasses.VERTICAL]: this.props.vertical,
584
+ [`${prefixCls}`]: !vertical,
585
+ [cssClasses.VERTICAL]: vertical,
558
586
  });
587
+ const ariaLabel = range ? `Range: ${this._getAriaValueText(currentValue[0], 0)} to ${this._getAriaValueText(currentValue[1], 1)}` : undefined;
559
588
  const slider = (
560
589
  <div
561
590
  className={wrapperClass}
562
- style={this.props.style}
591
+ style={style}
563
592
  ref={this.sliderEl}
593
+ aria-label={ariaLabel}
564
594
  onMouseEnter={() => this.foundation.handleWrapperEnter()}
565
595
  onMouseLeave={() => this.foundation.handleWrapperLeave()}
566
596
  >
@@ -568,7 +598,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
568
598
  <div
569
599
  className={`${prefixCls}-rail`}
570
600
  onClick={this.foundation.handleWrapClick}
571
- style={this.props.railStyle}
601
+ style={railStyle}
572
602
  />
573
603
  }
574
604
  {this.renderTrack()}
@@ -576,12 +606,12 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
576
606
  <div>{this.renderHandle()}</div>
577
607
  {this.renderLabel()}
578
608
  <div className={boundaryClass}>
579
- <span className={`${prefixCls}-boundary-min`}>{this.state.min}</span>
580
- <span className={`${prefixCls}-boundary-max`}>{this.state.max}</span>
609
+ <span className={`${prefixCls}-boundary-min`}>{min}</span>
610
+ <span className={`${prefixCls}-boundary-max`}>{max}</span>
581
611
  </div>
582
612
  </div>
583
613
  );
584
- if (!this.props.vertical) {
614
+ if (!vertical) {
585
615
  return <div className={sliderCls}>{slider}</div>;
586
616
  }
587
617
  return slider;