@@ -2,18 +2,19 @@ import React, { Component } from 'react';
22import { StyleSheet , Text , TextProps } from 'react-native' ;
33import Icon from '../Icon' ;
44import Flex , { FlexProps } from '../Flex' ;
5+ import { iconStr } from './svg' ;
56
6- const iconStr = `
7- <svg width="64" height="41" viewBox="0 0 64 41">
8- <g transform="translate(0 1)" fill="none" fill-rule="evenodd">
9- <ellipse fill="#F5F5F5" cx="32" cy="33" rx="32" ry="7"></ellipse>
10- <g fill-rule="nonzero" stroke="#D9D9D9">
11- <path fill="#FFF" d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path>
12- <path fill="#FAFAFA" d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z"></path>
13- </g>
14- </g>
15- </svg>
16- ` ;
7+ // export const iconStr = `
8+ // <svg width="64" height="41" viewBox="0 0 64 41">
9+ // <g transform="translate(0 1)" fill="none" fill-rule="evenodd">
10+ // <ellipse fill="#F5F5F5" cx="32" cy="33" rx="32" ry="7"></ellipse>
11+ // <g fill-rule="nonzero" stroke="#D9D9D9">
12+ // <path fill="#FFF" d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path>
13+ // <path fill="#FAFAFA" d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z"></path>
14+ // </g>
15+ // </g>
16+ // </svg>
17+ // `;
1718
1819export interface EmptyProps extends FlexProps {
1920 /**
@@ -38,24 +39,17 @@ export interface EmptyProps extends FlexProps {
3839 children ?: React . ReactNode ;
3940}
4041
41- export default class Empty extends Component < EmptyProps > {
42- static defaultProps : EmptyProps = {
43- size : 64 ,
44- label : '暂无数据' ,
45- xml : iconStr ,
46- } ;
47- render ( ) {
48- const { size, label, xml, labelStyle, children, ...props } = this . props ;
49- return (
50- < Flex direction = "column" justify = "center" align = "center" { ...props } >
51- { xml && < Icon xml = { xml } size = { size } /> }
52- { ! ! children
53- ? children
54- : label &&
55- typeof label === 'string' && < Text style = { StyleSheet . flatten ( [ styles . label , labelStyle ] ) } > { label } </ Text > }
56- </ Flex >
57- ) ;
58- }
42+ export default function Empty ( props : EmptyProps ) {
43+ const { size = 64 , label = '暂无数据' , xml = iconStr , labelStyle, children, ...otherProps } = props ;
44+ return (
45+ < Flex direction = "column" justify = "center" align = "center" { ...otherProps } >
46+ { xml && < Icon xml = { xml } size = { size } /> }
47+ { ! ! children
48+ ? children
49+ : label &&
50+ typeof label === 'string' && < Text style = { StyleSheet . flatten ( [ styles . label , labelStyle ] ) } > { label } </ Text > }
51+ </ Flex >
52+ ) ;
5953}
6054
6155const styles = StyleSheet . create ( {
0 commit comments