py-test-component 2.0.1 → 2.0.4
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/DEVELOPER.md +541 -0
- package/README.md +201 -0
- package/USAGE.md +366 -0
- package/dist/313f7dacf2076822059d.woff +0 -0
- package/dist/4520188144a17fb24a6a.ttf +0 -0
- package/dist/py-component.esm.js +2 -0
- package/dist/py-component.esm.js.LICENSE.txt +37 -0
- package/dist/py-component.js +2 -0
- package/dist/py-component.js.LICENSE.txt +37 -0
- package/package.json +4 -1
- package/src/react/index.js +7 -7
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Vue.js v2.7.16
|
|
3
|
+
* (c) 2014-2023 Evan You
|
|
4
|
+
* Released under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* vue-custom-element v3.3.0
|
|
11
|
+
* (c) 2021 Karol Fabjańczuk
|
|
12
|
+
* @license MIT
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @license
|
|
17
|
+
* Lodash <https://lodash.com/>
|
|
18
|
+
* Copyright JS Foundation and other contributors <https://js.foundation/>
|
|
19
|
+
* Released under MIT license <https://lodash.com/license>
|
|
20
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
21
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Checks if an event is supported in the current execution environment.
|
|
26
|
+
*
|
|
27
|
+
* NOTE: This will not work correctly for non-generic events such as `change`,
|
|
28
|
+
* `reset`, `load`, `error`, and `select`.
|
|
29
|
+
*
|
|
30
|
+
* Borrows from Modernizr.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} eventNameSuffix Event name, e.g. "click".
|
|
33
|
+
* @param {?boolean} capture Check if the capture phase is supported.
|
|
34
|
+
* @return {boolean} True if the event is supported.
|
|
35
|
+
* @internal
|
|
36
|
+
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
37
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "py-test-component",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "Vue2 + ElementUI 组件库,支持 React 使用",
|
|
5
5
|
"main": "dist/py-component.js",
|
|
6
6
|
"module": "dist/py-component.esm.js",
|
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
"files": [
|
|
22
22
|
"dist",
|
|
23
23
|
"src/react",
|
|
24
|
+
"README.md",
|
|
25
|
+
"USAGE.md",
|
|
26
|
+
"DEVELOPER.md",
|
|
24
27
|
"src/vue"
|
|
25
28
|
],
|
|
26
29
|
"scripts": {
|
package/src/react/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useRef, useState, forwardRef } from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useState, forwardRef } from 'react';
|
|
2
2
|
|
|
3
3
|
// 注入 ElementUI CSS(只执行一次)
|
|
4
4
|
let cssInjected = false;
|
|
@@ -16,7 +16,7 @@ function usePyComponent() {
|
|
|
16
16
|
const [loaded, setLoaded] = useState(false);
|
|
17
17
|
useEffect(() => {
|
|
18
18
|
injectElementUICSS();
|
|
19
|
-
import('
|
|
19
|
+
import('py-test-component').then(() => setLoaded(true));
|
|
20
20
|
}, []);
|
|
21
21
|
return loaded;
|
|
22
22
|
}
|
|
@@ -37,7 +37,8 @@ function wrapVueComponent(tagName, dataProp = null) {
|
|
|
37
37
|
return <div style={{ padding: '20px', textAlign: 'center' }}>{loading}</div>;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
// 使用 createElement 避免 JSX 标签名大小写警告
|
|
41
|
+
return React.createElement(tagName, { ref: ref || elRef, ...props });
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -45,11 +46,10 @@ function wrapVueComponent(tagName, dataProp = null) {
|
|
|
45
46
|
export const PyTable = wrapVueComponent('py-table', 'propData');
|
|
46
47
|
export const PyWeather = wrapVueComponent('py-weather', 'propData');
|
|
47
48
|
|
|
48
|
-
// 初始化 store
|
|
49
|
+
// 初始化 store(仅设置,不暴露 store 给外部)
|
|
49
50
|
export function initStore(config) {
|
|
50
|
-
return import('
|
|
51
|
+
return import('py-test-component').then((m) => {
|
|
51
52
|
const PyComponent = m.default || m;
|
|
52
|
-
PyComponent?.
|
|
53
|
-
return PyComponent?.store;
|
|
53
|
+
PyComponent?.initStore?.(config);
|
|
54
54
|
});
|
|
55
55
|
}
|