clxx 2.1.1 → 2.1.3
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 +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/utils/cssUtil.d.ts +2 -2
- package/build/utils/cssUtil.js +24 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
- [`is`](./src/utils/is.ts):一些简单的环境判断
|
|
12
12
|
- [`jsonp`](./src/utils/jsonp.ts):发送一个 jsonp 请求
|
|
13
13
|
- [`GET,POST`](./src/utils/request.ts):ajax 请求的简单封装
|
|
14
|
-
- [`
|
|
14
|
+
- [`tick`](./src/utils/tick.ts):嘀嗒器,每帧都会执行
|
|
15
15
|
- [`uniqKey`](./src/utils/uniqKey.ts):生成一个全局唯一的 key
|
|
16
16
|
- [`waitUntil`](./src/utils/wait.ts):执行某种检测,直接条件为真或者超时才返回
|
|
17
17
|
|
package/build/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { is } from './utils/is';
|
|
|
11
11
|
export { waitFor, waitUntil } from './utils/wait';
|
|
12
12
|
export { normalizeUnit, splitValue, adaptive } from './utils/cssUtil';
|
|
13
13
|
export { createApp, history, getHistory } from './utils/createApp';
|
|
14
|
+
export { createPortalDOM } from './utils/dom';
|
|
14
15
|
export { useInterval } from './Effect/useInterval';
|
|
15
16
|
export { useTick } from './Effect/useTick';
|
|
16
17
|
export { Ago } from './Ago';
|
package/build/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export { is } from './utils/is';
|
|
|
11
11
|
export { waitFor, waitUntil } from './utils/wait';
|
|
12
12
|
export { normalizeUnit, splitValue, adaptive } from './utils/cssUtil';
|
|
13
13
|
export { createApp, history, getHistory } from './utils/createApp';
|
|
14
|
+
export { createPortalDOM } from './utils/dom';
|
|
14
15
|
export { useInterval } from './Effect/useInterval';
|
|
15
16
|
export { useTick } from './Effect/useTick';
|
|
16
17
|
export { Ago } from './Ago';
|
package/build/utils/cssUtil.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Interpolation, Theme } from '@emotion/react';
|
|
2
2
|
/**
|
|
3
3
|
* 匹配所有的CSS数值类型的值
|
|
4
4
|
*/
|
|
@@ -39,4 +39,4 @@ export declare function splitValue(value: number | string, defaultUnit?: string)
|
|
|
39
39
|
* @param style
|
|
40
40
|
* @returns
|
|
41
41
|
*/
|
|
42
|
-
export declare function adaptive(style:
|
|
42
|
+
export declare function adaptive(style: Record<string, Interpolation<Theme>>): import("@emotion/utils").SerializedStyles;
|
package/build/utils/cssUtil.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { css } from
|
|
2
|
-
import { getContextValue } from
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { getContextValue } from '../context';
|
|
3
3
|
/**
|
|
4
4
|
* 匹配所有的CSS数值类型的值
|
|
5
5
|
*/
|
|
@@ -10,11 +10,11 @@ export const CSSValueReg = /^((?:\-)?(?:\d+\.?|\.\d+|\d+\.\d+))([a-zA-Z%]*)$/;
|
|
|
10
10
|
* @param value 长度值
|
|
11
11
|
* @param defaultUnit 默认长度值单位
|
|
12
12
|
*/
|
|
13
|
-
export function normalizeUnit(value, defaultUnit =
|
|
14
|
-
if (typeof value ===
|
|
13
|
+
export function normalizeUnit(value, defaultUnit = 'px') {
|
|
14
|
+
if (typeof value === 'number') {
|
|
15
15
|
return value + defaultUnit;
|
|
16
16
|
}
|
|
17
|
-
if (typeof value ===
|
|
17
|
+
if (typeof value === 'string') {
|
|
18
18
|
const result = value.match(CSSValueReg);
|
|
19
19
|
if (Array.isArray(result)) {
|
|
20
20
|
return result[2]
|
|
@@ -39,17 +39,17 @@ export function normalizeUnit(value, defaultUnit = "px") {
|
|
|
39
39
|
* @param value
|
|
40
40
|
* @param defaultUnit
|
|
41
41
|
*/
|
|
42
|
-
export function splitValue(value, defaultUnit =
|
|
43
|
-
if (typeof value ===
|
|
42
|
+
export function splitValue(value, defaultUnit = 'px') {
|
|
43
|
+
if (typeof value === 'number') {
|
|
44
44
|
return { num: value, unit: defaultUnit };
|
|
45
45
|
}
|
|
46
|
-
if (typeof value ===
|
|
46
|
+
if (typeof value === 'string') {
|
|
47
47
|
const result = value.match(CSSValueReg);
|
|
48
48
|
if (Array.isArray(result)) {
|
|
49
49
|
return { num: parseFloat(result[1]), unit: result[2] || defaultUnit };
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
throw new Error(
|
|
52
|
+
throw new Error('Invalid numeric format');
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* 生成自适应的样式,仅供库内部使用
|
|
@@ -65,13 +65,24 @@ export function adaptive(style) {
|
|
|
65
65
|
const normal = {};
|
|
66
66
|
for (let name in style) {
|
|
67
67
|
let value = style[name];
|
|
68
|
-
if (typeof value !==
|
|
68
|
+
if (typeof value !== 'number') {
|
|
69
|
+
normal[name] = value;
|
|
70
|
+
}
|
|
71
|
+
else if ([
|
|
72
|
+
'flex',
|
|
73
|
+
'flexGrow',
|
|
74
|
+
'flexShrink',
|
|
75
|
+
'lineHeight',
|
|
76
|
+
'fontWeight',
|
|
77
|
+
'zIndex',
|
|
78
|
+
].includes(name) &&
|
|
79
|
+
typeof value === 'number') {
|
|
69
80
|
normal[name] = value;
|
|
70
81
|
}
|
|
71
82
|
else {
|
|
72
|
-
normal[name] = (value * 100) / 750 +
|
|
73
|
-
max[name] = (value * ctx.maxDocWidth) / 750 +
|
|
74
|
-
min[name] = (value * ctx.minDocWidth) / 750 +
|
|
83
|
+
normal[name] = (value * 100) / 750 + 'vw';
|
|
84
|
+
max[name] = (value * ctx.maxDocWidth) / 750 + 'px';
|
|
85
|
+
min[name] = (value * ctx.minDocWidth) / 750 + 'px';
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
return css(Object.assign(Object.assign({}, normal), { [`@media (min-width: ${ctx.maxDocWidth}px)`]: max, [`@media (max-width: ${ctx.minDocWidth}px)`]: min }));
|