Skip to content

Commit

Permalink
初始化仓库
Browse files Browse the repository at this point in the history
  • Loading branch information
SystemLight committed Aug 10, 2020
0 parents commit 4c4eb11
Show file tree
Hide file tree
Showing 15 changed files with 8,194 additions and 0 deletions.
115 changes: 115 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# See https://github.com/github/gitignore for more about ignoring files.

# IDE content
.idea/

# Special content


# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt


# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 SystemLight

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# ra-antd-table

基于react antd进行拓展的表格组件

## 安装

```
npm install ra-antd-table
```

## 使用示例

```
import EditTable from "ra-antd-table";
const columns = [
{
key: "name",
dataIndex: "name",
sortKey: "name",
title: "姓名"
},
{
key: "age",
dataIndex: "age",
sortKey: "age",
filterKey: "age",
totalKey: "age",
width: 180,
title: "年龄"
},
{
key: "size",
dataIndex: "size",
sortKey: "size",
filterKey: "size",
title: "位置"
}
];
const data = [
{
key: "1",
name: "SystemLight",
age: 23,
size: 1
},
{
key: "2",
name: "Lisys",
age: 18,
size: 2
},
{
key: "3",
name: "kirito",
age: 12,
size: 3
}
];
function App() {
const [colState, setColState] = useState(columns);
return (
<>
<div className={"s-wrap"} style={{paddingTop: 15}}>
<EditTable
columns={colState}
data={data} title={"表格标题"}
onResize={(e, {size}, i) => {
colState[i].width = size.width;
setColState([...colState]);
}}
onChangeHide={(idx, status) => {
colState[idx].hide = status;
setColState([...colState]);
}}
onChangePin={(idx, val) => {
colState[idx].fixed = val === "none" ? undefined : val;
setColState([...colState]);
}}
/>
</div>
</>
);
}
```

![NPM version](show.png)
32 changes: 32 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = function (api) {
api.cache(true);

const presets = [
[
"@babel/env",
{
targets: {
node: "8",
ie: "10",
edge: "17",
firefox: "60",
chrome: "67",
safari: "11.1",
},
useBuiltIns: "usage",
modules: false,
corejs: {
"version": 3,
"proposals": true,
}
},
],
"@babel/react"
];
const plugins = [];

return {
presets,
plugins
};
};
4 changes: 4 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/// <reference types="react" />
import "./style.less";
import { IEditTableProps, IDefaultRecordType } from "./interface";
export default function Index<RT extends IDefaultRecordType>(props: IEditTableProps<RT>): JSX.Element;
1 change: 1 addition & 0 deletions dist/index.umd.js

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions dist/interface.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { DefaultRecordType } from "rc-table/lib/interface";
import { ColumnType } from "antd/es/table";
import { DetailedHTMLProps, SyntheticEvent, ThHTMLAttributes } from "react";
import { ResizeCallbackData } from "react-resizable";
export interface IDefaultRecordType extends DefaultRecordType {
index?: number;
}
export declare type IData<RT> = RT[];
export declare type IRecordKey<RT> = Exclude<keyof RT, "index">;
export interface IColumnType<RT> extends ColumnType<RT> {
filterKey?: IRecordKey<RT>;
sortKey?: IRecordKey<RT>;
totalKey?: IRecordKey<RT>;
hide?: boolean;
}
export declare type IColumnsType<RT> = IColumnType<RT>[];
export declare type ITableHeadProps = DetailedHTMLProps<ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>;
export interface IResizableCell extends ITableHeadProps {
width: number;
onResize: (e: SyntheticEvent, data: ResizeCallbackData) => void;
}
export declare type IFixed = "left" | "right" | "none";
export interface IOnAddData {
(): void;
}
export interface IOnEditData {
(): void;
}
export interface IOnViewData {
(): void;
}
export interface IOnDeleteData {
(): void;
}
export interface IEditTableProps<RT> {
columns: IColumnsType<RT>;
data: IData<RT>;
title?: string;
exportFileName?: string;
onAdd?: IOnAddData;
onEdit?: IOnEditData;
onView?: IOnViewData;
onDelete?: IOnDeleteData;
onResize?: (e: SyntheticEvent, data: ResizeCallbackData, index: number) => void;
onChangeHide?: (idx: number, status: boolean) => void;
onChangePin?: (idx: number, val: IFixed) => void;
loading?: boolean;
}
Loading

0 comments on commit 4c4eb11

Please sign in to comment.