Skip to content

Commit 768b841

Browse files
committedSep 19, 2023
type: Support TypeScript v5.
1 parent 533e760 commit 768b841

File tree

7 files changed

+128
-120
lines changed

7 files changed

+128
-120
lines changed
 

Diff for: ‎README-zh.md

+62-61
Large diffs are not rendered by default.

Diff for: ‎package.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44
"homepage": "https://uiwjs.github.io",
55
"private": true,
66
"scripts": {
7-
"lib": "lerna exec --scope @uiw/react-descriptions -- tsbb build --target react",
8-
"lib:css": "lerna exec --scope @uiw/react-descriptions -- compile-less -d src -o esm",
9-
"lib:css:dist": "lerna exec --scope @uiw/react-descriptions -- compile-less -d src -o lib --combine=dist.css",
10-
"lib:css:watch": "lerna exec --scope @uiw/react-descriptions -- compile-less -d src -o esm --watch",
11-
"lib:watch": "lerna exec --scope @uiw/react-descriptions -- tsbb watch & npm run lib:css:watch",
12-
"lib:bootstrap": "lerna bootstrap --hoist --scope @uiw/react-descriptions",
7+
"lib": "lerna exec --scope @uiw/react-slider -- tsbb build \"src/*.{ts,tsx}\" --use-babel --cjs cjs",
8+
"lib:css": "lerna exec --scope @uiw/react-slider -- compile-less -d src -o esm",
9+
"lib:css:dist": "lerna exec --scope @uiw/react-slider -- compile-less -d src -o lib --combine=dist.css",
10+
"lib:css:watch": "lerna exec --scope @uiw/react-slider -- compile-less -d src -o esm --watch",
11+
"lib:watch": "lerna exec --scope @uiw/react-slider -- tsbb watch \"src/*.{ts,tsx}\" --use-babel --cjs cjs & npm run lib:css:watch",
12+
"lib:bootstrap": "lerna bootstrap --hoist --scope @uiw/react-slider",
1313
"lib:build": "npm run lib && npm run lib:css && npm run lib:css:dist",
1414
"//>>>>>>>>>>>>": "<<<<<<<<<<",
15-
"watch:other:lib": "lerna exec --parallel --scope @uiw/* --ignore @uiw/doc -- tsbb watch",
16-
"watch:uiw": "lerna exec --scope uiw -- tsbb watch",
17-
"watch:react-menu": "lerna exec --scope @uiw/react-menu -- tsbb watch",
15+
"watch:other:lib": "lerna exec --parallel --scope @uiw/* --ignore @uiw/doc -- tsbb watch \"src/*.{ts,tsx}\" --use-babel --cjs cjs",
16+
"watch:uiw": "lerna exec --scope uiw -- tsbb watch \"src/*.{ts,tsx}\" --use-babel --cjs cjs",
17+
"watch:react-menu": "lerna exec --scope @uiw/react-menu -- tsbb watch \"src/*.{ts,tsx}\" --use-babel --cjs cjs",
1818
"watch:css:react-menu": "lerna exec --scope @uiw/react-menu -- compile-less -d src -o esm --watch",
1919
"//-----------": "//-----------",
2020
"build": "npm run b:uiw && npm run b:css && npm run b:css:dist",
2121
"start": "lerna exec --scope website -- npm run start",
2222
"doc": "npm run b:website && npm run b:doc",
2323
"b:website": "lerna exec --scope website -- npm run build",
2424
"b:doc": "lerna exec --scope @uiw/doc -- node script/released.js",
25-
"b:uiw": "lerna exec --scope @uiw/* --scope uiw --ignore @uiw/doc -- tsbb build",
25+
"b:uiw": "lerna exec --scope @uiw/* --scope uiw --ignore @uiw/doc -- tsbb build \"src/*.{ts,tsx}\" --use-babel --cjs cjs",
2626
"b:css": "lerna exec --scope @uiw/* -- compile-less -d src -o esm",
2727
"b:css:dist": "lerna exec --scope @uiw/* --scope @uiw/utils -- compile-less -d src -o lib --combine=dist.css",
2828
"b:bundle": "lerna exec --scope uiw -- ncc build --target web --filename uiw",
@@ -63,21 +63,21 @@
6363
"node": ">=16.0.0"
6464
},
6565
"devDependencies": {
66-
"@kkt/less-modules": "~7.3.0",
66+
"@kkt/less-modules": "^7.5.2",
6767
"@kkt/ncc": "~1.0.15",
6868
"@types/react": "~18.2.0",
6969
"@types/react-dom": "~18.2.0",
7070
"@types/react-test-renderer": "~18.0.0",
7171
"@types/react-transition-group": "~4.4.4",
7272
"compile-less-cli": "~1.8.11",
7373
"husky": "~8.0.0",
74-
"kkt": "~7.3.0",
74+
"kkt": "^7.5.2",
7575
"lerna": "~6.0.0",
7676
"lint-staged": "^13.0.3",
7777
"prettier": "~2.8.0",
7878
"react": "~18.2.0",
7979
"react-dom": "~18.2.0",
8080
"react-test-renderer": "~18.2.0",
81-
"tsbb": "~3.7.0"
81+
"tsbb": "^4.1.14"
8282
}
8383
}

