Skip to content

Commit 7a9638e

Browse files
committed
feat: 上传版本 1.0.0
1 parent 18f0af2 commit 7a9638e

22 files changed

Lines changed: 665 additions & 0 deletions

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
15+
[Makefile]
16+
indent_style = tab

.fatherrc.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
cjs: 'babel',
3+
esm: 'babel',
4+
};

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/npm-debug.log*
6+
/yarn-error.log
7+
/yarn.lock
8+
/package-lock.json
9+
10+
# production
11+
/es
12+
/lib
13+
/docs-dist
14+
15+
# misc
16+
.DS_Store
17+
/coverage
18+
19+
# umi
20+
.umi
21+
.umi-production
22+
.umi-test
23+
.env.local
24+
25+
# ide
26+
/.vscode
27+
/.idea

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
**/*.svg
2+
**/*.ejs
3+
**/*.html
4+
package.json
5+
.umi
6+
.umi-production
7+
.umi-test

.prettierrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@umijs/fabric').prettier;

.umirc.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from 'dumi';
2+
3+
export default defineConfig({
4+
title: 'react-inline-edit',
5+
favicon:
6+
'https://user-images.githubusercontent.com/9554297/83762004-a0761b00-a6a9-11ea-83b4-9c8ff721d4b8.png',
7+
logo: 'https://user-images.githubusercontent.com/9554297/83762004-a0761b00-a6a9-11ea-83b4-9c8ff721d4b8.png',
8+
outputPath: 'docs-dist',
9+
// mode: 'site',
10+
// more config: https://d.umijs.org/config
11+
});

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# react-inline-edit
2+
3+
Inline edit component for React(基于 React 的内联编辑组件)
4+
5+
## 安装
6+
7+
```bash
8+
npm install @twp0217/react-inline-edit --save
9+
```
10+
11+
## 使用
12+
13+
```typescript
14+
import React from 'react';
15+
import InlineEdit from '@twp0217/react-inline-edit';
16+
17+
export default () => {
18+
const [editValue, setEditValue] = React.useState<string>('');
19+
20+
return (
21+
<InlineEdit
22+
defaultValue={editValue}
23+
readView={editValue || '请点击输入值'}
24+
editView={<input placeholder="请输入值" />}
25+
onConfirm={setEditValue}
26+
/>
27+
);
28+
};
29+
```
30+
31+
## API
32+
33+
### InlineEditProps
34+
35+
| 名称 | 类型 | 默认值 | 说明 |
36+
| -------------- | -------------------- | --------- | ------------------ | ---- |
37+
| className | string | - | 类名 |
38+
| style | React.CSSProperties | - | 样式 |
39+
| keepOpenOnBlur | `boolean` | `false` | 失去焦点时保持打开 |
40+
| hideActions | `boolean` | `false` | 是否隐藏操作按钮 |
41+
| confirmText | `string` | `Confirm` | 确认文本 |
42+
| cancelText | `string` | `Cancel` | 取消文本 |
43+
| defaultValue | `string` | - | 默认值 |
44+
| isEditing | `boolean` | - | 是否正在编辑 |
45+
| loading | `boolean` | - | 加载中 |
46+
| placement | `'top' | 'bottom'` | - | 位置 |
47+
| readView | `React.ReactNode` | - | 查看视图 |
48+
| editView | `React.ReactNode` | - | 编辑视图 |
49+
| onEdit | `() => void` | - | 编辑事件 |
50+
| onBlur | `() => void` | - | 失去焦点事件 |
51+
| onConfirm | `(value: T) => void` | - | 确认事件 |
52+
| onCancel | `() => void` | - | 取消事件 |
53+
54+
## 支持
55+
56+
- 如果项目对你有帮助,请点颗星星:star:,谢谢。
57+
- 如果你对项目有想法、问题、BUG,欢迎讨论。

docs/demo/basic.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
order: 1
3+
---
4+
5+
## basic
6+
7+
<code src="../examples/basic.tsx" />

docs/demo/event.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
order: 1
3+
---
4+
5+
## event
6+
7+
<code src="../examples/event.tsx" />

docs/examples/basic.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import InlineEdit from '@twp0217/react-inline-edit';
3+
4+
export default () => {
5+
const [editValue, setEditValue] = React.useState<string>('');
6+
7+
return (
8+
<InlineEdit
9+
defaultValue={editValue}
10+
readView={editValue || '请点击输入值'}
11+
editView={<input placeholder="请输入值" />}
12+
onConfirm={setEditValue}
13+
/>
14+
);
15+
};

0 commit comments

Comments
 (0)