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.
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React from 'react';
2
2
  /**
3
3
  * 可触摸元素的属性,兼容PC
4
4
  */
@@ -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 "react";
14
- import { is } from "../utils/is";
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("touchable");
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 === "string") {
37
- setBoxClass(typeof boxClass === "string"
41
+ if (typeof activeClassName === 'string') {
42
+ setBoxClass(typeof boxClass === 'string'
38
43
  ? `${boxClass} ${activeClassName}`
39
44
  : activeClassName);
40
45
  }
41
- if (typeof activeStyle === "object") {
42
- setBoxStyle(typeof boxStyle === "object"
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("mouseup", onEnd);
64
+ doc.addEventListener('mouseup', onEnd);
60
65
  return () => {
61
- doc.removeEventListener("mouseup", onEnd);
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.6",
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": "node ./scripts/clear.js && tsc"
12
+ "build": "rm -rfv ./build && tsc"
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",