py-test-component 2.0.7 → 2.0.9

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.
@@ -1,37 +0,0 @@
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
- */
@@ -1,55 +0,0 @@
1
- import React, { useEffect, useRef, useState, forwardRef } from 'react';
2
-
3
- // 注入 ElementUI CSS(只执行一次)
4
- let cssInjected = false;
5
- function injectElementUICSS() {
6
- if (cssInjected || typeof document === 'undefined') return;
7
- cssInjected = true;
8
- const link = document.createElement('link');
9
- link.rel = 'stylesheet';
10
- link.href = 'https://unpkg.com/element-ui/lib/theme-chalk/index.css';
11
- document.head.appendChild(link);
12
- }
13
-
14
- // 加载组件库
15
- function usePyComponent() {
16
- const [loaded, setLoaded] = useState(false);
17
- useEffect(() => {
18
- injectElementUICSS();
19
- import('py-test-component').then(() => setLoaded(true));
20
- }, []);
21
- return loaded;
22
- }
23
-
24
- // 通用包装函数:动态创建 React 组件
25
- function wrapVueComponent(tagName, dataProp = null) {
26
- return forwardRef(function WrappedComponent({ propData, loading, ...props }, ref) {
27
- const elRef = useRef(null);
28
- const loaded = usePyComponent();
29
-
30
- useEffect(() => {
31
- if (elRef.current && propData !== undefined && dataProp) {
32
- elRef.current[dataProp] = propData;
33
- }
34
- }, [propData]);
35
-
36
- if (!loaded && loading) {
37
- return <div style={{ padding: '20px', textAlign: 'center' }}>{loading}</div>;
38
- }
39
-
40
- // 使用 createElement 避免 JSX 标签名大小写警告
41
- return React.createElement(tagName, { ref: ref || elRef, ...props });
42
- });
43
- }
44
-
45
- // 一键注册所有组件
46
- export const PyTable = wrapVueComponent('py-table', 'propData');
47
- export const PyWeather = wrapVueComponent('py-weather', 'propData');
48
-
49
- // 初始化 store(仅设置,不暴露 store 给外部)
50
- export function initStore(config) {
51
- return import('py-test-component').then((m) => {
52
- const PyComponent = m.default || m;
53
- PyComponent?.initStore?.(config);
54
- });
55
- }
package/src/vue/index.js DELETED
@@ -1,32 +0,0 @@
1
- // Vue 项目专用入口
2
- // 注意:此组件库基于 Vue 2.7 + ElementUI 构建
3
- // Vue 3 工程请使用 React 入口(通过 Web Components 方式)
4
-
5
- import Vue from 'vue';
6
- import ElementUI from 'element-ui';
7
- import 'element-ui/lib/theme-chalk/index.css';
8
- import vueCustomElement from 'vue-custom-element';
9
-
10
- import PyTable from '../components/PyTable.vue';
11
- import PyWeather from '../components/PyWeather.vue';
12
- import store from '../store';
13
-
14
- // 确保 Vue 和插件已安装
15
- Vue.use(ElementUI);
16
- Vue.use(vueCustomElement);
17
-
18
- // 注册为 Web Components(禁用 Shadow DOM)
19
- if (!customElements.get('py-table')) {
20
- Vue.customElement('py-table', PyTable, { shadow: false });
21
- }
22
- if (!customElements.get('py-weather')) {
23
- Vue.customElement('py-weather', PyWeather, { shadow: false });
24
- }
25
-
26
- // 初始化 store(统一的方法)
27
- function initStore(config) {
28
- store.set(config);
29
- }
30
-
31
- export { PyTable, PyWeather, initStore };
32
- export default { PyTable, PyWeather, initStore };