@ray-js/framework-shared 1.4.43 → 1.4.45
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/emitter/index.js +1 -0
- package/lib/filterProps/index.js +1 -0
- package/lib/inlineStyle/index.js +5 -3
- package/lib/normalizeTabBar.js +4 -3
- package/lib/plainStyle/index.js +5 -3
- package/lib/useStylesheet/index.js +2 -3
- package/lib/useThrottle/index.js +1 -0
- package/lib/useTouch/index.js +1 -0
- package/lib/useTransition/index.js +4 -3
- package/package.json +5 -5
package/lib/emitter/index.js
CHANGED
package/lib/filterProps/index.js
CHANGED
package/lib/inlineStyle/index.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import "core-js/modules/es.string.replace.js";
|
2
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
1
3
|
import { isWeb } from '@ray-js/env';
|
2
4
|
import { isUnitlessNumber } from './CSSProperty';
|
3
5
|
|
@@ -22,15 +24,15 @@ export function inlineStyle() {
|
|
22
24
|
else if (!(key in isUnitlessNumber)) {
|
23
25
|
if (!Number.isNaN(Number(value))) {
|
24
26
|
if (isWeb) {
|
25
|
-
style[key] =
|
27
|
+
style[key] = "".concat(value / 100, "rem");
|
26
28
|
} else {
|
27
|
-
style[key] =
|
29
|
+
style[key] = "".concat(value, "rpx");
|
28
30
|
}
|
29
31
|
} else if (/\b([.\d]+)rpx\b/.test(value) && isWeb) {
|
30
32
|
// TODO: 支持 native 的样式抹平
|
31
33
|
style[key] = value.replace(/\b([.\d]+)rpx\b/g, (match, x) => {
|
32
34
|
const size = Number(x);
|
33
|
-
return
|
35
|
+
return "".concat(size / 100, "rem");
|
34
36
|
});
|
35
37
|
}
|
36
38
|
}
|
package/lib/normalizeTabBar.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
2
3
|
import { match, parse } from 'path-to-regexp';
|
3
4
|
export function normalizeTabBar(tabBar, routes) {
|
4
5
|
let list = tabBar.list;
|
@@ -27,7 +28,7 @@ export function normalizeTabBar(tabBar, routes) {
|
|
27
28
|
tab = _objectSpread({}, tab);
|
28
29
|
const m = routes.find(i => tab.pagePath === i.path);
|
29
30
|
if (!m) {
|
30
|
-
throw new Error(
|
31
|
+
throw new Error("tabBar.list[".concat(index, "].pagePath: ").concat(tab.pagePath, " \u9700\u8981\u5728\u8DEF\u7531\u914D\u7F6E\u4E2D: ").concat(JSON.stringify(routes, null, 2)));
|
31
32
|
}
|
32
33
|
if (!tab.route) {
|
33
34
|
// 判断 routes[number].route 是否为模式匹配规则
|
@@ -36,7 +37,7 @@ export function normalizeTabBar(tabBar, routes) {
|
|
36
37
|
// 判断是否能被路由命中
|
37
38
|
const matched = match((_m$route = m.route) !== null && _m$route !== void 0 ? _m$route : m.path)(tab.route);
|
38
39
|
if (!matched) {
|
39
|
-
console.warn(
|
40
|
+
console.warn("tabBar.list[".concat(index, "]\n.route: ").concat(tab.route, "\n.pagePath: ").concat(tab.pagePath, "\n\u5E94\u88AB\u8DEF\u7531\u547D\u4E2D: \n").concat(JSON.stringify(m, null, 2)));
|
40
41
|
return;
|
41
42
|
}
|
42
43
|
// 判断是否还被其他路由命中
|
@@ -46,7 +47,7 @@ export function normalizeTabBar(tabBar, routes) {
|
|
46
47
|
});
|
47
48
|
const unusable = otherMatched.filter(r => r.path !== tab.pagePath);
|
48
49
|
if (unusable.length) {
|
49
|
-
console.warn(
|
50
|
+
console.warn("tabBar.list[".concat(index, "]\n.route: ").concat(tab.route, "\n%c.pagePath: ").concat(tab.pagePath, "\n%c\u88AB\u5176\u5B83\u8DEF\u7531\u547D\u4E2D\uFF1A\n").concat(JSON.stringify(unusable, null, 2)), 'background:#290000;color:green', 'background:#290000;color:green', 'color:red');
|
50
51
|
return;
|
51
52
|
}
|
52
53
|
return tab;
|
package/lib/plainStyle/index.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import "core-js/modules/es.string.replace.js";
|
2
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
1
3
|
const vendorPrefixes = ['webkit', 'moz', 'ms', 'o'];
|
2
4
|
const transformReactStyleKey = key => {
|
3
5
|
var _styleValue;
|
@@ -6,7 +8,7 @@ const transformReactStyleKey = key => {
|
|
6
8
|
return key;
|
7
9
|
}
|
8
10
|
let styleValue = key.replace(/\.?([A-Z]+)/g, function (_x, y) {
|
9
|
-
return
|
11
|
+
return "-".concat(y.toLowerCase());
|
10
12
|
});
|
11
13
|
|
12
14
|
// vendor prefix
|
@@ -14,7 +16,7 @@ const transformReactStyleKey = key => {
|
|
14
16
|
const firstWord = styleValue.split('-').filter(s => s)[0];
|
15
17
|
styleValue = styleValue.replace(/^-/, '');
|
16
18
|
if (vendorPrefixes.find(prefix => prefix === firstWord)) {
|
17
|
-
styleValue =
|
19
|
+
styleValue = "-".concat(styleValue);
|
18
20
|
}
|
19
21
|
}
|
20
22
|
return styleValue;
|
@@ -25,6 +27,6 @@ export const plainStyle = style => {
|
|
25
27
|
}
|
26
28
|
return Object.keys(style).reduce((acc, key) => {
|
27
29
|
const value = style[key];
|
28
|
-
return [...acc,
|
30
|
+
return [...acc, "".concat(transformReactStyleKey(key), ":").concat(value, ";")];
|
29
31
|
}, []).join('\n');
|
30
32
|
};
|
@@ -1,12 +1,11 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { plainStyle } from '../plainStyle';
|
3
3
|
let clsxId = 0;
|
4
|
-
const generateClassName = () =>
|
4
|
+
const generateClassName = () => "placeholder-style-".concat(clsxId++);
|
5
5
|
export function useStylesheet(css) {
|
6
6
|
const className = React.useRef(generateClassName());
|
7
7
|
React.useEffect(() => {
|
8
|
-
const styleContent =
|
9
|
-
${plainStyle(css)}}`;
|
8
|
+
const styleContent = ".".concat(className.current, "::placeholder {\n").concat(plainStyle(css), "}");
|
10
9
|
const style = window.document.createElement('style');
|
11
10
|
style.type = 'text/css';
|
12
11
|
style.appendChild(document.createTextNode(styleContent));
|
package/lib/useThrottle/index.js
CHANGED
package/lib/useTouch/index.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
3
3
|
const _excluded = ["hoverDuration", "hoverDelay"];
|
4
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
4
5
|
import * as React from 'react';
|
5
6
|
import { isWeb } from '@ray-js/env';
|
6
7
|
const LONG_TAP_DURATION = 350;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
1
2
|
import { useEffect, useRef, useState } from 'react';
|
2
3
|
const nextFrame = function () {
|
3
4
|
let duration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000 / 30;
|
@@ -21,17 +22,17 @@ export function useTransition(options, deps) {
|
|
21
22
|
function updateShow(show) {
|
22
23
|
if (showRef.current === show) return false;
|
23
24
|
showRef.current = show;
|
24
|
-
onStart === null || onStart === void 0
|
25
|
+
onStart === null || onStart === void 0 || onStart(showRef.current);
|
25
26
|
setStatus(showRef.current ? 'showStart' : 'hideStart');
|
26
27
|
nextFrame(duration).then(() => {
|
27
28
|
setStatus(showRef.current ? 'showComplete' : 'hideComplete');
|
28
|
-
onFinish === null || onFinish === void 0
|
29
|
+
onFinish === null || onFinish === void 0 || onFinish(showRef.current);
|
29
30
|
});
|
30
31
|
}
|
31
32
|
useEffect(() => {
|
32
33
|
updateShow(visible);
|
33
34
|
}, [visible]);
|
34
35
|
return [status, {
|
35
|
-
animationDuration:
|
36
|
+
animationDuration: "".concat(duration / 1000, "s")
|
36
37
|
}, updateShow];
|
37
38
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ray-js/framework-shared",
|
3
|
-
"version": "1.4.
|
3
|
+
"version": "1.4.45",
|
4
4
|
"description": "Ray shared for framework",
|
5
5
|
"keywords": [
|
6
6
|
"ray"
|
@@ -24,16 +24,16 @@
|
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
26
|
"@ray-core/wechat": "^0.3.9",
|
27
|
-
"@ray-js/env": "1.4.
|
28
|
-
"@ray-js/types": "1.4.
|
27
|
+
"@ray-js/env": "1.4.45",
|
28
|
+
"@ray-js/types": "1.4.45",
|
29
29
|
"path-to-regexp": "^6.2.1"
|
30
30
|
},
|
31
31
|
"devDependencies": {
|
32
|
-
"@ray-js/cli": "1.4.
|
32
|
+
"@ray-js/cli": "1.4.45"
|
33
33
|
},
|
34
34
|
"publishConfig": {
|
35
35
|
"access": "public",
|
36
36
|
"registry": "https://registry.npmjs.org"
|
37
37
|
},
|
38
|
-
"gitHead": "
|
38
|
+
"gitHead": "3d43182ecec581aec70f654706be0b070e38011b"
|
39
39
|
}
|