@ray-js/framework-shared 0.3.0-beta.1c347991
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 -0
- package/lib/emitter/index.android.js +1 -0
- package/lib/emitter/index.d.ts +9 -0
- package/lib/emitter/index.ios.js +1 -0
- package/lib/emitter/index.js +57 -0
- package/lib/emitter/index.tuya.js +57 -0
- package/lib/emitter/index.web.js +57 -0
- package/lib/emitter/index.wechat.js +57 -0
- package/lib/filterProps/index.android.js +1 -0
- package/lib/filterProps/index.d.ts +2 -0
- package/lib/filterProps/index.ios.js +1 -0
- package/lib/filterProps/index.js +30 -0
- package/lib/filterProps/index.tuya.js +30 -0
- package/lib/filterProps/index.web.js +30 -0
- package/lib/filterProps/index.wechat.js +30 -0
- package/lib/index.android.js +1 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.ios.js +1 -0
- package/lib/index.js +9 -0
- package/lib/index.tuya.js +9 -0
- package/lib/index.web.js +9 -0
- package/lib/index.wechat.js +9 -0
- package/lib/inlineStyle/CSSProperty.android.js +1 -0
- package/lib/inlineStyle/CSSProperty.d.ts +6 -0
- package/lib/inlineStyle/CSSProperty.ios.js +1 -0
- package/lib/inlineStyle/CSSProperty.js +78 -0
- package/lib/inlineStyle/CSSProperty.tuya.js +78 -0
- package/lib/inlineStyle/CSSProperty.web.js +78 -0
- package/lib/inlineStyle/CSSProperty.wechat.js +78 -0
- package/lib/inlineStyle/index.android.js +1 -0
- package/lib/inlineStyle/index.d.ts +7 -0
- package/lib/inlineStyle/index.ios.js +1 -0
- package/lib/inlineStyle/index.js +52 -0
- package/lib/inlineStyle/index.tuya.js +49 -0
- package/lib/inlineStyle/index.web.js +49 -0
- package/lib/inlineStyle/index.wechat.js +49 -0
- package/lib/plainStyle/index.android.js +1 -0
- package/lib/plainStyle/index.d.ts +2 -0
- package/lib/plainStyle/index.ios.js +1 -0
- package/lib/plainStyle/index.js +52 -0
- package/lib/plainStyle/index.tuya.js +52 -0
- package/lib/plainStyle/index.web.js +52 -0
- package/lib/plainStyle/index.wechat.js +52 -0
- package/lib/useInterval/index.android.js +1 -0
- package/lib/useInterval/index.d.ts +4 -0
- package/lib/useInterval/index.ios.js +1 -0
- package/lib/useInterval/index.js +24 -0
- package/lib/useInterval/index.tuya.js +24 -0
- package/lib/useInterval/index.web.js +24 -0
- package/lib/useInterval/index.wechat.js +24 -0
- package/lib/useStylesheet/index.android.js +1 -0
- package/lib/useStylesheet/index.d.ts +2 -0
- package/lib/useStylesheet/index.ios.js +1 -0
- package/lib/useStylesheet/index.js +24 -0
- package/lib/useStylesheet/index.tuya.js +24 -0
- package/lib/useStylesheet/index.web.js +24 -0
- package/lib/useStylesheet/index.wechat.js +24 -0
- package/lib/useThrottle/index.android.js +1 -0
- package/lib/useThrottle/index.d.ts +5 -0
- package/lib/useThrottle/index.ios.js +1 -0
- package/lib/useThrottle/index.js +36 -0
- package/lib/useThrottle/index.tuya.js +36 -0
- package/lib/useThrottle/index.web.js +36 -0
- package/lib/useThrottle/index.wechat.js +36 -0
- package/lib/useTouch/index.android.js +1 -0
- package/lib/useTouch/index.d.ts +43 -0
- package/lib/useTouch/index.ios.js +1 -0
- package/lib/useTouch/index.js +137 -0
- package/lib/useTouch/index.tuya.js +125 -0
- package/lib/useTouch/index.web.js +137 -0
- package/lib/useTouch/index.wechat.js +125 -0
- package/lib/useTransition/index.android.js +1 -0
- package/lib/useTransition/index.d.ts +17 -0
- package/lib/useTransition/index.ios.js +1 -0
- package/lib/useTransition/index.js +53 -0
- package/lib/useTransition/index.tuya.js +53 -0
- package/lib/useTransition/index.web.js +53 -0
- package/lib/useTransition/index.wechat.js +53 -0
- package/package.json +41 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
import "core-js/modules/es.object.to-string.js";
|
2
|
+
// https://github.com/facebook/react/blob/master/packages/react-dom/src/shared/CSSProperty.js
|
3
|
+
|
4
|
+
/**
|
5
|
+
* CSS properties which accept numbers but are not in units of "px".
|
6
|
+
*/
|
7
|
+
export var isUnitlessNumber = {
|
8
|
+
animationIterationCount: true,
|
9
|
+
borderImageOutset: true,
|
10
|
+
borderImageSlice: true,
|
11
|
+
borderImageWidth: true,
|
12
|
+
boxFlex: true,
|
13
|
+
boxFlexGroup: true,
|
14
|
+
boxOrdinalGroup: true,
|
15
|
+
columnCount: true,
|
16
|
+
columns: true,
|
17
|
+
flex: true,
|
18
|
+
flexGrow: true,
|
19
|
+
flexPositive: true,
|
20
|
+
flexShrink: true,
|
21
|
+
flexNegative: true,
|
22
|
+
flexOrder: true,
|
23
|
+
gridArea: true,
|
24
|
+
gridRow: true,
|
25
|
+
gridRowEnd: true,
|
26
|
+
gridRowSpan: true,
|
27
|
+
gridRowStart: true,
|
28
|
+
gridColumn: true,
|
29
|
+
gridColumnEnd: true,
|
30
|
+
gridColumnSpan: true,
|
31
|
+
gridColumnStart: true,
|
32
|
+
fontWeight: true,
|
33
|
+
lineClamp: true,
|
34
|
+
lineHeight: true,
|
35
|
+
opacity: true,
|
36
|
+
order: true,
|
37
|
+
orphans: true,
|
38
|
+
tabSize: true,
|
39
|
+
widows: true,
|
40
|
+
zIndex: true,
|
41
|
+
zoom: true,
|
42
|
+
// SVG-related properties
|
43
|
+
fillOpacity: true,
|
44
|
+
floodOpacity: true,
|
45
|
+
stopOpacity: true,
|
46
|
+
strokeDasharray: true,
|
47
|
+
strokeDashoffset: true,
|
48
|
+
strokeMiterlimit: true,
|
49
|
+
strokeOpacity: true,
|
50
|
+
strokeWidth: true
|
51
|
+
};
|
52
|
+
/**
|
53
|
+
* @param {string} prefix vendor-specific prefix, eg: Webkit
|
54
|
+
* @param {string} key style name, eg: transitionDuration
|
55
|
+
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
|
56
|
+
* WebkitTransitionDuration
|
57
|
+
*/
|
58
|
+
|
59
|
+
function prefixKey(prefix, key) {
|
60
|
+
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
61
|
+
}
|
62
|
+
/**
|
63
|
+
* Support style names that may come passed in prefixed by adding permutations
|
64
|
+
* of vendor prefixes.
|
65
|
+
*/
|
66
|
+
|
67
|
+
|
68
|
+
var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
|
69
|
+
|
70
|
+
var _loop = function (prop) {
|
71
|
+
prefixes.forEach(function (prefix) {
|
72
|
+
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
|
73
|
+
});
|
74
|
+
};
|
75
|
+
|
76
|
+
for (var prop in isUnitlessNumber) {
|
77
|
+
_loop(prop);
|
78
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import "core-js/modules/es.object.to-string.js";
|
2
|
+
// https://github.com/facebook/react/blob/master/packages/react-dom/src/shared/CSSProperty.js
|
3
|
+
|
4
|
+
/**
|
5
|
+
* CSS properties which accept numbers but are not in units of "px".
|
6
|
+
*/
|
7
|
+
export var isUnitlessNumber = {
|
8
|
+
animationIterationCount: true,
|
9
|
+
borderImageOutset: true,
|
10
|
+
borderImageSlice: true,
|
11
|
+
borderImageWidth: true,
|
12
|
+
boxFlex: true,
|
13
|
+
boxFlexGroup: true,
|
14
|
+
boxOrdinalGroup: true,
|
15
|
+
columnCount: true,
|
16
|
+
columns: true,
|
17
|
+
flex: true,
|
18
|
+
flexGrow: true,
|
19
|
+
flexPositive: true,
|
20
|
+
flexShrink: true,
|
21
|
+
flexNegative: true,
|
22
|
+
flexOrder: true,
|
23
|
+
gridArea: true,
|
24
|
+
gridRow: true,
|
25
|
+
gridRowEnd: true,
|
26
|
+
gridRowSpan: true,
|
27
|
+
gridRowStart: true,
|
28
|
+
gridColumn: true,
|
29
|
+
gridColumnEnd: true,
|
30
|
+
gridColumnSpan: true,
|
31
|
+
gridColumnStart: true,
|
32
|
+
fontWeight: true,
|
33
|
+
lineClamp: true,
|
34
|
+
lineHeight: true,
|
35
|
+
opacity: true,
|
36
|
+
order: true,
|
37
|
+
orphans: true,
|
38
|
+
tabSize: true,
|
39
|
+
widows: true,
|
40
|
+
zIndex: true,
|
41
|
+
zoom: true,
|
42
|
+
// SVG-related properties
|
43
|
+
fillOpacity: true,
|
44
|
+
floodOpacity: true,
|
45
|
+
stopOpacity: true,
|
46
|
+
strokeDasharray: true,
|
47
|
+
strokeDashoffset: true,
|
48
|
+
strokeMiterlimit: true,
|
49
|
+
strokeOpacity: true,
|
50
|
+
strokeWidth: true
|
51
|
+
};
|
52
|
+
/**
|
53
|
+
* @param {string} prefix vendor-specific prefix, eg: Webkit
|
54
|
+
* @param {string} key style name, eg: transitionDuration
|
55
|
+
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
|
56
|
+
* WebkitTransitionDuration
|
57
|
+
*/
|
58
|
+
|
59
|
+
function prefixKey(prefix, key) {
|
60
|
+
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
61
|
+
}
|
62
|
+
/**
|
63
|
+
* Support style names that may come passed in prefixed by adding permutations
|
64
|
+
* of vendor prefixes.
|
65
|
+
*/
|
66
|
+
|
67
|
+
|
68
|
+
var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
|
69
|
+
|
70
|
+
var _loop = function (prop) {
|
71
|
+
prefixes.forEach(function (prefix) {
|
72
|
+
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
|
73
|
+
});
|
74
|
+
};
|
75
|
+
|
76
|
+
for (var prop in isUnitlessNumber) {
|
77
|
+
_loop(prop);
|
78
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.inlineStyle=inlineStyle;var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _CSSProperty=require("./CSSProperty");var isMiniProgram=false;var isWeb=false;function inlineStyle(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}var allStyle=args.filter(Boolean);if(allStyle.length==0)return undefined;var style=Object.assign.apply(Object,[{}].concat((0,_toConsumableArray2.default)(allStyle)));Object.keys(style).forEach(function(key){var value=style[key];if(typeof value==='undefined'){delete style[key];}else if(!(key in _CSSProperty.isUnitlessNumber)){if(!Number.isNaN(Number(value))){style[key]=value+"rpx";}else if(/\b([.\d]+)rpx\b/.test(value)&&isWeb){style[key]=value.replace(/\b([.\d]+)rpx\b/g,function(match,x){var size=Number(x);return size/100+"rem";});}}});return style;}
|
@@ -0,0 +1 @@
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.inlineStyle=inlineStyle;var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _CSSProperty=require("./CSSProperty");var isMiniProgram=false;var isWeb=false;function inlineStyle(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}var allStyle=args.filter(Boolean);if(allStyle.length==0)return undefined;var style=Object.assign.apply(Object,[{}].concat((0,_toConsumableArray2.default)(allStyle)));Object.keys(style).forEach(function(key){var value=style[key];if(typeof value==='undefined'){delete style[key];}else if(!(key in _CSSProperty.isUnitlessNumber)){if(!Number.isNaN(Number(value))){style[key]=value+"rpx";}else if(/\b([.\d]+)rpx\b/.test(value)&&isWeb){style[key]=value.replace(/\b([.\d]+)rpx\b/g,function(match,x){var size=Number(x);return size/100+"rem";});}}});return style;}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
2
|
+
import "core-js/modules/es.array.filter.js";
|
3
|
+
import "core-js/modules/es.object.to-string.js";
|
4
|
+
import "core-js/modules/es.object.assign.js";
|
5
|
+
import "core-js/modules/es.array.concat.js";
|
6
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
7
|
+
import "core-js/modules/es.object.keys.js";
|
8
|
+
import "core-js/modules/es.number.is-nan.js";
|
9
|
+
import "core-js/modules/es.number.constructor.js";
|
10
|
+
import "core-js/modules/es.regexp.exec.js";
|
11
|
+
import "core-js/modules/es.regexp.test.js";
|
12
|
+
import "core-js/modules/es.string.replace.js";
|
13
|
+
import { isWeb } from '@ray-js/env';
|
14
|
+
import { isUnitlessNumber } from './CSSProperty';
|
15
|
+
/**
|
16
|
+
* 根据平台转换内敛样式单位, 自适应单位
|
17
|
+
* 需要关闭 remax 的内敛样式转换规则
|
18
|
+
* @param int 内敛样式
|
19
|
+
*/
|
20
|
+
|
21
|
+
export function inlineStyle() {
|
22
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
23
|
+
args[_key] = arguments[_key];
|
24
|
+
}
|
25
|
+
|
26
|
+
var allStyle = args.filter(Boolean);
|
27
|
+
if (allStyle.length == 0) return undefined;
|
28
|
+
var style = Object.assign.apply(Object, [{}].concat(_toConsumableArray(allStyle)));
|
29
|
+
Object.keys(style).forEach(function (key) {
|
30
|
+
var value = style[key];
|
31
|
+
|
32
|
+
if (typeof value === 'undefined') {
|
33
|
+
delete style[key];
|
34
|
+
} // 整数类型替换为
|
35
|
+
else if (!(key in isUnitlessNumber)) {
|
36
|
+
if (!Number.isNaN(Number(value))) {
|
37
|
+
if (isWeb) {
|
38
|
+
style[key] = "".concat(value / 100, "rem");
|
39
|
+
} else {
|
40
|
+
style[key] = "".concat(value, "rpx");
|
41
|
+
}
|
42
|
+
} else if (/\b([.\d]+)rpx\b/.test(value) && isWeb) {
|
43
|
+
// TODO: 支持 native 的样式抹平
|
44
|
+
style[key] = value.replace(/\b([.\d]+)rpx\b/g, function (match, x) {
|
45
|
+
var size = Number(x);
|
46
|
+
return "".concat(size / 100, "rem");
|
47
|
+
});
|
48
|
+
}
|
49
|
+
}
|
50
|
+
});
|
51
|
+
return style;
|
52
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
2
|
+
import "core-js/modules/es.array.filter.js";
|
3
|
+
import "core-js/modules/es.object.to-string.js";
|
4
|
+
import "core-js/modules/es.object.assign.js";
|
5
|
+
import "core-js/modules/es.array.concat.js";
|
6
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
7
|
+
import "core-js/modules/es.object.keys.js";
|
8
|
+
import "core-js/modules/es.number.is-nan.js";
|
9
|
+
import "core-js/modules/es.number.constructor.js";
|
10
|
+
import "core-js/modules/es.regexp.exec.js";
|
11
|
+
import "core-js/modules/es.regexp.test.js";
|
12
|
+
import "core-js/modules/es.string.replace.js";
|
13
|
+
var isMiniProgram = true;
|
14
|
+
var isWeb = false;
|
15
|
+
import { isUnitlessNumber } from './CSSProperty';
|
16
|
+
/**
|
17
|
+
* 根据平台转换内敛样式单位, 自适应单位
|
18
|
+
* 需要关闭 remax 的内敛样式转换规则
|
19
|
+
* @param int 内敛样式
|
20
|
+
*/
|
21
|
+
|
22
|
+
export function inlineStyle() {
|
23
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
24
|
+
args[_key] = arguments[_key];
|
25
|
+
}
|
26
|
+
|
27
|
+
var allStyle = args.filter(Boolean);
|
28
|
+
if (allStyle.length == 0) return undefined;
|
29
|
+
var style = Object.assign.apply(Object, [{}].concat(_toConsumableArray(allStyle)));
|
30
|
+
Object.keys(style).forEach(function (key) {
|
31
|
+
var value = style[key];
|
32
|
+
|
33
|
+
if (typeof value === 'undefined') {
|
34
|
+
delete style[key];
|
35
|
+
} // 整数类型替换为
|
36
|
+
else if (!(key in isUnitlessNumber)) {
|
37
|
+
if (!Number.isNaN(Number(value))) {
|
38
|
+
style[key] = "".concat(value, "rpx");
|
39
|
+
} else if (/\b([.\d]+)rpx\b/.test(value) && isWeb) {
|
40
|
+
// TODO: 支持 native 的样式抹平
|
41
|
+
style[key] = value.replace(/\b([.\d]+)rpx\b/g, function (match, x) {
|
42
|
+
var size = Number(x);
|
43
|
+
return "".concat(size / 100, "rem");
|
44
|
+
});
|
45
|
+
}
|
46
|
+
}
|
47
|
+
});
|
48
|
+
return style;
|
49
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
2
|
+
import "core-js/modules/es.array.filter.js";
|
3
|
+
import "core-js/modules/es.object.to-string.js";
|
4
|
+
import "core-js/modules/es.object.assign.js";
|
5
|
+
import "core-js/modules/es.array.concat.js";
|
6
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
7
|
+
import "core-js/modules/es.object.keys.js";
|
8
|
+
import "core-js/modules/es.number.is-nan.js";
|
9
|
+
import "core-js/modules/es.number.constructor.js";
|
10
|
+
import "core-js/modules/es.regexp.exec.js";
|
11
|
+
import "core-js/modules/es.regexp.test.js";
|
12
|
+
import "core-js/modules/es.string.replace.js";
|
13
|
+
var isMiniProgram = false;
|
14
|
+
var isWeb = true;
|
15
|
+
import { isUnitlessNumber } from './CSSProperty';
|
16
|
+
/**
|
17
|
+
* 根据平台转换内敛样式单位, 自适应单位
|
18
|
+
* 需要关闭 remax 的内敛样式转换规则
|
19
|
+
* @param int 内敛样式
|
20
|
+
*/
|
21
|
+
|
22
|
+
export function inlineStyle() {
|
23
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
24
|
+
args[_key] = arguments[_key];
|
25
|
+
}
|
26
|
+
|
27
|
+
var allStyle = args.filter(Boolean);
|
28
|
+
if (allStyle.length == 0) return undefined;
|
29
|
+
var style = Object.assign.apply(Object, [{}].concat(_toConsumableArray(allStyle)));
|
30
|
+
Object.keys(style).forEach(function (key) {
|
31
|
+
var value = style[key];
|
32
|
+
|
33
|
+
if (typeof value === 'undefined') {
|
34
|
+
delete style[key];
|
35
|
+
} // 整数类型替换为
|
36
|
+
else if (!(key in isUnitlessNumber)) {
|
37
|
+
if (!Number.isNaN(Number(value))) {
|
38
|
+
style[key] = "".concat(value / 100, "rem");
|
39
|
+
} else if (/\b([.\d]+)rpx\b/.test(value) && isWeb) {
|
40
|
+
// TODO: 支持 native 的样式抹平
|
41
|
+
style[key] = value.replace(/\b([.\d]+)rpx\b/g, function (match, x) {
|
42
|
+
var size = Number(x);
|
43
|
+
return "".concat(size / 100, "rem");
|
44
|
+
});
|
45
|
+
}
|
46
|
+
}
|
47
|
+
});
|
48
|
+
return style;
|
49
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
2
|
+
import "core-js/modules/es.array.filter.js";
|
3
|
+
import "core-js/modules/es.object.to-string.js";
|
4
|
+
import "core-js/modules/es.object.assign.js";
|
5
|
+
import "core-js/modules/es.array.concat.js";
|
6
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
7
|
+
import "core-js/modules/es.object.keys.js";
|
8
|
+
import "core-js/modules/es.number.is-nan.js";
|
9
|
+
import "core-js/modules/es.number.constructor.js";
|
10
|
+
import "core-js/modules/es.regexp.exec.js";
|
11
|
+
import "core-js/modules/es.regexp.test.js";
|
12
|
+
import "core-js/modules/es.string.replace.js";
|
13
|
+
var isMiniProgram = true;
|
14
|
+
var isWeb = false;
|
15
|
+
import { isUnitlessNumber } from './CSSProperty';
|
16
|
+
/**
|
17
|
+
* 根据平台转换内敛样式单位, 自适应单位
|
18
|
+
* 需要关闭 remax 的内敛样式转换规则
|
19
|
+
* @param int 内敛样式
|
20
|
+
*/
|
21
|
+
|
22
|
+
export function inlineStyle() {
|
23
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
24
|
+
args[_key] = arguments[_key];
|
25
|
+
}
|
26
|
+
|
27
|
+
var allStyle = args.filter(Boolean);
|
28
|
+
if (allStyle.length == 0) return undefined;
|
29
|
+
var style = Object.assign.apply(Object, [{}].concat(_toConsumableArray(allStyle)));
|
30
|
+
Object.keys(style).forEach(function (key) {
|
31
|
+
var value = style[key];
|
32
|
+
|
33
|
+
if (typeof value === 'undefined') {
|
34
|
+
delete style[key];
|
35
|
+
} // 整数类型替换为
|
36
|
+
else if (!(key in isUnitlessNumber)) {
|
37
|
+
if (!Number.isNaN(Number(value))) {
|
38
|
+
style[key] = "".concat(value, "rpx");
|
39
|
+
} else if (/\b([.\d]+)rpx\b/.test(value) && isWeb) {
|
40
|
+
// TODO: 支持 native 的样式抹平
|
41
|
+
style[key] = value.replace(/\b([.\d]+)rpx\b/g, function (match, x) {
|
42
|
+
var size = Number(x);
|
43
|
+
return "".concat(size / 100, "rem");
|
44
|
+
});
|
45
|
+
}
|
46
|
+
}
|
47
|
+
});
|
48
|
+
return style;
|
49
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.plainStyle=void 0;var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var vendorPrefixes=['webkit','moz','ms','o'];var transformReactStyleKey=function(key){var _styleValue;if(key!==null&&key!==void 0&&key.startsWith('--')){return key;}var styleValue=key.replace(/\.?([A-Z]+)/g,function(_x,y){return"-"+y.toLowerCase();});if((_styleValue=styleValue)!==null&&_styleValue!==void 0&&_styleValue.startsWith('-')){var firstWord=styleValue.split('-').filter(function(s){return s;})[0];styleValue=styleValue.replace(/^-/,'');if(vendorPrefixes.find(function(prefix){return prefix===firstWord;})){styleValue="-"+styleValue;}}return styleValue;};var plainStyle=function(style){if(!style){return'';}return Object.keys(style).reduce(function(acc,key){var value=style[key];return[].concat((0,_toConsumableArray2.default)(acc),[transformReactStyleKey(key)+":"+value+";"]);},[]).join('\n');};exports.plainStyle=plainStyle;
|
@@ -0,0 +1 @@
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.plainStyle=void 0;var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var vendorPrefixes=['webkit','moz','ms','o'];var transformReactStyleKey=function(key){var _styleValue;if(key!==null&&key!==void 0&&key.startsWith('--')){return key;}var styleValue=key.replace(/\.?([A-Z]+)/g,function(_x,y){return"-"+y.toLowerCase();});if((_styleValue=styleValue)!==null&&_styleValue!==void 0&&_styleValue.startsWith('-')){var firstWord=styleValue.split('-').filter(function(s){return s;})[0];styleValue=styleValue.replace(/^-/,'');if(vendorPrefixes.find(function(prefix){return prefix===firstWord;})){styleValue="-"+styleValue;}}return styleValue;};var plainStyle=function(style){if(!style){return'';}return Object.keys(style).reduce(function(acc,key){var value=style[key];return[].concat((0,_toConsumableArray2.default)(acc),[transformReactStyleKey(key)+":"+value+";"]);},[]).join('\n');};exports.plainStyle=plainStyle;
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
2
|
+
import "core-js/modules/es.string.starts-with.js";
|
3
|
+
import "core-js/modules/es.regexp.exec.js";
|
4
|
+
import "core-js/modules/es.string.replace.js";
|
5
|
+
import "core-js/modules/es.array.filter.js";
|
6
|
+
import "core-js/modules/es.object.to-string.js";
|
7
|
+
import "core-js/modules/es.string.split.js";
|
8
|
+
import "core-js/modules/es.array.find.js";
|
9
|
+
import "core-js/modules/es.array.join.js";
|
10
|
+
import "core-js/modules/es.array.reduce.js";
|
11
|
+
import "core-js/modules/es.object.keys.js";
|
12
|
+
import "core-js/modules/es.array.concat.js";
|
13
|
+
var vendorPrefixes = ['webkit', 'moz', 'ms', 'o'];
|
14
|
+
|
15
|
+
var transformReactStyleKey = function (key) {
|
16
|
+
var _styleValue;
|
17
|
+
|
18
|
+
// css3 var
|
19
|
+
if (key !== null && key !== void 0 && key.startsWith('--')) {
|
20
|
+
return key;
|
21
|
+
}
|
22
|
+
|
23
|
+
var styleValue = key.replace(/\.?([A-Z]+)/g, function (_x, y) {
|
24
|
+
return "-".concat(y.toLowerCase());
|
25
|
+
}); // vendor prefix
|
26
|
+
|
27
|
+
if ((_styleValue = styleValue) !== null && _styleValue !== void 0 && _styleValue.startsWith('-')) {
|
28
|
+
var firstWord = styleValue.split('-').filter(function (s) {
|
29
|
+
return s;
|
30
|
+
})[0];
|
31
|
+
styleValue = styleValue.replace(/^-/, '');
|
32
|
+
|
33
|
+
if (vendorPrefixes.find(function (prefix) {
|
34
|
+
return prefix === firstWord;
|
35
|
+
})) {
|
36
|
+
styleValue = "-".concat(styleValue);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
return styleValue;
|
41
|
+
};
|
42
|
+
|
43
|
+
export var plainStyle = function (style) {
|
44
|
+
if (!style) {
|
45
|
+
return '';
|
46
|
+
}
|
47
|
+
|
48
|
+
return Object.keys(style).reduce(function (acc, key) {
|
49
|
+
var value = style[key];
|
50
|
+
return [].concat(_toConsumableArray(acc), ["".concat(transformReactStyleKey(key), ":").concat(value, ";")]);
|
51
|
+
}, []).join('\n');
|
52
|
+
};
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
2
|
+
import "core-js/modules/es.string.starts-with.js";
|
3
|
+
import "core-js/modules/es.regexp.exec.js";
|
4
|
+
import "core-js/modules/es.string.replace.js";
|
5
|
+
import "core-js/modules/es.array.filter.js";
|
6
|
+
import "core-js/modules/es.object.to-string.js";
|
7
|
+
import "core-js/modules/es.string.split.js";
|
8
|
+
import "core-js/modules/es.array.find.js";
|
9
|
+
import "core-js/modules/es.array.join.js";
|
10
|
+
import "core-js/modules/es.array.reduce.js";
|
11
|
+
import "core-js/modules/es.object.keys.js";
|
12
|
+
import "core-js/modules/es.array.concat.js";
|
13
|
+
var vendorPrefixes = ['webkit', 'moz', 'ms', 'o'];
|
14
|
+
|
15
|
+
var transformReactStyleKey = function (key) {
|
16
|
+
var _styleValue;
|
17
|
+
|
18
|
+
// css3 var
|
19
|
+
if (key !== null && key !== void 0 && key.startsWith('--')) {
|
20
|
+
return key;
|
21
|
+
}
|
22
|
+
|
23
|
+
var styleValue = key.replace(/\.?([A-Z]+)/g, function (_x, y) {
|
24
|
+
return "-".concat(y.toLowerCase());
|
25
|
+
}); // vendor prefix
|
26
|
+
|
27
|
+
if ((_styleValue = styleValue) !== null && _styleValue !== void 0 && _styleValue.startsWith('-')) {
|
28
|
+
var firstWord = styleValue.split('-').filter(function (s) {
|
29
|
+
return s;
|
30
|
+
})[0];
|
31
|
+
styleValue = styleValue.replace(/^-/, '');
|
32
|
+
|
33
|
+
if (vendorPrefixes.find(function (prefix) {
|
34
|
+
return prefix === firstWord;
|
35
|
+
})) {
|
36
|
+
styleValue = "-".concat(styleValue);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
return styleValue;
|
41
|
+
};
|
42
|
+
|
43
|
+
export var plainStyle = function (style) {
|
44
|
+
if (!style) {
|
45
|
+
return '';
|
46
|
+
}
|
47
|
+
|
48
|
+
return Object.keys(style).reduce(function (acc, key) {
|
49
|
+
var value = style[key];
|
50
|
+
return [].concat(_toConsumableArray(acc), ["".concat(transformReactStyleKey(key), ":").concat(value, ";")]);
|
51
|
+
}, []).join('\n');
|
52
|
+
};
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
2
|
+
import "core-js/modules/es.string.starts-with.js";
|
3
|
+
import "core-js/modules/es.regexp.exec.js";
|
4
|
+
import "core-js/modules/es.string.replace.js";
|
5
|
+
import "core-js/modules/es.array.filter.js";
|
6
|
+
import "core-js/modules/es.object.to-string.js";
|
7
|
+
import "core-js/modules/es.string.split.js";
|
8
|
+
import "core-js/modules/es.array.find.js";
|
9
|
+
import "core-js/modules/es.array.join.js";
|
10
|
+
import "core-js/modules/es.array.reduce.js";
|
11
|
+
import "core-js/modules/es.object.keys.js";
|
12
|
+
import "core-js/modules/es.array.concat.js";
|
13
|
+
var vendorPrefixes = ['webkit', 'moz', 'ms', 'o'];
|
14
|
+
|
15
|
+
var transformReactStyleKey = function (key) {
|
16
|
+
var _styleValue;
|
17
|
+
|
18
|
+
// css3 var
|
19
|
+
if (key !== null && key !== void 0 && key.startsWith('--')) {
|
20
|
+
return key;
|
21
|
+
}
|
22
|
+
|
23
|
+
var styleValue = key.replace(/\.?([A-Z]+)/g, function (_x, y) {
|
24
|
+
return "-".concat(y.toLowerCase());
|
25
|
+
}); // vendor prefix
|
26
|
+
|
27
|
+
if ((_styleValue = styleValue) !== null && _styleValue !== void 0 && _styleValue.startsWith('-')) {
|
28
|
+
var firstWord = styleValue.split('-').filter(function (s) {
|
29
|
+
return s;
|
30
|
+
})[0];
|
31
|
+
styleValue = styleValue.replace(/^-/, '');
|
32
|
+
|
33
|
+
if (vendorPrefixes.find(function (prefix) {
|
34
|
+
return prefix === firstWord;
|
35
|
+
})) {
|
36
|
+
styleValue = "-".concat(styleValue);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
return styleValue;
|
41
|
+
};
|
42
|
+
|
43
|
+
export var plainStyle = function (style) {
|
44
|
+
if (!style) {
|
45
|
+
return '';
|
46
|
+
}
|
47
|
+
|
48
|
+
return Object.keys(style).reduce(function (acc, key) {
|
49
|
+
var value = style[key];
|
50
|
+
return [].concat(_toConsumableArray(acc), ["".concat(transformReactStyleKey(key), ":").concat(value, ";")]);
|
51
|
+
}, []).join('\n');
|
52
|
+
};
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
2
|
+
import "core-js/modules/es.string.starts-with.js";
|
3
|
+
import "core-js/modules/es.regexp.exec.js";
|
4
|
+
import "core-js/modules/es.string.replace.js";
|
5
|
+
import "core-js/modules/es.array.filter.js";
|
6
|
+
import "core-js/modules/es.object.to-string.js";
|
7
|
+
import "core-js/modules/es.string.split.js";
|
8
|
+
import "core-js/modules/es.array.find.js";
|
9
|
+
import "core-js/modules/es.array.join.js";
|
10
|
+
import "core-js/modules/es.array.reduce.js";
|
11
|
+
import "core-js/modules/es.object.keys.js";
|
12
|
+
import "core-js/modules/es.array.concat.js";
|
13
|
+
var vendorPrefixes = ['webkit', 'moz', 'ms', 'o'];
|
14
|
+
|
15
|
+
var transformReactStyleKey = function (key) {
|
16
|
+
var _styleValue;
|
17
|
+
|
18
|
+
// css3 var
|
19
|
+
if (key !== null && key !== void 0 && key.startsWith('--')) {
|
20
|
+
return key;
|
21
|
+
}
|
22
|
+
|
23
|
+
var styleValue = key.replace(/\.?([A-Z]+)/g, function (_x, y) {
|
24
|
+
return "-".concat(y.toLowerCase());
|
25
|
+
}); // vendor prefix
|
26
|
+
|
27
|
+
if ((_styleValue = styleValue) !== null && _styleValue !== void 0 && _styleValue.startsWith('-')) {
|
28
|
+
var firstWord = styleValue.split('-').filter(function (s) {
|
29
|
+
return s;
|
30
|
+
})[0];
|
31
|
+
styleValue = styleValue.replace(/^-/, '');
|
32
|
+
|
33
|
+
if (vendorPrefixes.find(function (prefix) {
|
34
|
+
return prefix === firstWord;
|
35
|
+
})) {
|
36
|
+
styleValue = "-".concat(styleValue);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
return styleValue;
|
41
|
+
};
|
42
|
+
|
43
|
+
export var plainStyle = function (style) {
|
44
|
+
if (!style) {
|
45
|
+
return '';
|
46
|
+
}
|
47
|
+
|
48
|
+
return Object.keys(style).reduce(function (acc, key) {
|
49
|
+
var value = style[key];
|
50
|
+
return [].concat(_toConsumableArray(acc), ["".concat(transformReactStyleKey(key), ":").concat(value, ";")]);
|
51
|
+
}, []).join('\n');
|
52
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.useInterval=useInterval;var _react=require("react");function useInterval(callback){var delay=arguments.length>1&&arguments[1]!==undefined?arguments[1]:200;var intervalFn=(0,_react.useRef)({});(0,_react.useEffect)(function(){intervalFn.current.callback=callback;},[callback]);(0,_react.useEffect)(function(){if(delay!==null){intervalFn.current.timer=setInterval(function(){intervalFn.current.callback();},delay);return function(){clearInterval(intervalFn.current.timer);};}},[delay]);return intervalFn.current.timer;}
|
@@ -0,0 +1 @@
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.useInterval=useInterval;var _react=require("react");function useInterval(callback){var delay=arguments.length>1&&arguments[1]!==undefined?arguments[1]:200;var intervalFn=(0,_react.useRef)({});(0,_react.useEffect)(function(){intervalFn.current.callback=callback;},[callback]);(0,_react.useEffect)(function(){if(delay!==null){intervalFn.current.timer=setInterval(function(){intervalFn.current.callback();},delay);return function(){clearInterval(intervalFn.current.timer);};}},[delay]);return intervalFn.current.timer;}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
2
|
+
/**
|
3
|
+
* Hooks版本setInterval
|
4
|
+
*/
|
5
|
+
|
6
|
+
export function useInterval(callback) {
|
7
|
+
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
|
8
|
+
var intervalFn = useRef({});
|
9
|
+
useEffect(function () {
|
10
|
+
intervalFn.current.callback = callback;
|
11
|
+
}, [callback]); // set the interval
|
12
|
+
|
13
|
+
useEffect(function () {
|
14
|
+
if (delay !== null) {
|
15
|
+
intervalFn.current.timer = setInterval(function () {
|
16
|
+
intervalFn.current.callback();
|
17
|
+
}, delay);
|
18
|
+
return function () {
|
19
|
+
clearInterval(intervalFn.current.timer);
|
20
|
+
};
|
21
|
+
}
|
22
|
+
}, [delay]);
|
23
|
+
return intervalFn.current.timer;
|
24
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
2
|
+
/**
|
3
|
+
* Hooks版本setInterval
|
4
|
+
*/
|
5
|
+
|
6
|
+
export function useInterval(callback) {
|
7
|
+
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
|
8
|
+
var intervalFn = useRef({});
|
9
|
+
useEffect(function () {
|
10
|
+
intervalFn.current.callback = callback;
|
11
|
+
}, [callback]); // set the interval
|
12
|
+
|
13
|
+
useEffect(function () {
|
14
|
+
if (delay !== null) {
|
15
|
+
intervalFn.current.timer = setInterval(function () {
|
16
|
+
intervalFn.current.callback();
|
17
|
+
}, delay);
|
18
|
+
return function () {
|
19
|
+
clearInterval(intervalFn.current.timer);
|
20
|
+
};
|
21
|
+
}
|
22
|
+
}, [delay]);
|
23
|
+
return intervalFn.current.timer;
|
24
|
+
}
|