clxx 2.0.6 → 2.0.7
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/build/Clickable/index.d.ts +1 -1
- package/build/Clickable/index.js +14 -9
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/package.json +2 -2
package/build/Clickable/index.js
CHANGED
|
@@ -10,8 +10,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
13
|
-
import { useCallback, useRef, useState, useEffect, } from
|
|
14
|
-
import { is } from
|
|
13
|
+
import { useCallback, useRef, useState, useEffect, } from 'react';
|
|
14
|
+
import { is } from '../utils/is';
|
|
15
15
|
export function Clickable(props) {
|
|
16
16
|
let { children, bubble = true, className, activeClassName, style, activeStyle, disable = false } = props, attrs = __rest(props, ["children", "bubble", "className", "activeClassName", "style", "activeStyle", "disable"]);
|
|
17
17
|
// 如果激活样式和激活类都不存在,则设置激活默认样式
|
|
@@ -20,9 +20,14 @@ export function Clickable(props) {
|
|
|
20
20
|
opacity: 0.6,
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
const touchable = is(
|
|
23
|
+
const touchable = is('touchable');
|
|
24
24
|
const [boxClass, setBoxClass] = useState(className);
|
|
25
25
|
const [boxStyle, setBoxStyle] = useState(style);
|
|
26
|
+
// 监控属性的更新
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
setBoxClass(className);
|
|
29
|
+
setBoxStyle(style);
|
|
30
|
+
}, [className, style]);
|
|
26
31
|
// 标记是否正处于触摸状态
|
|
27
32
|
const touchRef = useRef(false);
|
|
28
33
|
const onStart = (event) => {
|
|
@@ -33,13 +38,13 @@ export function Clickable(props) {
|
|
|
33
38
|
event.stopPropagation();
|
|
34
39
|
}
|
|
35
40
|
// 激活目标样式
|
|
36
|
-
if (typeof activeClassName ===
|
|
37
|
-
setBoxClass(typeof boxClass ===
|
|
41
|
+
if (typeof activeClassName === 'string') {
|
|
42
|
+
setBoxClass(typeof boxClass === 'string'
|
|
38
43
|
? `${boxClass} ${activeClassName}`
|
|
39
44
|
: activeClassName);
|
|
40
45
|
}
|
|
41
|
-
if (typeof activeStyle ===
|
|
42
|
-
setBoxStyle(typeof boxStyle ===
|
|
46
|
+
if (typeof activeStyle === 'object') {
|
|
47
|
+
setBoxStyle(typeof boxStyle === 'object'
|
|
43
48
|
? Object.assign(Object.assign({}, boxStyle), activeStyle) : activeStyle);
|
|
44
49
|
}
|
|
45
50
|
}
|
|
@@ -56,9 +61,9 @@ export function Clickable(props) {
|
|
|
56
61
|
useEffect(() => {
|
|
57
62
|
if (!disable && !touchable) {
|
|
58
63
|
const doc = document.documentElement;
|
|
59
|
-
doc.addEventListener(
|
|
64
|
+
doc.addEventListener('mouseup', onEnd);
|
|
60
65
|
return () => {
|
|
61
|
-
doc.removeEventListener(
|
|
66
|
+
doc.removeEventListener('mouseup', onEnd);
|
|
62
67
|
};
|
|
63
68
|
}
|
|
64
69
|
}, [disable, touchable, onEnd]);
|
package/build/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { setContextValue, getContextValue } from "./context";
|
|
|
3
3
|
export { jsonp } from "./utils/jsonp";
|
|
4
4
|
export { uniqKey } from "./utils/uniqKey";
|
|
5
5
|
export { ago } from "./utils/ago";
|
|
6
|
-
export { GET, POST, sendJSON, sugarSend, sendRequest, buildUrlByOption } from "./utils/request";
|
|
6
|
+
export { GET, POST, sendJSON, sugarSend, sendRequest, buildUrlByOption, registerHostAlias } from "./utils/request";
|
|
7
7
|
export { calendarTable } from "./utils/calendarTable";
|
|
8
8
|
export { Countdown } from "./utils/Countdown";
|
|
9
9
|
export { defaultScroll } from "./utils/defaultScroll";
|
package/build/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { setContextValue, getContextValue } from "./context";
|
|
|
3
3
|
export { jsonp } from "./utils/jsonp";
|
|
4
4
|
export { uniqKey } from "./utils/uniqKey";
|
|
5
5
|
export { ago } from "./utils/ago";
|
|
6
|
-
export { GET, POST, sendJSON, sugarSend, sendRequest, buildUrlByOption } from "./utils/request";
|
|
6
|
+
export { GET, POST, sendJSON, sugarSend, sendRequest, buildUrlByOption, registerHostAlias } from "./utils/request";
|
|
7
7
|
export { calendarTable } from "./utils/calendarTable";
|
|
8
8
|
export { Countdown } from "./utils/Countdown";
|
|
9
9
|
export { defaultScroll } from "./utils/defaultScroll";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clxx",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"description": "Basic JS library for mobile devices",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"module": "./build/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"start": "tsc -w --pretty",
|
|
12
|
-
"build": "
|
|
12
|
+
"build": "rm -rfv ./build && tsc"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|