kn-hooks 0.0.17 → 0.0.18

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.
@@ -22,6 +22,12 @@
22
22
  | params.SelectOption | <code>ReactDom</code> | Antd的SelectOption组件 |
23
23
  | params.RadioOption | <code>ReactDom</code> | Antd的SelectOption组件 |
24
24
 
25
+ **Example**
26
+ ```js
27
+ import {useDictionary} from 'kn-hooks';
28
+ import {Select,Radio} from 'antd';
29
+ useDictionary.SetConfig(Select.Option,Radio.Option);
30
+ ```
25
31
  <a id="module_usedictionary_createdictionary"></a>
26
32
  ### <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> createDictionary(options) ⇒ <code>callback</code>
27
33
  创建字典hooks工具
@@ -43,7 +49,8 @@
43
49
  **Example**
44
50
  ```js
45
51
  // emUserType.jsx
46
- export const userType = createDictionary({
52
+ import {useDictionary} from 'kn-hooks';
53
+ export const userType = useDictionary.createDictionary({
47
54
  api:()=>Promise.resolve([{id:'1001',label:'项目1001',name:'pm1001'},]),
48
55
  afterApi:(response)=>{
49
56
  return response?.data;
@@ -3,6 +3,8 @@
3
3
 
4
4
  * [ usePagination](#module_usepagination)
5
5
  * [ usePagination(props)](#module_usepagination__usepagination) ⇒ <code>UsePaginationResult</code>
6
+ * [ FunServices()](#module_usepagination__funservices) ⇒ <code>FunServicesCallback</code>
7
+ * [ FunServicesCallback](#module_usepagination__funservicescallback) : <code>Object</code>
6
8
  * [ Pagination](#module_usepagination__pagination) : <code>Object</code>
7
9
  * [ PageDataResult](#module_usepagination__pagedataresult) : <code>Object</code>
8
10
  * [ FunUpdate](#module_usepagination__funupdate) ⇒ <code>Promise.&lt;PageDataResult&gt;</code>
@@ -18,7 +20,7 @@
18
20
  | Param | Type | Description |
19
21
  | --- | --- | --- |
20
22
  | props | <code>Object</code> | |
21
- | props.service | <code>function</code> | 发送请求的方法,默认分页使用current和pageSize,如有特殊需求通过beforeService拦截处理 |
23
+ | props.service | <code>FunServices</code> | 发送请求的方法,默认分页使用current和pageSize,如有特殊需求通过beforeService拦截处理 |
22
24
  | [props.pagination] | <code>Pagination</code> | 默认分页信息 |
23
25
 
24
26
  **Example**
@@ -45,8 +47,7 @@
45
47
  data:response.list,
46
48
  page:response.pageInfo
47
49
  };
48
- response.code=response;
49
- return response;
50
+ return req;
50
51
  },
51
52
 
52
53
  page.addListener('beforeService',fnFeforeService);
@@ -88,6 +89,33 @@
88
89
  </ul>
89
90
  )
90
91
  ```
92
+ <a id="module_usepagination__funservices"></a>
93
+ ### <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> FunServices() ⇒ <code>FunServicesCallback</code>
94
+ 分页请求接口格式要求
95
+
96
+ **Properties**
97
+
98
+ | Name | Type | Default | Description |
99
+ | --- | --- | --- | --- |
100
+ | current | <code>number</code> | <code>1</code> | 页码 |
101
+ | pageSize | <code>number</code> | <code>10</code> | 分页大小 |
102
+ | ...others | <code>any</code> | | 其它接口附带参数 |
103
+
104
+ <a id="module_usepagination__funservicescallback"></a>
105
+ ### <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> FunServicesCallback : <code>Object</code>
106
+ 分页接口请求结果
107
+
108
+ **Properties**
109
+
110
+ | Name | Type | Default | Description |
111
+ | --- | --- | --- | --- |
112
+ | code | <code>number</code> | <code>0</code> | 接口调用结果,0为成功 |
113
+ | data | <code>Array.&lt;Object&gt;</code> | | 分页数据 |
114
+ | page | <code>Object</code> | | 分页信息 |
115
+ | page.current | <code>number</code> | | 页码 |
116
+ | page.pageSize | <code>number</code> | | 分页大小 |
117
+ | page.total | <code>number</code> | | 数据总量 |
118
+
91
119
  <a id="module_usepagination__pagination"></a>
92
120
  ### <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
121
  分页信息
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kn-hooks",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
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",
package/readme.md CHANGED
@@ -171,6 +171,12 @@ return <span>当前计数器:{counter.count}</span>
171
171
  | params.SelectOption | <code>ReactDom</code> | Antd的SelectOption组件 |
172
172
  | params.RadioOption | <code>ReactDom</code> | Antd的SelectOption组件 |
173
173
 
174
+ **Example**
175
+ ```js
176
+ import {useDictionary} from 'kn-hooks';
177
+ import {Select,Radio} from 'antd';
178
+ useDictionary.SetConfig(Select.Option,Radio.Option);
179
+ ```
174
180
  <a id="module_usedictionary_createdictionary"></a>
175
181
  ### <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> createDictionary(options) ⇒ <code>callback</code>
176
182
  创建字典hooks工具
@@ -192,7 +198,8 @@ return <span>当前计数器:{counter.count}</span>
192
198
  **Example**
