Skip to content

Commit 5bf3745

Browse files
authored
chore(deps-dev): bump @types/react from 17.0.62 to 18.2.15 (#962)
* chore(deps-dev): bump @types/react from 17.0.62 to 18.2.15 * fix: fix * add test case
1 parent e4c841b commit 5bf3745

26 files changed

+225
-195
lines changed

docs/examples/components/TooltipSlider.tsx

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
import * as React from 'react';
2-
import 'rc-tooltip/assets/bootstrap.css';
3-
import Slider from 'rc-slider';
41
import type { SliderProps } from 'rc-slider';
5-
import raf from 'rc-util/lib/raf';
2+
import Slider from 'rc-slider';
3+
import type { TooltipRef } from 'rc-tooltip';
64
import Tooltip from 'rc-tooltip';
5+
import 'rc-tooltip/assets/bootstrap.css';
6+
import raf from 'rc-util/lib/raf';
7+
import * as React from 'react';
78

8-
const HandleTooltip = (props: {
9+
interface HandleTooltipProps {
910
value: number;
1011
children: React.ReactElement;
1112
visible: boolean;
1213
tipFormatter?: (value: number) => React.ReactNode;
13-
}) => {
14+
}
15+
16+
const HandleTooltip: React.FC<HandleTooltipProps> = (props) => {
1417
const { value, children, visible, tipFormatter = (val) => `${val} %`, ...restProps } = props;
1518

16-
const tooltipRef = React.useRef<any>();
19+
const tooltipRef = React.useRef<TooltipRef>();
1720
const rafRef = React.useRef<number | null>(null);
1821

1922
function cancelKeepAlign() {
@@ -50,31 +53,28 @@ const HandleTooltip = (props: {
5053
);
5154
};
5255

53-
export const handleRender: SliderProps['handleRender'] = (node, props) => {
54-
return (
55-
<HandleTooltip value={props.value} visible={props.dragging}>
56+
export const handleRender: SliderProps['handleRender'] = (node, props) => (
57+
<HandleTooltip value={props.value} visible={props.dragging}>
58+
{node}
59+
</HandleTooltip>
60+
);
61+
62+
interface TooltipSliderProps extends SliderProps {
63+
tipFormatter?: (value: number) => React.ReactNode;
64+
tipProps?: any;
65+
}
66+
67+
const TooltipSlider: React.FC<TooltipSliderProps> = ({ tipFormatter, tipProps, ...props }) => {
68+
const tipHandleRender: SliderProps['handleRender'] = (node, handleProps) => (
69+
<HandleTooltip
70+
value={handleProps.value}
71+
visible={handleProps.dragging}
72+
tipFormatter={tipFormatter}
73+
{...tipProps}
74+
>
5675
{node}
5776
</HandleTooltip>
5877
);
59-
};
60-
61-
const TooltipSlider = ({
62-
tipFormatter,
63-
tipProps,
64-
...props
65-
}: SliderProps & { tipFormatter?: (value: number) => React.ReactNode; tipProps: any }) => {
66-
const tipHandleRender: SliderProps['handleRender'] = (node, handleProps) => {
67-
return (
68-
<HandleTooltip
69-
value={handleProps.value}
70-
visible={handleProps.dragging}
71-
tipFormatter={tipFormatter}
72-
{...tipProps}
73-
>
74-
{node}
75-
</HandleTooltip>
76-
);
77-
};
7878

7979
return <Slider {...props} handleRender={tipHandleRender} />;
8080
};

docs/examples/debug.tsx

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
import React from 'react';
21
import Slider from 'rc-slider';
2+
import React from 'react';
33
import '../../assets/index.less';
44

55
export default () => {
66
const [disabled, setDisabled] = React.useState(false);
77
const [range, setRange] = React.useState(false);
88
const [reverse, setReverse] = React.useState(false);
99
const [vertical, setVertical] = React.useState(false);
10-
const [value, setValue] = React.useState(30);
1110

1211
return (
13-
<div
14-
style={{
15-
transform: 'scale(1.5)',
16-
transformOrigin: 'top left',
17-
}}
18-
>
12+
<div style={{ transform: 'scale(1.5)', transformOrigin: 'top left' }}>
1913
<div>
2014
<label>
2115
<input type="checkbox" checked={disabled} onChange={() => setDisabled(!disabled)} />
@@ -37,26 +31,12 @@ export default () => {
3731

3832
<div style={{ height: 300, width: 600 }}>
3933
<Slider
40-
// count={2}
41-
// disabled={disabled}
42-
// reverse={reverse}
43-
// vertical={vertical}
44-
// range={range}
45-
// defaultValue={[30, 50]}
46-
// dots
47-
// step={5}
48-
// draggableTrack
49-
// pushable={5}
50-
// allowCross={false}
5134
onChange={(nextValues) => {
5235
console.log('Change:', nextValues);
53-
// setValue(nextValues as any);
5436
}}
5537
onChangeComplete={(v) => {
5638
console.log('AfterChange:', v);
5739
}}
58-
// value={value}
59-
6040
min={0}
6141
max={1}
6242
defaultValue={0.81}

docs/examples/handle.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import React from 'react';
21
import Slider from 'rc-slider';
2+
import React from 'react';
33
import '../../assets/index.less';
44
import TooltipSlider, { handleRender } from './components/TooltipSlider';
55

6-
const wrapperStyle = { width: 400, margin: 50 };
6+
const wrapperStyle: React.CSSProperties = {
7+
width: 400,
8+
margin: 50,
9+
};
710

811
export default () => (
912
<div>

docs/examples/marks.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
import React from 'react';
21
import Slider from 'rc-slider';
2+
import React from 'react';
33
import '../../assets/index.less';
44

5-
const style = { width: 400, margin: 50 };
5+
const style: React.CSSProperties = {
6+
width: 400,
7+
margin: 50,
8+
};
9+
610
const marks = {
711
'-10': '-10°C',
812
0: <strong>0°C</strong>,
@@ -25,7 +29,14 @@ export default () => (
2529
<div>
2630
<div style={style}>
2731
<p>Slider with marks, `step=null`</p>
28-
<Slider min={-10} marks={marks} step={null} onChange={log} defaultValue={20} onChangeComplete={(v) => console.log('AfterChange:', v)} />
32+
<Slider
33+
min={-10}
34+
marks={marks}
35+
step={null}
36+
onChange={log}
37+
defaultValue={20}
38+
onChangeComplete={(v) => console.log('AfterChange:', v)}
39+
/>
2940
</div>
3041

3142
<div style={style}>

docs/examples/multiple.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import Slider from 'rc-slider';
33
import React from 'react';
44
import '../../assets/index.less';
55

6-
const style = { width: 400, margin: 50 };
6+
const style: React.CSSProperties = {
7+
width: 400,
8+
margin: 50,
9+
};
710

811
function log(value) {
912
console.log(value);

docs/examples/range.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
/* eslint react/no-multi-comp: 0, no-console: 0 */
2-
import React from 'react';
32
import Slider from 'rc-slider';
3+
import React from 'react';
44
import '../../assets/index.less';
55

6-
const style = { width: 400, margin: 50 };
6+
const style: React.CSSProperties = {
7+
width: 400,
8+
margin: 50,
9+
};
710

811
function log(value) {
912
console.log(value); //eslint-disable-line

docs/examples/slider.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
/* eslint react/no-multi-comp: 0, max-len: 0 */
2-
import React from 'react';
32
import Slider from 'rc-slider';
3+
import React from 'react';
44
import '../../assets/index.less';
55
import TooltipSlider from './components/TooltipSlider';
66

7-
const style = { width: 600, margin: 50 };
7+
const style: React.CSSProperties = {
8+
width: 600,
9+
margin: 50,
10+
};
811

912
function log(value) {
1013
console.log(value); //eslint-disable-line

docs/examples/vertical.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from 'react';
21
import Slider from 'rc-slider';
2+
import React from 'react';
33
import '../../assets/index.less';
44

55
const style: React.CSSProperties = {
@@ -9,7 +9,10 @@ const style: React.CSSProperties = {
99
marginBottom: 160,
1010
marginLeft: 50,
1111
};
12-
const parentStyle = { overflow: 'hidden' };
12+
13+
const parentStyle: React.CSSProperties = {
14+
overflow: 'hidden',
15+
};
1316

1417
const marks = {
1518
'-10': '-10°C',

package.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
"name": "rc-slider",
33
"version": "10.5.0",
44
"description": "Slider UI component for React",
5-
"engines": {
6-
"node": ">=8.x"
7-
},
85
"keywords": [
96
"react",
107
"react-component",
@@ -14,38 +11,34 @@
1411
"range"
1512
],
1613
"homepage": "http://github.com/react-component/slider/",
14+
"bugs": {
15+
"url": "http://github.com/react-component/slider/issues"
16+
},
1717
"repository": {
1818
"type": "git",
1919
"url": "[email protected]:react-component/slider.git"
2020
},
21-
"bugs": {
22-
"url": "http://github.com/react-component/slider/issues"
23-
},
21+
"license": "MIT",
22+
"main": "./lib/index",
23+
"module": "./es/index",
24+
"types": "./lib/index.d.ts",
25+
"style": "./assets/index.css",
2426
"files": [
2527
"assets/*.css",
2628
"lib",
2729
"es"
2830
],
29-
"license": "MIT",
30-
"main": "./lib/index",
31-
"module": "./es/index",
32-
"style": "./assets/index.css",
33-
"types": "./lib/index.d.ts",
3431
"scripts": {
35-
"start": "dumi dev",
32+
"compile": "father build && lessc assets/index.less assets/index.css",
33+
"coverage": "rc-test --coverage",
3634
"docs:build": "dumi build",
3735
"docs:deploy": "gh-pages -d .doc",
38-
"compile": "father build && lessc assets/index.less assets/index.css",
39-
"prepublishOnly": "npm run compile && np --yolo --no-publish",
4036
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
37+
"now-build": "npm run docs:build",
38+
"prepublishOnly": "npm run compile && np --yolo --no-publish",
4139
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
42-
"test": "rc-test",
43-
"coverage": "rc-test --coverage",
44-
"now-build": "npm run docs:build"
45-
},
46-
"peerDependencies": {
47-
"react": ">=16.9.0",
48-
"react-dom": ">=16.9.0"
40+
"start": "dumi dev",
41+
"test": "rc-test"
4942
},
5043
"dependencies": {
5144
"@babel/runtime": "^7.10.1",
@@ -58,14 +51,14 @@
5851
"@testing-library/react": "^12.1.3",
5952
"@types/classnames": "^2.2.9",
6053
"@types/jest": "^29.5.1",
61-
"@types/react": "^17.0.15",
54+
"@types/react": "^18.2.42",
6255
"@types/react-dom": "^18.0.11",
6356
"@umijs/fabric": "^4.0.1",
6457
"cross-env": "^7.0.0",
58+
"dumi": "^2.2.10",
6559
"eslint": "^8.54.0",
6660
"eslint-plugin-jest": "^27.6.0",
6761
"eslint-plugin-unicorn": "^49.0.0",
68-
"dumi": "^2.2.10",
6962
"father": "^4.3.5",
7063
"father-build": "^1.18.6",
7164
"gh-pages": "^6.1.0",
@@ -79,5 +72,12 @@
7972
"react-dom": "^16.0.0",
8073
"regenerator-runtime": "^0.14.0",
8174
"typescript": "^5.1.6"
75+
},
76+
"peerDependencies": {
77+
"react": ">=16.9.0",
78+
"react-dom": ">=16.9.0"
79+
},
80+
"engines": {
81+
"node": ">=8.x"
8282
}
8383
}

src/Handles/Handle.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface HandleProps {
2626
onChangeComplete?: () => void;
2727
}
2828

29-
const Handle = React.forwardRef((props: HandleProps, ref: React.Ref<HTMLDivElement>) => {
29+
const Handle = React.forwardRef<HTMLDivElement, HandleProps>((props, ref) => {
3030
const {
3131
prefixCls,
3232
value,
@@ -53,6 +53,7 @@ const Handle = React.forwardRef((props: HandleProps, ref: React.Ref<HTMLDivEleme
5353
styles,
5454
classNames,
5555
} = React.useContext(SliderContext);
56+
5657
const handlePrefixCls = `${prefixCls}-handle`;
5758

5859
// ============================ Events ============================
@@ -124,7 +125,7 @@ const Handle = React.forwardRef((props: HandleProps, ref: React.Ref<HTMLDivEleme
124125
onChangeComplete?.();
125126
break;
126127
}
127-
}
128+
};
128129

129130
// ============================ Offset ============================
130131
const positionStyle = getDirectionStyle(direction, value, min, max);

0 commit comments

Comments
 (0)