Skip to content

Commit 683a818

Browse files
authored
Allow Range prop step to be null in Typescript (#757)
This is the same like #691 where it was fixed for `Slider` but `Range` seems to have been forgotten. Fixes #739 #652 #574
1 parent b959281 commit 683a818

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/Range.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import classNames from 'classnames';
33
import Track from './common/Track';
44
import createSlider from './common/createSlider';
55
import * as utils from './utils';
6-
import { SliderProps } from './Slider';
7-
import { GenericSliderProps, GenericSliderState } from './interface';
6+
import type { SliderProps } from './Slider';
7+
import type { GenericSliderProps, GenericSliderState } from './interface';
88

99
const trimAlignValue = ({
1010
value,
@@ -46,7 +46,7 @@ export interface RangeProps extends GenericSliderProps {
4646
reverse?: boolean;
4747
vertical?: boolean;
4848
marks?: Record<number, React.ReactNode | { style?: React.CSSProperties; label?: string }>;
49-
step?: number;
49+
step?: number | null;
5050
threshold?: number;
5151
prefixCls?: string;
5252
included?: boolean;
@@ -182,8 +182,8 @@ class Range extends React.Component<RangeProps, RangeState> {
182182
return;
183183
}
184184
const currentValue = value || prevState.bounds;
185-
if (currentValue.some(v => utils.isValueOutOfRange(v, this.props))) {
186-
const newValues = currentValue.map(v => utils.ensureValueInRange(v, this.props));
185+
if (currentValue.some((v) => utils.isValueOutOfRange(v, this.props))) {
186+
const newValues = currentValue.map((v) => utils.ensureValueInRange(v, this.props));
187187
onChange(newValues);
188188
}
189189
}
@@ -196,7 +196,7 @@ class Range extends React.Component<RangeProps, RangeState> {
196196
} else {
197197
const controlledState = {};
198198

199-
['handle', 'recent'].forEach(item => {
199+
['handle', 'recent'].forEach((item) => {
200200
if (state[item] !== undefined) {
201201
controlledState[item] = state[item];
202202
}
@@ -277,10 +277,10 @@ class Range extends React.Component<RangeProps, RangeState> {
277277
const max = maxValue - Math.max(...startBounds);
278278
const min = minValue - Math.min(...startBounds);
279279
const ratio = Math.min(Math.max(pos / (this.getSliderLength() / 100), min), max);
280-
const nextBounds = startBounds.map(v =>
280+
const nextBounds = startBounds.map((v) =>
281281
Math.floor(Math.max(Math.min(v + ratio, maxValue), minValue)),
282282
);
283-
if (state.bounds.map((c, i) => c === nextBounds[i]).some(c => !c)) {
283+
if (state.bounds.map((c, i) => c === nextBounds[i]).some((c) => !c)) {
284284
this.onChange({
285285
bounds: nextBounds,
286286
});
@@ -504,7 +504,7 @@ class Range extends React.Component<RangeProps, RangeState> {
504504
ariaValueTextFormatterGroupForHandles,
505505
} = this.props;
506506

507-
const offsets = bounds.map(v => this.calcOffset(v));
507+
const offsets = bounds.map((v) => this.calcOffset(v));
508508

509509
const handleClassName = `${prefixCls}-handle`;
510510
const handles = bounds.map((v, i) => {
@@ -531,7 +531,7 @@ class Range extends React.Component<RangeProps, RangeState> {
531531
reverse,
532532
disabled,
533533
style: handleStyle[i],
534-
ref: h => this.saveHandle(i, h),
534+
ref: (h) => this.saveHandle(i, h),
535535
ariaLabel: ariaLabelGroupForHandles[i],
536536
ariaLabelledBy: ariaLabelledByGroupForHandles[i],
537537
ariaValueTextFormatter: ariaValueTextFormatterGroupForHandles[i],

0 commit comments

Comments
 (0)