193
199
  ```js
194
200
  // emUserType.jsx
195
- export const userType = createDictionary({
201
+ import {useDictionary} from 'kn-hooks';
202
+ export const userType = useDictionary.createDictionary({
196
203
  api:()=>Promise.resolve([{id:'1001',label:'项目1001',name:'pm1001'},]),
197
204
  afterApi:(response)=>{
198
205
  return response?.data;
@@ -311,6 +318,8 @@ const Index=()=>{
311
318
 
312
319
  * [ usePagination](#module_usepagination)
313
320
  * [ usePagination(props)](#module_usepagination__usepagination) ⇒ <code>UsePaginationResult</code>
321
+ * [ FunServices()](#module_usepagination__funservices) ⇒ <code>FunServicesCallback</code>
322
+ * [ FunServicesCallback](#module_usepagination__funservicescallback) : <code>Object</code>
314
323
  * [ Pagination](#module_usepagination__pagination) : <code>Object</code>
315
324
  * [ PageDataResult](#module_usepagination__pagedataresult) : <code>Object</code>
316
325
  * [ FunUpdate](#module_usepagination__funupdate) ⇒ <code>Promise.&lt;PageDataResult&gt;</code>
@@ -326,7 +335,7 @@ const Index=()=>{
326
335
  | Param | Type | Description |
327
336
  | --- | --- | --- |
328
337
  | props | <code>Object</code> | |
329
- | props.service | <code>function</code> | 发送请求的方法,默认分页使用current和pageSize,如有特殊需求通过beforeService拦截处理 |
338
+ | props.service | <code>FunServices</code> | 发送请求的方法,默认分页使用current和pageSize,如有特殊需求通过beforeService拦截处理 |
330
339
  | [props.pagination] | <code>Pagination</code> | 默认分页信息 |
331
340
 
332
341
  **Example**
@@ -353,8 +362,7 @@ const Index=()=>{
353
362
  data:response.list,
354
363
  page:response.pageInfo
355
364
  };
356
- response.code=response;
357
- return response;
365
+ return req;
358
366
  },
359
367
 
360
368
  page.addListener('beforeService',fnFeforeService);
@@ -396,6 +404,33 @@ const Index=()=>{
396
404
  </ul>
397
405
  )
398
406
  ```
407
+ <a id="module_usepagination__funservices"></a>
408
+ ### <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> FunServices() ⇒ <code>FunServicesCallback</code>
409
+ 分页请求接口格式要求
410
+
411
+ **Properties**
412
+
413
+ | Name | Type | Default | Description |
414
+ | --- | --- | --- | --- |
415
+ | current | <code>number</code> | <code>1</code> | 页码 |
416
+ | pageSize | <code>number</code> | <code>10</code> | 分页大小 |
417
+ | ...others | <code>any</code> | | 其它接口附带参数 |
418
+
419
+ <a id="module_usepagination__funservicescallback"></a>
420
+ ### <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> FunServicesCallback : <code>Object</code>
421
+ 分页接口请求结果
422
+
423
+ **Properties**
424
+
425
+ | Name | Type | Default | Description |
426
+ | --- | --- | --- | --- |
427
+ | code | <code>number</code> | <code>0</code> | 接口调用结果,0为成功 |
428
+ | data | <code>Array.&lt;Object&gt;</code> | | 分页数据 |
429
+ | page | <code>Object</code> | | 分页信息 |
430
+ | page.current | <code>number</code> | | 页码 |
431
+ | page.pageSize | <code>number</code> | | 分页大小 |
432
+ | page.total | <code>number</code> | | 数据总量 |
433
+
399
434
  <a id="module_usepagination__pagination"></a>
400
435
  ### <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>
401
436
  分页信息
@@ -7,7 +7,7 @@ import { useState,useMemo,useRef } from 'react';
7
7
  /**
8
8
  * 分页管理器
9
9
  * @param {Object} props
10
- * @param {function} props.service - 发送请求的方法,默认分页使用current和pageSize,如有特殊需求通过beforeService拦截处理
10
+ * @param {FunServices} props.service - 发送请求的方法,默认分页使用current和pageSize,如有特殊需求通过beforeService拦截处理
11
11
  * @param {Pagination} [props.pagination] - 默认分页信息
12
12
  * @version 1.0.0
13
13
  *
@@ -34,8 +34,7 @@ import { useState,useMemo,useRef } from 'react';
34
34
  data:response.list,
35
35
  page:response.pageInfo
36
36
  };
37
- response.code=response;
38
- return response;
37
+ return req;
39
38
  },
40
39
 
41
40
  page.addListener('beforeService',fnFeforeService);
@@ -211,6 +210,30 @@ const usePagination=(props)=>{
211
210
 
212
211
 
213
212
 
213
+ /**
214
+ * 分页接口请求结果
215
+ * @typedef {Object} FunServicesCallback
216
+ * @property {number} code=0 - 接口调用结果,0为成功
217
+ * @property {Object[]} data - 分页数据
218
+ * @property {Object} page - 分页信息
219
+ * @property {number} page.current - 页码
220
+ * @property {number} page.pageSize - 分页大小
221
+ * @property {number} page.total - 数据总量
222
+ *
223
+ */
224
+
225
+
226
+ /**
227
+ * @function
228
+ * @name FunServices
229
+ * @description 分页请求接口格式要求
230
+ * @property {number} current=1 - 页码
231
+ * @property {number} pageSize=10 - 分页大小
232
+ * @property {...any} others - 其它接口附带参数
233
+ * @return {FunServicesCallback}
234
+ */
235
+
236
+
214
237
  /**
215
238
  * 分页信息
216
239
  * @typedef {Object} Pagination