kn-hooks 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/md/usePagination.md +1 -2
- package/md/usePaginationWithForm.md +22 -1
- package/package.json +1 -1
- package/readme.md +23 -3
- package/src/usePagination/index.js +4 -2
- package/src/usePaginationWithForm/index.js +16 -0
package/md/usePagination.md
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
| Param | Type | Description |
|
|
21
21
|
| --- | --- | --- |
|
|
22
22
|
| props | <code>Object</code> | |
|
|
23
|
-
| props.service | <code>FunServices</code> |
|
|
23
|
+
| props.service | <code>FunServices</code> | 发送请求的方法 |
|
|
24
24
|
| [props.pagination] | <code>Pagination</code> | 默认分页信息 |
|
|
25
25
|
|
|
26
26
|
**Example**
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
const page = usePagination({
|
|
30
30
|
service:GET_LIST,
|
|
31
31
|
pagination:{pageSize:10},
|
|
32
|
-
|
|
33
32
|
});
|
|
34
33
|
|
|
35
34
|
useEffect(()=>{
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
<a id="module_usepaginationwithform"></a>
|
|
2
2
|
## <span style="display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:4px;color:rgb(71, 128, 227);background:#ede6e6;">G</span> usePaginationWithForm
|
|
3
|
+
|
|
4
|
+
* [ usePaginationWithForm](#module_usepaginationwithform)
|
|
5
|
+
* [ usePaginationWithForm(props)](#module_usepaginationwithform__usepaginationwithform) ⇒ <code>UsePaginationWithFormResult</code>
|
|
6
|
+
* [ UsePaginationWithFormResult](#module_usepaginationwithform__usepaginationwithformresult) : <code>Object</code>
|
|
7
|
+
|
|
3
8
|
<a id="module_usepaginationwithform__usepaginationwithform"></a>
|
|
4
|
-
### <span style="display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:4px;color:rgb(71, 128, 227);background:#ede6e6;">M</span> usePaginationWithForm(props)
|
|
9
|
+
### <span style="display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:4px;color:rgb(71, 128, 227);background:#ede6e6;">M</span> usePaginationWithForm(props) ⇒ <code>UsePaginationWithFormResult</code>
|
|
5
10
|
支持Antd-Form的usePagination
|
|
6
11
|
作用是在查询接口前自动获取form表单内的字段,并作为接口查询参数进行查询
|
|
7
12
|
使用方法及参数字段参考 [usePagination](usePagination.md)
|
|
@@ -21,6 +26,12 @@ const page = usePaginationWithForm({
|
|
|
21
26
|
form:form
|
|
22
27
|
});
|
|
23
28
|
|
|
29
|
+
const onSearch=()=>{
|
|
30
|
+
page.update();
|
|
31
|
+
}
|
|
32
|
+
const onReset=()=>{
|
|
33
|
+
page.reset();
|
|
34
|
+
}
|
|
24
35
|
return(
|
|
25
36
|
<Form form={form} style={{width:'600px'}} layout="inline">
|
|
26
37
|
<Form.Item label='关键字' name='keyword' rules={[
|
|
@@ -36,4 +47,14 @@ return(
|
|
|
36
47
|
</Form>
|
|
37
48
|
)
|
|
38
49
|
```
|
|
50
|
+
<a id="module_usepaginationwithform__usepaginationwithformresult"></a>
|
|
51
|
+
### <span style="display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:4px;color:rgb(71, 128, 227);background:#ede6e6;">T</span> UsePaginationWithFormResult : <code>Object</code>
|
|
52
|
+
usePaginationWithForm的返回对象
|
|
53
|
+
|
|
54
|
+
**Properties**
|
|
55
|
+
|
|
56
|
+
| Name | Type | Description |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| reset | <code>function</code> | 重置方法 |
|
|
59
|
+
|
|
39
60
|
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -335,7 +335,7 @@ const Index=()=>{
|
|
|
335
335
|
| Param | Type | Description |
|
|
336
336
|
| --- | --- | --- |
|
|
337
337
|
| props | <code>Object</code> | |
|
|
338
|
-
| props.service | <code>FunServices</code> |
|
|
338
|
+
| props.service | <code>FunServices</code> | 发送请求的方法 |
|
|
339
339
|
| [props.pagination] | <code>Pagination</code> | 默认分页信息 |
|
|
340
340
|
|
|
341
341
|
**Example**
|
|
@@ -344,7 +344,6 @@ const Index=()=>{
|
|
|
344
344
|
const page = usePagination({
|
|
345
345
|
service:GET_LIST,
|
|
346
346
|
pagination:{pageSize:10},
|
|
347
|
-
|
|
348
347
|
});
|
|
349
348
|
|
|
350
349
|
useEffect(()=>{
|
|
@@ -497,8 +496,13 @@ usePagination的返回对象
|
|
|
497
496
|
|
|
498
497
|
<a id="module_usepaginationwithform"></a>
|
|
499
498
|
## <span style="display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:4px;color:rgb(71, 128, 227);background:#ede6e6;">G</span> usePaginationWithForm
|
|
499
|
+
|
|
500
|
+
* [ usePaginationWithForm](#module_usepaginationwithform)
|
|
501
|
+
* [ usePaginationWithForm(props)](#module_usepaginationwithform__usepaginationwithform) ⇒ <code>UsePaginationWithFormResult</code>
|
|
502
|
+
* [ UsePaginationWithFormResult](#module_usepaginationwithform__usepaginationwithformresult) : <code>Object</code>
|
|
503
|
+
|
|
500
504
|
<a id="module_usepaginationwithform__usepaginationwithform"></a>
|
|
501
|
-
### <span style="display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:4px;color:rgb(71, 128, 227);background:#ede6e6;">M</span> usePaginationWithForm(props)
|
|
505
|
+
### <span style="display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:4px;color:rgb(71, 128, 227);background:#ede6e6;">M</span> usePaginationWithForm(props) ⇒ <code>UsePaginationWithFormResult</code>
|
|
502
506
|
支持Antd-Form的usePagination
|
|
503
507
|
作用是在查询接口前自动获取form表单内的字段,并作为接口查询参数进行查询
|
|
504
508
|
使用方法及参数字段参考 [usePagination](usePagination.md)
|
|
@@ -518,6 +522,12 @@ const page = usePaginationWithForm({
|
|
|
518
522
|
form:form
|
|
519
523
|
});
|
|
520
524
|
|
|
525
|
+
const onSearch=()=>{
|
|
526
|
+
page.update();
|
|
527
|
+
}
|
|
528
|
+
const onReset=()=>{
|
|
529
|
+
page.reset();
|
|
530
|
+
}
|
|
521
531
|
return(
|
|
522
532
|
<Form form={form} style={{width:'600px'}} layout="inline">
|
|
523
533
|
<Form.Item label='关键字' name='keyword' rules={[
|
|
@@ -533,6 +543,16 @@ return(
|
|
|
533
543
|
</Form>
|
|
534
544
|
)
|
|
535
545
|
```
|
|
546
|
+
<a id="module_usepaginationwithform__usepaginationwithformresult"></a>
|
|
547
|
+
### <span style="display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:4px;color:rgb(71, 128, 227);background:#ede6e6;">T</span> UsePaginationWithFormResult : <code>Object</code>
|
|
548
|
+
usePaginationWithForm的返回对象
|
|
549
|
+
|
|
550
|
+
**Properties**
|
|
551
|
+
|
|
552
|
+
| Name | Type | Description |
|
|
553
|
+
| --- | --- | --- |
|
|
554
|
+
| reset | <code>function</code> | 重置方法 |
|
|
555
|
+
|
|
536
556
|
|
|
537
557
|
<a id="module_useswitch"></a>
|
|
538
558
|
## <span style="display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:4px;color:rgb(71, 128, 227);background:#ede6e6;">G</span> useSwitch
|
|
@@ -6,9 +6,12 @@ import { useState,useMemo,useRef } from 'react';
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* 分页管理器
|
|
9
|
+
*
|
|
10
|
+
*
|
|
9
11
|
* @param {Object} props
|
|
10
|
-
* @param {FunServices} props.service -
|
|
12
|
+
* @param {FunServices} props.service - 发送请求的方法
|
|
11
13
|
* @param {Pagination} [props.pagination] - 默认分页信息
|
|
14
|
+
*
|
|
12
15
|
* @version 1.0.0
|
|
13
16
|
*
|
|
14
17
|
* @example
|
|
@@ -16,7 +19,6 @@ import { useState,useMemo,useRef } from 'react';
|
|
|
16
19
|
const page = usePagination({
|
|
17
20
|
service:GET_LIST,
|
|
18
21
|
pagination:{pageSize:10},
|
|
19
|
-
|
|
20
22
|
});
|
|
21
23
|
|
|
22
24
|
useEffect(()=>{
|
|
@@ -22,6 +22,12 @@ const page = usePaginationWithForm({
|
|
|
22
22
|
form:form
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
+
const onSearch=()=>{
|
|
26
|
+
page.update();
|
|
27
|
+
}
|
|
28
|
+
const onReset=()=>{
|
|
29
|
+
page.reset();
|
|
30
|
+
}
|
|
25
31
|
return(
|
|
26
32
|
<Form form={form} style={{width:'600px'}} layout="inline">
|
|
27
33
|
<Form.Item label='关键字' name='keyword' rules={[
|
|
@@ -36,6 +42,7 @@ return(
|
|
|
36
42
|
<Button onClick={onReset} type='primary'>重置</Button>
|
|
37
43
|
</Form>
|
|
38
44
|
)
|
|
45
|
+
* @returns {UsePaginationWithFormResult}
|
|
39
46
|
*/
|
|
40
47
|
const usePaginationWithForm = (props) => {
|
|
41
48
|
const {service,pagination}= props;
|
|
@@ -83,4 +90,13 @@ const usePaginationWithForm = (props) => {
|
|
|
83
90
|
};
|
|
84
91
|
};
|
|
85
92
|
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* usePaginationWithForm的返回对象
|
|
96
|
+
* @typedef {Object} UsePaginationWithFormResult
|
|
97
|
+
* @property {Function} reset - 重置方法
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
86
102
|
export default usePaginationWithForm
|