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