Skip to content

Commit

Permalink
feat: 1.0.19
Browse files Browse the repository at this point in the history
  • Loading branch information
BugHunter7788 committed Mar 15, 2021
1 parent bb1e016 commit b2a7f30
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 35 deletions.
7 changes: 7 additions & 0 deletions babel.config.build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
presets: [
'@babel/env',
'@babel/typescript',
'@babel/react',
]
};
2 changes: 1 addition & 1 deletion generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cp -r src/components/Table build

# complie
./node_modules/.bin/lessc build/Table/style.less build/Table/style.css -x
./node_modules/.bin/babel build/Table/Table.tsx --out-file build/Table/Table.js
./node_modules/.bin/babel --config-file $(pwd)/babel.config.build.js build/Table/Table.tsx --out-file build/Table/Table.js

# clear
rm -rf build/Table/style.less
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "taro3-table",
"version": "1.0.17",
"version": "1.0.19",
"author": "qxtang",
"main": "build/Table/index.js",
"templateInfo": {
Expand Down
25 changes: 10 additions & 15 deletions src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
Props
} from './types';

const Table = (props: Props): JSX.Element => {
const Table = (props: Props): JSX.Element | null => {
// variables
const {
columns: pColumns = [],
Expand Down Expand Up @@ -55,18 +55,18 @@ const Table = (props: Props): JSX.Element => {
const [expansion, setExpansion] = useState<boolean>(false); // 是否展开

// effects
useEffect(() => {
onChange(dataSource);
}, [dataSource]);

useEffect(() => {
if (pColumns.some((i: AnyOpt) => {
return !['number', 'undefined'].includes(typeof i.width);
})) {
console.error('[taro3-table] -', '列配置 width 参数类型需为 number');
setError(true);
}
}, []);

useEffect(() => {
onChange(dataSource);
}, [dataSource]);
}, [columns]);

// 当 columns、pColumns、dataSource 有变化时进行排序
useEffect(() => {
Expand Down Expand Up @@ -318,14 +318,6 @@ const Table = (props: Props): JSX.Element => {
);
};

const Error = () => {
return (
<View className="error">
<Text>错误</Text>
</View>
);
};

const Empty = () => {
return (
<View className="nothing">
Expand All @@ -341,6 +333,10 @@ const Table = (props: Props): JSX.Element => {
}, 0);
}, [columns]);

if (error) {
return null;
}

return (
<View
className={classnames(['taro3table', className])}
Expand All @@ -350,7 +346,6 @@ const Table = (props: Props): JSX.Element => {
}}
>
{loading && (<Loading/>)}
{error && (<Error/>)}
<ScrollView
className="table"
scroll-x={(dataSource.length !== 0) && (scroll.x)}
Expand Down
18 changes: 0 additions & 18 deletions src/components/Table/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,6 @@
}
}

.error {
position: absolute;
height: 100%;
width: 100%;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-color: rgba(255, 255, 255, .3);
backdrop-filter: blur(unit(6, rpx));
z-index: 95;
color: #ff0000;
display: flex;
align-items: center;
justify-content: center;
font-size: unit(28, rpx);
}

.nothing {
color: #CCCCCC;
font-size: unit(24, rpx);
Expand Down

0 comments on commit b2a7f30

Please sign in to comment.