Diff for: ‎packages/react-back-top/src/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface ChildrenFunction {
99
current: number;
1010
}
1111

12-
export interface BackTopProps extends IProps, Omit<HTMLDivProps, 'children'> {
12+
export interface BackTopProps extends IProps, Omit<HTMLDivProps, 'children' | 'content'> {
1313
offsetTop?: number;
1414
clickable?: boolean;
1515
content?: JSX.Element | string;

Diff for: ‎packages/react-icon/src/index.tsx

+30-31
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,63 @@ import svgPaths from '@uiw/icons/fonts/w-icon.json';
33
import './style/index.less';
44

55
export type IconsName = keyof typeof svgPaths;
6-
type TagType = React.ComponentType | keyof JSX.IntrinsicElements;
7-
8-
export interface IconProps<Tag extends TagType = 'span', E = React.ReactElement> extends React.HTMLAttributes<Tag> {
6+
type TagType = React.ElementType | keyof JSX.IntrinsicElements;
7+
type ElementProps<T extends TagType, E = React.ReactElement> = {
8+
fill?: string;
99
style?: React.CSSProperties;
1010
className?: string;
1111
prefixCls?: string;
1212
/**
1313
* HTML tag to use for the rendered element.
1414
* @default "span"
1515
*/
16-
tagName?: Tag;
16+
tagName?: T;
1717
type?: IconsName | null | E;
1818
spin?: boolean;
1919
color?: string;
2020
verticalAlign?: 'middle' | 'baseline';
21-
}
21+
};
22+
23+
export type IconProps<T extends TagType> = ElementProps<T> & React.ComponentPropsWithoutRef<T>;
2224

23-
export default function Icon<Tag extends TagType = 'span'>(props: IconProps<Tag>) {
25+
const Icon = <T extends TagType = 'span'>(props: IconProps<T>) => {
2426
const {
2527
className,
2628
prefixCls = 'w-icon',
2729
verticalAlign = 'middle',
28-
tagName: TagName = 'span',
30+
tagName: Element = 'span',
2931
color,
3032
type,
3133
spin = false,
32-
...others
34+
style,
35+
...reset
3336
} = props;
3437

3538
let svg = null;
3639
if (typeof type === 'string') {
3740
svg = (
38-
<svg fill={color} viewBox="0 0 20 20">
39-
{(svgPaths[type] || []).map((d, i) => (
41+
<svg fill={color || props.fill} viewBox="0 0 20 20">
42+
{(svgPaths[type as IconsName] || []).map((d, i) => (
4043
<path key={i} d={d} fillRule="evenodd" />
4144
))}
4245
</svg>
4346
);
44-
} else if (React.isValidElement(type)) {
45-
svg = React.cloneElement(type, {
46-
fill: color,
47-
});
48-
} else {
49-
return null;
5047
}
51-
others.style = { fill: 'currentColor', ...others.style };
52-
const propps = {
53-
...others,
54-
className: [
55-
prefixCls,
56-
className,
57-
prefixCls && verticalAlign ? `${prefixCls}-${verticalAlign}` : null,
58-
spin && prefixCls ? `${prefixCls}-spin` : null,
59-
]
60-
.filter(Boolean)
61-
.join(' ')
62-
.trim(),
63-
};
48+
const initStyle = { fill: 'currentColor', ...style };
49+
const cls = [
50+
prefixCls,
51+
className,
52+
prefixCls && verticalAlign ? `${prefixCls}-${verticalAlign}` : null,
53+
spin && prefixCls ? `${prefixCls}-spin` : null,
54+
]
55+
.filter(Boolean)
56+
.join(' ')
57+
.trim();
58+
return (
59+
<Element className={cls} {...reset} style={initStyle}>
60+
{svg}
61+
</Element>
62+
);
63+
};
6464

65-
return React.createElement(TagName, { ...propps } as any, svg);
66-
}
65+
export default Icon;

Diff for: ‎packages/react-slider/src/index.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from 'react';
1+
import React, { ReactElement, useEffect, useState } from 'react';
22
import { IProps, HTMLDivProps } from '@uiw/utils';
33
import Dots from './Dots';
44
import './style/index.less';
@@ -66,7 +66,7 @@ export default function Slider(props: SliderProps) {
6666
handleChange(curr);
6767
};
6868

69-
function getRangeValue(val: number | number[]) {
69+
function getRangeValue(val: number) {
7070
if (!Array.isArray(value)) {
7171
return Array.isArray(val) ? val : [val];
7272
}
@@ -202,10 +202,17 @@ export default function Slider(props: SliderProps) {
202202
if (marks && marks !== true && marks[val] && marks[val].label) {
203203
return marks[val].label;
204204
} else if (marks && marks !== true && marks[val] && typeof marks[val] === 'string') {
205-
return marks[val];
205+
return marks[val] as ReactElement;
206206
} else if (renderMarks && typeof renderMarks === 'function' && renderMarks(val)) {
207207
return renderMarks(val);
208208
}
209+
// if (marks && typeof marks !== 'boolean' && marks[val].label) {
210+
// return marks[val].label;
211+
// } else if (marks && typeof marks !== 'boolean' && typeof marks[val] === 'string') {
212+
// return marks[val] as ReactElement;
213+
// } else if (renderMarks && typeof renderMarks === 'function' && renderMarks(val)) {
214+
// return renderMarks(val);
215+
// }
209216
return val;
210217
}
211218

Diff for: ‎packages/react-tag/src/index.tsx

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useMemo } from 'react';
1+
import React from 'react';
22
import { IProps, HTMLSpanProps } from '@uiw/utils';
33
import './style/index.less';
44

@@ -47,15 +47,16 @@ export default (props: TagProps = {}) => {
4747
if (!visible) {
4848
return null;
4949
}
50+
const iconClose = !disabled && closable && (
51+
<svg onClick={onClose} className={`${prefixCls}-close`} width="15" height="15" viewBox="0 0 16 16">
52+
<path d="M9.41 8l2.29-2.29c.19-.18.3-.43.3-.71a1.003 1.003 0 0 0-1.71-.71L8 6.59l-2.29-2.3a1.003 1.003 0 0 0-1.42 1.42L6.59 8 4.3 10.29c-.19.18-.3.43-.3.71a1.003 1.003 0 0 0 1.71.71L8 9.41l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 0 0 .71-1.71L9.41 8z" />
53+
</svg>
54+
);
5055

5156
return (
5257
<span className={cls} style={styl} {...other}>
5358
{title || children}
54-
{!disabled && closable ? (
55-
<svg onClick={onClose} className={`${prefixCls}-close`} width="15" height="15" viewBox="0 0 16 16">
56-
<path d="M9.41 8l2.29-2.29c.19-.18.3-.43.3-.71a1.003 1.003 0 0 0-1.71-.71L8 6.59l-2.29-2.3a1.003 1.003 0 0 0-1.42 1.42L6.59 8 4.3 10.29c-.19.18-.3.43-.3.71a1.003 1.003 0 0 0 1.71.71L8 9.41l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 0 0 .71-1.71L9.41 8z" />
57-
</svg>
58-
) : null}
59+
{iconClose}
5960
</span>
6061
);
6162
};

Diff for: ‎website/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@
4040
"react": ">=16.9.0",
4141
"react-code-preview-layout": "^2.0.6",
4242
"react-dom": ">=16.9.0",
43-
"react-router-dom": "~6.4.2",
43+
"react-router-dom": "^6.16.0",
4444
"uiw": "^4.21.28"
4545
},
4646
"devDependencies": {
47-
"@kkt/less-modules": "~7.3.0",
48-
"@kkt/raw-modules": "~7.3.0",
49-
"@kkt/scope-plugin-options": "~7.3.0",
47+
"@kkt/less-modules": "^7.5.2",
48+
"@kkt/raw-modules": "^7.5.2",
49+
"@kkt/scope-plugin-options": "^7.5.2",
5050
"@types/react": "~18.2.0",
5151
"@types/react-dom": "~18.2.0",
52-
"kkt": "~7.3.0",
52+
"kkt": "^7.5.2",
5353
"react-test-renderer": "~18.2.0"
5454
},
5555
"author": "kenny wang <wowohoo@qq.com>",

0 commit comments

Comments
 (0)
Please sign in to comment.