kn-hooks 0.0.9 → 0.0.11
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/useClipboard.md +50 -0
- package/md/useCounter.md +29 -0
- package/md/useDictionary.md +116 -0
- package/md/usePagination.md +155 -0
- package/md/usePaginationWithForm.md +40 -0
- package/md/useSwitch.md +36 -0
- package/package.json +12 -3
- package/readme.md +17 -196
- package/src/index.js +7 -2
- package/src/useClipboard/index.js +30 -7
- package/src/useCounter/index.js +34 -0
- package/src/useDictionary/index.js +96 -26
- package/src/usePagination/index.js +264 -0
- package/src/usePaginationWithForm/index.js +86 -0
- package/src/useSwitch/index.js +23 -8
- package/test/useCounter/index.jsx +15 -0
- package/test/usePagination/index.jsx +119 -0
- package/test/usePaginationWithForm/index.jsx +101 -0
- package/test/useSwitch/index.jsx +2 -5
- package/src/.DS_Store +0 -0
- package/src/useAntdFormTableSearch/index.js +0 -165
- package/src/useRefSwitch/index.js +0 -15
- package/test/.DS_Store +0 -0
- package/test/useRefSwitch/index.jsx +0 -19
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<a id="module_useclipboard"></a>
|
|
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> useClipboard
|
|
3
|
+
|
|
4
|
+
* [ useClipboard](#module_useclipboard)
|
|
5
|
+
* [ useClipboard([props])](#module_useclipboard__useclipboard) ⇒ <code>UseClipboardResult</code>
|
|
6
|
+
* [ FunCopy](#module_useclipboard__funcopy) : <code>callback</code>
|
|
7
|
+
* [ UseClipboardResult](#module_useclipboard__useclipboardresult) : <code>Object</code>
|
|
8
|
+
|
|
9
|
+
<a id="module_useclipboard__useclipboard"></a>
|
|
10
|
+
### <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> useClipboard([props]) ⇒ <code>UseClipboardResult</code>
|
|
11
|
+
剪贴板工具
|
|
12
|
+
|
|
13
|
+
[Demo - CodeSandBox](https://codesandbox.io/s/useclipboard-b4ryc?file=/index.js)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
| Param | Type | Description |
|
|
17
|
+
| --- | --- | --- |
|
|
18
|
+
| [props] | <code>Object</code> | - |
|
|
19
|
+
| [props.onSuccess] | <code>callback</code> | 成功复制到剪贴板后的回调 ()=>void |
|
|
20
|
+
|
|
21
|
+
**Example**
|
|
22
|
+
```js
|
|
23
|
+
const clipboard= useClipboard();
|
|
24
|
+
const onCopy=()=>{
|
|
25
|
+
clipboard.copy('text',()=>{console.log('success')})
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
<a id="module_useclipboard__funcopy"></a>
|
|
29
|
+
### <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> FunCopy : <code>callback</code>
|
|
30
|
+
复制函数
|
|
31
|
+
|
|
32
|
+
**Properties**
|
|
33
|
+
|
|
34
|
+
| Name | Type | Description |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| text | <code>string</code> | 需要被复制的字符串 |
|
|
37
|
+
| onCurSuccess | <code>callback</code> | 复制成功的回调 ()=>void |
|
|
38
|
+
|
|
39
|
+
<a id="module_useclipboard__useclipboardresult"></a>
|
|
40
|
+
### <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> UseClipboardResult : <code>Object</code>
|
|
41
|
+
UseClipboardResult返回的hook
|
|
42
|
+
|
|
43
|
+
**Properties**
|
|
44
|
+
|
|
45
|
+
| Name | Type | Description |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| copy | <code>FunCopy</code> | 触发复制字符串的函数 |
|
|
48
|
+
|
|
49
|
+
**最后更新时间 2023-03-01 14:30:26**
|
|
50
|
+
|
package/md/useCounter.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<a id="module_usecounter"></a>
|
|
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> useCounter
|
|
3
|
+
|
|
4
|
+
* [ useCounter](#module_usecounter)
|
|
5
|
+
* [ useCounter()](#module_usecounter__usecounter) ⇒ <code>UseCounterResult</code>
|
|
6
|
+
* [ UseCounterResult](#module_usecounter__usecounterresult)
|
|
7
|
+
|
|
8
|
+
<a id="module_usecounter__usecounter"></a>
|
|
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> useCounter() ⇒ <code>UseCounterResult</code>
|
|
10
|
+
加法计数器
|
|
11
|
+
|
|
12
|
+
**Example**
|
|
13
|
+
```js
|
|
14
|
+
const counter= useCounter();
|
|
15
|
+
const onAdd=()=>{counter.addCount()}
|
|
16
|
+
return <span>当前计数器:{counter.count}</span>
|
|
17
|
+
```
|
|
18
|
+
<a id="module_usecounter__usecounterresult"></a>
|
|
19
|
+
### <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> UseCounterResult
|
|
20
|
+
**Properties**
|
|
21
|
+
|
|
22
|
+
| Name | Type | Description |
|
|
23
|
+
| --- | --- | --- |
|
|
24
|
+
| req | <code>Object</code> | |
|
|
25
|
+
| req.count | <code>number</code> | 当前计数器的值 |
|
|
26
|
+
| req.addCount | <code>function</code> | 计数器的值+1。 ()=>void |
|
|
27
|
+
|
|
28
|
+
**最后更新时间 2023-03-01 14:30:26**
|
|
29
|
+
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<a id="module_usedictionary"></a>
|
|
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> useDictionary
|
|
3
|
+
|
|
4
|
+
* [ useDictionary](#module_usedictionary)
|
|
5
|
+
* [ useDictionary(props)](#module_usedictionary__usedictionary) ⇒ <code>UseDictionaryResult</code>
|
|
6
|
+
* [ SET(params)](#module_usedictionary__set) ⇒ <code>void</code>
|
|
7
|
+
* [ Api](#module_usedictionary__api) ⇒ <code>Object</code>
|
|
8
|
+
* [ DictionaryItem](#module_usedictionary__dictionaryitem)
|
|
9
|
+
* [ UseDictionaryResult](#module_usedictionary__usedictionaryresult)
|
|
10
|
+
|
|
11
|
+
<a id="module_usedictionary__usedictionary"></a>
|
|
12
|
+
### <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> useDictionary(props) ⇒ <code>UseDictionaryResult</code>
|
|
13
|
+
字典管理
|
|
14
|
+
|
|
15
|
+
[Demo - CodeSandBox](https://codesandbox.io/s/usedictionary-j7cw8?file=/index.js)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
| Param | Type | Default | Description |
|
|
19
|
+
| --- | --- | --- | --- |
|
|
20
|
+
| props | <code>Object</code> | | |
|
|
21
|
+
| props.api | <code>Api</code> | | 用于获取字典列表的接口 |
|
|
22
|
+
| [props.idKey] | <code>string</code> | <code>"'id'"</code> | 字段id的key键值 |
|
|
23
|
+
| [props.nameKey] | <code>string</code> | <code>"'name'"</code> | 字段name的key键值 |
|
|
24
|
+
| [props.labelKey] | <code>string</code> | <code>"'label'"</code> | 字段label的key键值 |
|
|
25
|
+
| [props.SelectOption] | <code>ReactDom</code> | | 指定\<Select.Option\>对象是谁 |
|
|
26
|
+
| [props.RadioOption] | <code>ReactDom</code> | | 指定\<Radio.Button\>对象是谁 |
|
|
27
|
+
| [props.beforeApi] | <code>callback</code> | | (request:object)=>object 接口调用前的参数拦截器 |
|
|
28
|
+
| [props.afterApi] | <code>callback</code> | | (reponse:object)=>object[] 接口调用后的拦截器 |
|
|
29
|
+
|
|
30
|
+
**Example**
|
|
31
|
+
```js
|
|
32
|
+
import {Select,Radio} from 'antd';
|
|
33
|
+
import useDictionary from '@/useDictionary';
|
|
34
|
+
useDictionary.SET({SelectOption:Select.Option,RadioOption:Radio.Button});
|
|
35
|
+
|
|
36
|
+
const Index=()=>{
|
|
37
|
+
|
|
38
|
+
const emCity = useDictionary({
|
|
39
|
+
api:()=>{
|
|
40
|
+
return new Promise(resolve=>{
|
|
41
|
+
resolve({
|
|
42
|
+
code:0,
|
|
43
|
+
data:{
|
|
44
|
+
body:[
|
|
45
|
+
{id:1,name:'shanghai',label:'上海'},
|
|
46
|
+
{id:2,name:'beijing',label:'北京'},
|
|
47
|
+
{id:3,name:'guangzhou',label:'广州'}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<section >
|
|
57
|
+
<Select defaultValue={1}>
|
|
58
|
+
{
|
|
59
|
+
emCity.selectOptions
|
|
60
|
+
}
|
|
61
|
+
</Select>
|
|
62
|
+
<p>分割线</p>
|
|
63
|
+
<Radio.Group defaultValue={1}>
|
|
64
|
+
{
|
|
65
|
+
emCity.radioOptions
|
|
66
|
+
}
|
|
67
|
+
</Radio.Group>
|
|
68
|
+
</section>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
<a id="module_usedictionary__set"></a>
|
|
73
|
+
### <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> SET(params) ⇒ <code>void</code>
|
|
74
|
+
全局设置SelectOption和RadioOption
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
| Param | Type | Description |
|
|
78
|
+
| --- | --- | --- |
|
|
79
|
+
| params | <code>Object</code> | |
|
|
80
|
+
| params.SelectOption | <code>ReactDom</code> | Antd的SelectOption组件 |
|
|
81
|
+
| params.RadioOption | <code>ReactDom</code> | Antd的SelectOption组件 |
|
|
82
|
+
|
|
83
|
+
<a id="module_usedictionary__api"></a>
|
|
84
|
+
### <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> Api ⇒ <code>Object</code>
|
|
85
|
+
**Properties**
|
|
86
|
+
|
|
87
|
+
| Name | Type | Description |
|
|
88
|
+
| --- | --- | --- |
|
|
89
|
+
| params | <code>Object</code> | 调用接口用到的参数 |
|
|
90
|
+
|
|
91
|
+
<a id="module_usedictionary__dictionaryitem"></a>
|
|
92
|
+
### <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> DictionaryItem
|
|
93
|
+
**Properties**
|
|
94
|
+
|
|
95
|
+
| Name | Type | Description |
|
|
96
|
+
| --- | --- | --- |
|
|
97
|
+
| id | <code>string</code> | 数据唯一ID |
|
|
98
|
+
| name | <code>string</code> | 数据唯一id对应的别名 |
|
|
99
|
+
| label | <code>string</code> | 展示给用户看的文字 |
|
|
100
|
+
|
|
101
|
+
<a id="module_usedictionary__usedictionaryresult"></a>
|
|
102
|
+
### <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> UseDictionaryResult
|
|
103
|
+
**Properties**
|
|
104
|
+
|
|
105
|
+
| Name | Type | Description |
|
|
106
|
+
| --- | --- | --- |
|
|
107
|
+
| types | <code>Array.<DictionaryItem></code> | 字典数据列表 |
|
|
108
|
+
| selectOptions | <code>Array.<ReactDOM></code> | 供Antd渲染\<Select\>的列表 |
|
|
109
|
+
| radioOptions | <code>Array.<ReactDOM></code> | 供Antd渲染\<Radio\>的列表 |
|
|
110
|
+
| getId | <code>function</code> | (labelOrName:string)=>string,搜索字典项中,label或name匹配labelOrName的项目,返回其id的值 |
|
|
111
|
+
| getName | <code>function</code> | (id:string)=>string,搜索字典项中,id匹配id的项目,返回其name的值 |
|
|
112
|
+
| getLabel | <code>function</code> | (id:string)=>string,搜索字典项中,id匹配id的项目,返回其label的值 |
|
|
113
|
+
| reload | <code>function</code> | ()=>void,重新调用字典接口刷新字典列表 |
|
|
114
|
+
|
|
115
|
+
**最后更新时间 2023-03-01 14:30:26**
|
|
116
|
+
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
<a id="module_usepagination"></a>
|
|
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> usePagination
|
|
3
|
+
|
|
4
|
+
* [ usePagination](#module_usepagination)
|
|
5
|
+
* [ usePagination(props)](#module_usepagination__usepagination) ⇒ <code>UsePaginationResult</code>
|
|
6
|
+
* [ Pagination](#module_usepagination__pagination) : <code>Object</code>
|
|
7
|
+
* [ PageDataResult](#module_usepagination__pagedataresult) : <code>Object</code>
|
|
8
|
+
* [ FunUpdate](#module_usepagination__funupdate) ⇒ <code>Promise.<PageDataResult></code>
|
|
9
|
+
* [ UsePaginationResult](#module_usepagination__usepaginationresult) : <code>Object</code>
|
|
10
|
+
* [ FunListener](#module_usepagination__funlistener) ⇒ <code>Object</code> \| <code>Promise.<Object></code>
|
|
11
|
+
|
|
12
|
+
<a id="module_usepagination__usepagination"></a>
|
|
13
|
+
### <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> usePagination(props) ⇒ <code>UsePaginationResult</code>
|
|
14
|
+
分页管理器
|
|
15
|
+
|
|
16
|
+
**Version**: 1.0.0
|
|
17
|
+
|
|
18
|
+
| Param | Type | Description |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
| props | <code>Object</code> | |
|
|
21
|
+
| props.service | <code>function</code> | 发送请求的方法,默认分页使用current和pageSize,如有特殊需求通过beforeService拦截处理 |
|
|
22
|
+
| [props.pagination] | <code>Pagination</code> | 默认分页信息 |
|
|
23
|
+
|
|
24
|
+
**Example**
|
|
25
|
+
```js
|
|
26
|
+
// 移动端滚动加载案例
|
|
27
|
+
const page = usePagination({
|
|
28
|
+
service:GET_LIST,
|
|
29
|
+
pagination:{pageSize:10},
|
|
30
|
+
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
useEffect(()=>{
|
|
34
|
+
const fnFeforeService = (params)=>{
|
|
35
|
+
// 假如你这里需要变更接口字段名称的话
|
|
36
|
+
params.page=params.current;
|
|
37
|
+
params.keyword='abc';
|
|
38
|
+
return params;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const fnAfterService = (response)=>{
|
|
42
|
+
// 这里你可以翻译及二次处理你的接口字段
|
|
43
|
+
let req={
|
|
44
|
+
code:response.errorCode
|
|
45
|
+
data:response.list,
|
|
46
|
+
page:response.pageInfo
|
|
47
|
+
};
|
|
48
|
+
response.code=response;
|
|
49
|
+
return response;
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
page.addListener('beforeService',fnFeforeService);
|
|
53
|
+
page.addListener('afterService',fnAfterService);
|
|
54
|
+
return ()=>{
|
|
55
|
+
page.removeListener('beforeService',fnFeforeService);
|
|
56
|
+
page.removeListener('afterService',fnAfterService)
|
|
57
|
+
}
|
|
58
|
+
},[])
|
|
59
|
+
|
|
60
|
+
const onReset=()=>{page.reset();}
|
|
61
|
+
|
|
62
|
+
const onPageChange=()=>{
|
|
63
|
+
let value=document.querySelector('#inputPage').value;
|
|
64
|
+
page.update({pagination:{current:+value}})
|
|
65
|
+
}
|
|
66
|
+
const onNext=()=>{page.nextPage();}
|
|
67
|
+
|
|
68
|
+
const renderTable=()=>{
|
|
69
|
+
let renderData= [];
|
|
70
|
+
page?.data?.forEach(list=>{
|
|
71
|
+
renderData=[...renderData,...list];
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<ul>
|
|
76
|
+
{
|
|
77
|
+
renderData?.map((item,idx)=>{
|
|
78
|
+
return <li key={idx}>[{idx}]{item}</li>
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
</ul>
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
return (
|
|
86
|
+
<ul>
|
|
87
|
+
{renderTable()}
|
|
88
|
+
</ul>
|
|
89
|
+
)
|
|
90
|
+
```
|
|
91
|
+
<a id="module_usepagination__pagination"></a>
|
|
92
|
+
### <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> Pagination : <code>Object</code>
|
|
93
|
+
分页信息
|
|
94
|
+
|
|
95
|
+
**Properties**
|
|
96
|
+
|
|
97
|
+
| Name | Type | Default | Description |
|
|
98
|
+
| --- | --- | --- | --- |
|
|
99
|
+
| pageSize | <code>number</code> | <code>20</code> | 分页大小 |
|
|
100
|
+
| current | <code>number</code> | <code>1</code> | 当前页码 |
|
|
101
|
+
| total | <code>number</code> | <code>1</code> | 总记录数 |
|
|
102
|
+
| [startIdx] | <code>number</code> | <code>0</code> | 当前页面下第一条数据的序号 |
|
|
103
|
+
| [more] | <code>boolean</code> | | 是否还有下一页 |
|
|
104
|
+
|
|
105
|
+
<a id="module_usepagination__pagedataresult"></a>
|
|
106
|
+
### <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> PageDataResult : <code>Object</code>
|
|
107
|
+
分页数据结果
|
|
108
|
+
|
|
109
|
+
**Properties**
|
|
110
|
+
|
|
111
|
+
| Name | Type | Description |
|
|
112
|
+
| --- | --- | --- |
|
|
113
|
+
| pagination | <code>Pagination</code> | 最新分页信息 |
|
|
114
|
+
| data | <code>Array.<Array.<Object>></code> | 分页数据集合 |
|
|
115
|
+
|
|
116
|
+
<a id="module_usepagination__funupdate"></a>
|
|
117
|
+
### <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> FunUpdate ⇒ <code>Promise.<PageDataResult></code>
|
|
118
|
+
分页查询结果
|
|
119
|
+
|
|
120
|
+
**Returns**: <code>Promise.<PageDataResult></code> - 最新的分页数据结果
|
|
121
|
+
**Properties**
|
|
122
|
+
|
|
123
|
+
| Name | Type | Description |
|
|
124
|
+
| --- | --- | --- |
|
|
125
|
+
| [pagination] | <code>Pagination</code> | 最新分页信息 |
|
|
126
|
+
| [clear] | <code>boolean</code> | 是否清空数据 |
|
|
127
|
+
|
|
128
|
+
<a id="module_usepagination__usepaginationresult"></a>
|
|
129
|
+
### <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> UsePaginationResult : <code>Object</code>
|
|
130
|
+
usePagination的返回对象
|
|
131
|
+
|
|
132
|
+
**Properties**
|
|
133
|
+
|
|
134
|
+
| Name | Type | Description |
|
|
135
|
+
| --- | --- | --- |
|
|
136
|
+
| data | <code>Array.<Array.<Object>></code> | 分页数据集合 |
|
|
137
|
+
| paginnation | <code>Pagination</code> | 分页信息 |
|
|
138
|
+
| update | <code>FunUpdate</code> | 查询方法 |
|
|
139
|
+
| next | <code>FunUpdate</code> | 获取下一页数据 |
|
|
140
|
+
| addListener | <code>function</code> | 监听事件 (type='beforeService'|'afterService',fn:FunListener)=>object |
|
|
141
|
+
| removeListener | <code>function</code> | 移除监听事件 (type,fn:FunListener)=>void |
|
|
142
|
+
|
|
143
|
+
<a id="module_usepagination__funlistener"></a>
|
|
144
|
+
### <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> FunListener ⇒ <code>Object</code> \| <code>Promise.<Object></code>
|
|
145
|
+
事件监听方法
|
|
146
|
+
|
|
147
|
+
**Returns**: <code>Object</code> \| <code>Promise.<Object></code> - 处理完毕的数据对象或者Promise
|
|
148
|
+
**Properties**
|
|
149
|
+
|
|
150
|
+
| Name | Type | Description |
|
|
151
|
+
| --- | --- | --- |
|
|
152
|
+
| params | <code>Object</code> | 被拦截的数据对象 |
|
|
153
|
+
|
|
154
|
+
**最后更新时间 2023-03-01 14:30:26**
|
|
155
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<a id="module_usepaginationwithform"></a>
|
|
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
|
+
<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)
|
|
5
|
+
支持Antd-Form的usePagination
|
|
6
|
+
作用是在查询接口前自动获取form表单内的字段,并作为接口查询参数进行查询
|
|
7
|
+
使用方法及参数字段参考 [usePagination](usePagination.md)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
| Param | Type | Description |
|
|
11
|
+
| --- | --- | --- |
|
|
12
|
+
| props | <code>Object</code> | |
|
|
13
|
+
| props.form | <code>Object</code> | Form表单的ref,在接口调用前会校验获取form表单内的数据,提交到接口参数内查询 |
|
|
14
|
+
|
|
15
|
+
**Example**
|
|
16
|
+
```js
|
|
17
|
+
const [form] = Form.useForm();
|
|
18
|
+
const page = usePaginationWithForm({
|
|
19
|
+
service:GET_LIST,
|
|
20
|
+
pagination:{pageSize:10},
|
|
21
|
+
form:form
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return(
|
|
25
|
+
<Form form={form} style={{width:'600px'}} layout="inline">
|
|
26
|
+
<Form.Item label='关键字' name='keyword' rules={[
|
|
27
|
+
{
|
|
28
|
+
max:5,
|
|
29
|
+
message:'最多5个字符'
|
|
30
|
+
}
|
|
31
|
+
]}>
|
|
32
|
+
<Input />
|
|
33
|
+
</Form.Item>
|
|
34
|
+
<Button onClick={onSearch} type='primary'>查询</Button>
|
|
35
|
+
<Button onClick={onReset} type='primary'>重置</Button>
|
|
36
|
+
</Form>
|
|
37
|
+
)
|
|
38
|
+
```
|
|
39
|
+
**最后更新时间 2023-03-01 14:30:27**
|
|
40
|
+
|
package/md/useSwitch.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<a id="module_useswitch"></a>
|
|
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> useSwitch
|
|
3
|
+
useSwitch
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
* [ useSwitch](#module_useswitch)
|
|
7
|
+
* [ useSwitch([props])](#module_useswitch__useswitch) ⇒ <code>UseSwitchResult</code>
|
|
8
|
+
* [ UseSwitchResult](#module_useswitch__useswitchresult) : <code>Object</code>
|
|
9
|
+
|
|
10
|
+
<a id="module_useswitch__useswitch"></a>
|
|
11
|
+
### <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> useSwitch([props]) ⇒ <code>UseSwitchResult</code>
|
|
12
|
+
控制开关
|
|
13
|
+
|
|
14
|
+
[Demo-CodeSandbox](https://codesandbox.io/s/useswitch-qd7dr?file=/index.js)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
| Param | Type | Default | Description |
|
|
18
|
+
| --- | --- | --- | --- |
|
|
19
|
+
| [props] | <code>boolean</code> | <code>false</code> | 默认的开关状态 |
|
|
20
|
+
|
|
21
|
+
<a id="module_useswitch__useswitchresult"></a>
|
|
22
|
+
### <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> UseSwitchResult : <code>Object</code>
|
|
23
|
+
useSwitchHookResult
|
|
24
|
+
|
|
25
|
+
**Properties**
|
|
26
|
+
|
|
27
|
+
| Name | Type | Description |
|
|
28
|
+
| --- | --- | --- |
|
|
29
|
+
| state | <code>boolean</code> | 当前开关状态 |
|
|
30
|
+
| count | <code>number</code> | 当前开关计数器 |
|
|
31
|
+
| open | <code>function</code> | 切换至开模式 (force?:boolean)=>void |
|
|
32
|
+
| close | <code>function</code> | 切换至关模式 (force?:boolean)=>void |
|
|
33
|
+
| toggle | <code>function</code> | 切换至反向模式 ()=>void |
|
|
34
|
+
|
|
35
|
+
**最后更新时间 2023-03-01 14:30:27**
|
|
36
|
+
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kn-hooks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "cross-env env_api=dev env_package=dev webpack-dev-server --progress",
|
|
6
6
|
"build": "cross-env env_api=prod env_package=prod webpack --config webpack.config.js",
|
|
7
7
|
"build:dev": "cross-env env_api=dev env_package=dev webpack",
|
|
8
|
-
"report": "cross-env env_api=prod env_package=prod report=true webpack --config webpack.test.config.js"
|
|
8
|
+
"report": "cross-env env_api=prod env_package=prod report=true webpack --config webpack.test.config.js",
|
|
9
|
+
"doc": "./node_modules/.bin/jsdoc src/**/*.js --configure .jsdoc.json --verbose",
|
|
10
|
+
"md": "./node_modules/.bin/jsdoc2md --plugin ./dmd/lib/index.js --files src/useRollingPagination/*.js src/useSwitch/*.js > md/api.md"
|
|
9
11
|
},
|
|
10
12
|
"main": "src/index.js",
|
|
11
13
|
"dependencies": {
|
|
@@ -32,13 +34,19 @@
|
|
|
32
34
|
"babel-plugin-import": "^1.13.3",
|
|
33
35
|
"cross-env": "7.0.3",
|
|
34
36
|
"css-loader": "3.4.2",
|
|
37
|
+
"dmd-bitbucket": "^0.1.10",
|
|
38
|
+
"dmd-plugin-example": "^0.1.0",
|
|
39
|
+
"docdash": "^2.0.1",
|
|
35
40
|
"html-webpack-plugin": "4.0.3",
|
|
41
|
+
"jsdoc": "^4.0.2",
|
|
42
|
+
"jsdoc-to-markdown": "^8.0.0",
|
|
36
43
|
"mini-css-extract-plugin": "0.9.0",
|
|
37
44
|
"react": "16.13.0",
|
|
38
45
|
"react-dom": "16.13.0",
|
|
39
46
|
"rollup": "^2.50.5",
|
|
40
47
|
"rollup-plugin-jsx": "^1.0.3",
|
|
41
48
|
"rollup-plugin-terser": "^7.0.2",
|
|
49
|
+
"taffydb": "^2.7.3",
|
|
42
50
|
"terser-webpack-plugin": "4.2.3",
|
|
43
51
|
"webpack": "4.46.0",
|
|
44
52
|
"webpack-bundle-analyzer": "3.6.1",
|
|
@@ -48,7 +56,8 @@
|
|
|
48
56
|
"files": [
|
|
49
57
|
"test",
|
|
50
58
|
"src",
|
|
51
|
-
"lib"
|
|
59
|
+
"lib",
|
|
60
|
+
"md"
|
|
52
61
|
],
|
|
53
62
|
"keywords": [],
|
|
54
63
|
"description": "",
|