Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyib committed Mar 6, 2024
1 parent e6c587a commit 49fed28
Show file tree
Hide file tree
Showing 25 changed files with 180 additions and 203 deletions.
2 changes: 0 additions & 2 deletions packages/hooks/src/useAntdTable/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ The following demos are for antd v4. For v3, please refer to: https://ahooks-v2.
<Table columns={columns} rowKey="email" {...tableProps} />
```

<br />

<code src="./demo/table.tsx"></code>

### Form and Table data binding
Expand Down
2 changes: 0 additions & 2 deletions packages/hooks/src/useAntdTable/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ demo:
<Table columns={columns} rowKey="email" {...tableProps} />
```

<br />

<code src="./demo/table.tsx"></code>

### Form 与 Table 联动
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useBoolean/demo/demo1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default () => {
return (
<div>
<p>Effects:{JSON.stringify(state)}</p>
<Space>
<Space style={{ marginTop: 8 }}>
<Button onClick={toggle}>Toggle</Button>
<Button onClick={setFalse}>Set false</Button>
<Button onClick={setTrue}>Set true</Button>
Expand Down
16 changes: 7 additions & 9 deletions packages/hooks/src/useDrop/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ A pair of hooks to help you manage data transfer between drag and drop
<code src="./demo/demo1.tsx"></code>
<code src="./demo/demo2.tsx"></code>

## API

### useDrag
## API - useDrag

```typescript
useDrag<T>(
Expand All @@ -37,31 +35,31 @@ useDrag<T>(
);
```

#### Params
### Params

| Property | Description | Type | Default |
| -------- | ------------------ | ----------------------------------------------------------- | ------- |
| data | Drag data | `any` | - |
| target | DOM element or ref | `() => Element` \| `Element` \| `MutableRefObject<Element>` | - |
| options | More config | `DragOptions` | - |

#### DragOptions
### DragOptions

| Property | Description | Type | Default |
| ----------- | ------------------------------------------------------------- | ------------------------------ | ------- |
| onDragStart | On drag start callback | `(e: React.DragEvent) => void` | - |
| onDragEnd | On drag end callback | `(e: React.DragEvent) => void` | - |
| dragImage | Customize image that follow the mouse pointer during dragging | `DragImageOptions` | - |

#### DragImageOptions
### DragImageOptions

| 参数 | 说明 | 类型 | 默认值 |
| ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ------ |
| image | An image Element element to use for the drag feedback image. The image will typically be an [`<img>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) element but it can also be a [`<canvas>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas) or any other visible element | `string \| Element` | - |
| offsetX | the horizontal offset within the image | `number` | 0 |
| offsetY | the vertical offset within the image | `number` | 0 |

### useDrop
## API - useDrop

```typescript
useDrop<T>(
Expand All @@ -70,14 +68,14 @@ useDrop<T>(
);
```

#### Params
### Params

| Property | Description | Type | Default |
| -------- | ------------------ | ----------------------------------------------------------- | ------- |
| target | DOM element or ref | `() => Element` \| `Element` \| `MutableRefObject<Element>` | - |
| options | More config | `DropOptions` | - |

#### DropOptions
### DropOptions

| Property | Description | Type | Default |
| ----------- | ------------------------------------------- | --------------------------------------------- | ------- |
Expand Down
16 changes: 7 additions & 9 deletions packages/hooks/src/useDrop/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ demo:
<code src="./demo/demo1.tsx"></code>
<code src="./demo/demo2.tsx"></code>

## API

### useDrag
## API - useDrag

```typescript
useDrag<T>(
Expand All @@ -37,31 +35,31 @@ useDrag<T>(
);
```

#### Params
### Params

| 参数 | 说明 | 类型 | 默认值 |
| ------- | --------------------- | ----------------------------------------------------------- | ------ |
| data | 拖拽的内容 | `any` | - |
| target | DOM 节点或者 Ref 对象 | `() => Element` \| `Element` \| `MutableRefObject<Element>` | - |
| options | 额外的配置项 | `DragOptions` | - |

#### DragOptions
### DragOptions

| 参数 | 说明 | 类型 | 默认值 |
| ----------- | ---------------------------------- | ------------------------------ | ------ |
| onDragStart | 开始拖拽的回调 | `(e: React.DragEvent) => void` | - |
| onDragEnd | 结束拖拽的回调 | `(e: React.DragEvent) => void` | - |
| dragImage | 自定义拖拽过程中跟随鼠标指针的图像 | `DragImageOptions` | - |

#### DragImageOptions
### DragImageOptions

| 参数 | 说明 | 类型 | 默认值 |
| ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------- | ------ |
| image | 拖拽过程中跟随鼠标指针的图像。图像通常是一个 [`<img>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) 元素,但也可以是 [`<canvas>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas) 或任何其他图像元素。 | `string \| Element` | - |
| offsetX | 水平偏移 | `number` | 0 |
| offsetY | 垂直偏移 | `number` | 0 |

### useDrop
## API - useDrop

```typescript
useDrop<T>(
Expand All @@ -70,14 +68,14 @@ useDrop<T>(
);
```

#### Params
### Params

| 参数 | 说明 | 类型 | 默认值 |
| ------- | --------------------- | ----------------------------------------------------------- | ------ |
| target | DOM 节点或者 Ref 对象 | `() => Element` \| `Element` \| `MutableRefObject<Element>` | - |
| options | 额外的配置项 | `DragOptions` | - |

#### DropOptions
### DropOptions

| 参数 | 说明 | 类型 | 默认值 |
| ----------- | ------------------------------ | --------------------------------------------- | ------ |
Expand Down
24 changes: 12 additions & 12 deletions packages/hooks/src/useRequest/docs/basic/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,18 @@ const {

### Result

| Property | Description | Type |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| data | Data returned by service | `TData` \| `undefined` |
| error | Exception thrown by service | `Error` \| `undefined` |
| loading | Is the service being executed | `boolean` |
| params | An array of parameters for the service being executed. For example, you triggered `run(1, 2, 3)`, then params is equal to `[1, 2, 3]` | `TParams` \| `[]` |
| run | <ul><li> Manually trigger the execution of the service, and the parameters will be passed to the service</li><li>Automatic handling of exceptions, feedback through `onError`</li></ul> | `(...params : TParams) => void` |
| runAsync | The usage is the same as `run`, but it returns a Promise, so you need to handle the exception yourself. | `(...params: TParams) => Promise<TData>` |
| refresh | Use the last params, call `run` again | `() => void` |
| refreshAsync | Use the last params, call `runAsync` again | `() => Promise<TData>` |
| mutate | Mutate `data` directly | `(data?: TData / ((oldData?: TData) => (TData / undefined))) => void` |
| cancel | Ignore the current promise response | `() => void` |
| Property | Description | Type |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| data | Data returned by service | `TData` \| `undefined` |
| error | Exception thrown by service | `Error` \| `undefined` |
| loading | Is the service being executed | `boolean` |
| params | An array of parameters for the service being executed. For example, you triggered `run(1, 2, 3)`, then params is equal to `[1, 2, 3]` | `TParams` \| `[]` |
| run | <ul><li> Manually trigger the execution of the service, and the parameters will be passed to the service</li><li>Automatic handling of exceptions, feedback through `onError`</li></ul> | `(...params : TParams) => void` |
| runAsync | The usage is the same as `run`, but it returns a Promise, so you need to handle the exception yourself. | `(...params: TParams) => Promise<TData>` |
| refresh | Use the last params, call `run` again | `() => void` |
| refreshAsync | Use the last params, call `runAsync` again | `() => Promise<TData>` |
| mutate | Mutate `data` directly | `(data?: TData \| ((oldData?: TData) => (TData \| undefined))) => void` |
| cancel | Ignore the current promise response | `() => void` |

### Options

Expand Down
24 changes: 12 additions & 12 deletions packages/hooks/src/useRequest/docs/basic/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,18 @@ const {

### Result

| 参数 | 说明 | 类型 |
| ------------ | -------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| data | service 返回的数据 | `TData` \| `undefined` |
| error | service 抛出的异常 | `Error` \| `undefined` |
| loading | service 是否正在执行 | `boolean` |
| params | 当次执行的 service 的参数数组。比如你触发了 `run(1, 2, 3)`,则 params 等于 `[1, 2, 3]` | `TParams` \| `[]` |
| run | <ul><li> 手动触发 service 执行,参数会传递给 service</li><li>异常自动处理,通过 `onError` 反馈</li></ul> | `(...params: TParams) => void` |
| runAsync |`run` 用法一致,但返回的是 Promise,需要自行处理异常。 | `(...params: TParams) => Promise<TData>` |
| refresh | 使用上一次的 params,重新调用 `run` | `() => void` |
| refreshAsync | 使用上一次的 params,重新调用 `runAsync` | `() => Promise<TData>` |
| mutate | 直接修改 `data` | `(data?: TData / ((oldData?: TData) => (TData / undefined))) => void` |
| cancel | 忽略当前 Promise 的响应 | `() => void` |
| 参数 | 说明 | 类型 |
| ------------ | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| data | service 返回的数据 | `TData` \| `undefined` |
| error | service 抛出的异常 | `Error` \| `undefined` |
| loading | service 是否正在执行 | `boolean` |
| params | 当次执行的 service 的参数数组。比如你触发了 `run(1, 2, 3)`,则 params 等于 `[1, 2, 3]` | `TParams` \| `[]` |
| run | <ul><li> 手动触发 service 执行,参数会传递给 service</li><li>异常自动处理,通过 `onError` 反馈</li></ul> | `(...params: TParams) => void` |
| runAsync |`run` 用法一致,但返回的是 Promise,需要自行处理异常。 | `(...params: TParams) => Promise<TData>` |
| refresh | 使用上一次的 params,重新调用 `run` | `() => void` |
| refreshAsync | 使用上一次的 params,重新调用 `runAsync` | `() => Promise<TData>` |
| mutate | 直接修改 `data` | `(data?: TData \| ((oldData?: TData) => (TData \| undefined))) => void` |
| cancel | 忽略当前 Promise 的响应 | `() => void` |

### Options

Expand Down
Loading

0 comments on commit 49fed28

Please sign in to comment.