mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
Merge branch 'master' into feature
This commit is contained in:
commit
03b9175c6b
@ -7,12 +7,14 @@ const ltrD =
|
||||
const rtlD =
|
||||
'M256 64l512 0 0 128-128 0 0 768-128 0 0-768-128 0 0 768-128 0 0-448c-123.712 0-224-100.288-224-224s100.288-224 224-224zM960 896l-256-224 256-224z';
|
||||
|
||||
const DirectionSvg = ({ direction }: any) => (
|
||||
<svg viewBox="0 0 1024 1024" fill="currentColor">
|
||||
<path d={direction === 'ltr' ? ltrD : rtlD} />
|
||||
</svg>
|
||||
);
|
||||
|
||||
const DirectionIcon: React.FC<{ direction: DirectionType; className?: string }> = (props) => (
|
||||
<Icon {...props}>
|
||||
<svg viewBox="0 0 1024 1024" fill="currentColor">
|
||||
<path d={props.direction === 'ltr' ? ltrD : rtlD} />
|
||||
</svg>
|
||||
</Icon>
|
||||
<Icon {...props} component={() => <DirectionSvg direction={props.direction} />} />
|
||||
);
|
||||
|
||||
export default DirectionIcon;
|
||||
|
@ -460,14 +460,12 @@ const InternalUpload: React.ForwardRefRenderFunction<UploadRef, UploadProps> = (
|
||||
[`${prefixCls}-disabled`]: mergedDisabled,
|
||||
});
|
||||
|
||||
const renderUploadButton = (uploadButtonStyle?: React.CSSProperties) => (
|
||||
<div className={uploadButtonCls} style={uploadButtonStyle}>
|
||||
const uploadButton = (
|
||||
<div className={uploadButtonCls} style={children ? undefined : { display: 'none' }}>
|
||||
<RcUpload {...rcUploadProps} ref={upload} />
|
||||
</div>
|
||||
);
|
||||
|
||||
const uploadButton = renderUploadButton(children ? undefined : { display: 'none' });
|
||||
|
||||
if (listType === 'picture-card' || listType === 'picture-circle') {
|
||||
return wrapCSSVar(
|
||||
<span className={mergedCls}>{renderUploadList(uploadButton, !!children)}</span>,
|
||||
|
@ -54,7 +54,7 @@ export const isImageUrl = (file: UploadFile): boolean => {
|
||||
if (file.type && !file.thumbUrl) {
|
||||
return isImageFileType(file.type);
|
||||
}
|
||||
const url: string = (file.thumbUrl || file.url || '') as string;
|
||||
const url = file.thumbUrl || file.url || '';
|
||||
const extension = extname(url);
|
||||
if (
|
||||
/^data:image\//.test(url) ||
|
||||
@ -76,17 +76,16 @@ export const isImageUrl = (file: UploadFile): boolean => {
|
||||
const MEASURE_SIZE = 200;
|
||||
|
||||
export function previewImage(file: File | Blob): Promise<string> {
|
||||
return new Promise((resolve) => {
|
||||
return new Promise<string>((resolve) => {
|
||||
if (!file.type || !isImageFileType(file.type)) {
|
||||
resolve('');
|
||||
return;
|
||||
}
|
||||
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = MEASURE_SIZE;
|
||||
canvas.height = MEASURE_SIZE;
|
||||
canvas.style.cssText = `position: fixed; left: 0; top: 0; width: ${MEASURE_SIZE}px; height: ${MEASURE_SIZE}px; z-index: 9999; display: none;`;
|
||||
document.body.appendChild(canvas);
|
||||
document.body.appendChild<HTMLCanvasElement>(canvas);
|
||||
const ctx = canvas.getContext('2d');
|
||||
const img = new Image();
|
||||
img.onload = () => {
|
||||
@ -115,13 +114,17 @@ export function previewImage(file: File | Blob): Promise<string> {
|
||||
if (file.type.startsWith('image/svg+xml')) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
if (reader.result) img.src = reader.result as string;
|
||||
if (reader.result && typeof reader.result === 'string') {
|
||||
img.src = reader.result;
|
||||
}
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
} else if (file.type.startsWith('image/gif')) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
if (reader.result) resolve(reader.result as string);
|
||||
if (reader.result) {
|
||||
resolve(reader.result as string);
|
||||
}
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
} else {
|
||||
|
@ -253,7 +253,7 @@
|
||||
"glob": "^10.3.10",
|
||||
"html2sketch": "^1.0.2",
|
||||
"http-server": "^14.1.1",
|
||||
"husky": "^9.0.7",
|
||||
"husky": "^9.0.9",
|
||||
"identity-obj-proxy": "^3.0.0",
|
||||
"immer": "^10.0.3",
|
||||
"inquirer": "^9.2.13",
|
||||
@ -317,7 +317,7 @@
|
||||
"sharp": "^0.33.2",
|
||||
"simple-git": "^3.22.0",
|
||||
"size-limit": "^11.0.2",
|
||||
"stylelint": "^16.2.0",
|
||||
"stylelint": "^16.2.1",
|
||||
"stylelint-config-rational-order": "^0.1.2",
|
||||
"stylelint-config-standard": "^36.0.0",
|
||||
"stylelint-prettier": "^5.0.0",
|
||||
|
Loading…
Reference in New Issue
Block a user