litten-hooks 1.7.1 → 2.0.1-beta.0
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/README.md +4 -2
- package/dist/checkedControl.js +1 -1
- package/dist/chunks/{checkedControl.DJK032i4.js → checkedControl.Np7TCTGe.js} +1 -1
- package/dist/chunks/contentControl.D8rNZWtl.js +30 -0
- package/dist/contentControl.js +1 -1
- package/dist/control/contentControl/contentControl.d.ts +5 -10
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunks/contentControl.BDOf7ZM1.js +0 -38
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# litten-hooks
|
|
2
|
+
|
|
2
3
|

|
|
3
4
|

|
|
4
5
|
[](https://coveralls.io/github/liuxian496/litten?branch=main)
|
|
5
6
|

|
|
6
7
|
|
|
7
|
-
|
|
8
8
|
<p>litten-hooks是一个基于react的工具库,提供开发「控件库」时需要的hooks</p>
|
|
9
9
|
|
|
10
10
|
<p>
|
|
@@ -14,11 +14,13 @@
|
|
|
14
14
|
[https://liuxian496.github.io/litten-hooks/](https://liuxian496.github.io/litten-hooks/)
|
|
15
15
|
|
|
16
16
|
## 依赖
|
|
17
|
+
|
|
17
18
|
<code>react</code>
|
|
18
19
|
<code>react-dom</code>
|
|
19
20
|
<code>loadsh</code>
|
|
20
21
|
上述依赖,打包时不包含,需要使用的项目自行引入。
|
|
21
22
|
|
|
22
23
|
## 如果你想请我喝一咖啡(Buy Me a Coffee)
|
|
24
|
+
|
|
23
25
|
<img src=".\\public\\wechat.jpg" height="360">
|
|
24
|
-
<img src=".\\public\\alipay.jpg" height="360">
|
|
26
|
+
<img src=".\\public\\alipay.jpg" height="360">
|
package/dist/checkedControl.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState as l, useEffect as d, useId as h, useCallback as m } from "react";
|
|
2
2
|
import { ControlType as y } from "../enum.js";
|
|
3
3
|
import { u as v } from "./usePrevious.VSe_Wq1g.js";
|
|
4
|
-
import { g as k } from "./contentControl.
|
|
4
|
+
import { g as k } from "./contentControl.D8rNZWtl.js";
|
|
5
5
|
const G = {};
|
|
6
6
|
function i(t) {
|
|
7
7
|
let e = {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useState as n, useEffect as o } from "react";
|
|
2
|
+
import { ControlType as s } from "../enum.js";
|
|
3
|
+
import { u as l } from "./usePrevious.VSe_Wq1g.js";
|
|
4
|
+
function m(t, e) {
|
|
5
|
+
let r;
|
|
6
|
+
return t !== void 0 ? r = t : r = e, r;
|
|
7
|
+
}
|
|
8
|
+
function p(t) {
|
|
9
|
+
let e;
|
|
10
|
+
switch (t) {
|
|
11
|
+
case s.Slider:
|
|
12
|
+
e = 50;
|
|
13
|
+
break;
|
|
14
|
+
default:
|
|
15
|
+
e = "";
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
return e;
|
|
19
|
+
}
|
|
20
|
+
function V(t) {
|
|
21
|
+
const { value: e } = t, r = l(e), [a, u] = n(e);
|
|
22
|
+
return o(() => {
|
|
23
|
+
r !== e && u(e);
|
|
24
|
+
}, [r, e]), [a, u];
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
p as a,
|
|
28
|
+
m as g,
|
|
29
|
+
V as u
|
|
30
|
+
};
|
package/dist/contentControl.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { ContentControlProps } from './contentControl.types';
|
|
2
|
-
import {
|
|
2
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* 检测一个数是否在给定的极值范围之内,并返回检测后的数值。如果小于最小值返回最小值,如果大于最大值返回最大值
|
|
6
|
-
* @param value 待检测的数值
|
|
7
|
-
* @param extremum 极值范围
|
|
8
|
-
* @returns 检测后校准的数值
|
|
9
|
-
*/
|
|
10
4
|
/**
|
|
11
5
|
* value值不是undefined时,返回value值。否则返回defaultValue的值
|
|
12
6
|
* @param value 控件的值(外部传入) {V}
|
|
@@ -20,7 +14,8 @@ export declare function getCurrentValue<V>(value: V | undefined, defaultValue: V
|
|
|
20
14
|
*/
|
|
21
15
|
export declare function getDefaultValueByDisplayName(displayName: string): string | number;
|
|
22
16
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @
|
|
17
|
+
* 获取当前值和更新当前值的hook
|
|
18
|
+
* @param props ContentControl组件的props
|
|
19
|
+
* @returns 当前值和更新当前值的函数
|
|
25
20
|
*/
|
|
26
|
-
export declare function useCurrentValue<T, V>(props: ContentControlProps<T, V>): [V | undefined, Dispatch<SetStateAction<V | undefined
|
|
21
|
+
export declare function useCurrentValue<T, V>(props: ContentControlProps<T, V>): [V | undefined, Dispatch<SetStateAction<V | undefined>>];
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChangeEventState as a, CheckState as s, ControlType as u, EnableState as o, FocusState as r, MouseState as l, Orientation as n, Placement as p, Shape as x, TextFieldType as i } from "./enum.js";
|
|
2
|
-
import { s as m, u as d } from "./chunks/checkedControl.
|
|
3
|
-
import { g, a as C, u as S } from "./chunks/contentControl.
|
|
2
|
+
import { s as m, u as d } from "./chunks/checkedControl.Np7TCTGe.js";
|
|
3
|
+
import { g, a as C, u as S } from "./chunks/contentControl.D8rNZWtl.js";
|
|
4
4
|
import { u as F } from "./chunks/disabledControl.SpguzRdp.js";
|
|
5
5
|
import { g as V, u as k } from "./chunks/focusControl.BDOZSK39.js";
|
|
6
6
|
import { a as B, g as D, u as P } from "./chunks/useVirtualFocus.DMntv7tM.js";
|
package/package.json
CHANGED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { useState as i, useEffect as l } from "react";
|
|
2
|
-
import { ControlType as d } from "../enum.js";
|
|
3
|
-
import { u as f } from "./usePrevious.VSe_Wq1g.js";
|
|
4
|
-
function c(r, e) {
|
|
5
|
-
let t;
|
|
6
|
-
return r !== void 0 ? t = r : t = e, t;
|
|
7
|
-
}
|
|
8
|
-
function C(r) {
|
|
9
|
-
let e;
|
|
10
|
-
switch (r) {
|
|
11
|
-
case d.Slider:
|
|
12
|
-
e = 50;
|
|
13
|
-
break;
|
|
14
|
-
default:
|
|
15
|
-
e = "";
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
18
|
-
return e;
|
|
19
|
-
}
|
|
20
|
-
function E(r) {
|
|
21
|
-
const { value: e, defaultValue: t, controlType: p, onChange: a } = r, n = f(e), [u, o] = i(
|
|
22
|
-
c(e, t)
|
|
23
|
-
), v = f(u), [m, s] = i();
|
|
24
|
-
return l(() => {
|
|
25
|
-
n !== e && (s(void 0), o(c(e, t)));
|
|
26
|
-
}, [n, e, t]), l(() => {
|
|
27
|
-
v !== u && (a == null || a({
|
|
28
|
-
e: m,
|
|
29
|
-
controlType: p,
|
|
30
|
-
value: u
|
|
31
|
-
}));
|
|
32
|
-
}), [u, o, s];
|
|
33
|
-
}
|
|
34
|
-
export {
|
|
35
|
-
C as a,
|
|
36
|
-
c as g,
|
|
37
|
-
E as u
|
|
38
|
-
};
|