@univerjs/ui-adapter-web-component 0.8.3-nightly.202507010644 → 0.8.3-nightly.202507021607
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/lib/cjs/index.js +1 -1
- package/lib/es/index.js +37 -38
- package/lib/index.js +37 -38
- package/lib/types/plugin.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +3 -4
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),m=require("@univerjs/ui");var f=Object.defineProperty,_=Object.getOwnPropertyDescriptor,g=(t,e,n)=>e in t?f(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,v=(t,e,n,o)=>{for(var r=o>1?void 0:o?_(e,n):e,i=t.length-1,a;i>=0;i--)(a=t[i])&&(r=a(r)||r);return r},l=(t,e)=>(n,o)=>e(n,o,t),P=(t,e,n)=>g(t,e+"",n);exports.UniverWebComponentAdapterPlugin=class extends c.Plugin{constructor(e={},n,o){super(),this._config=e,this._injector=n,this._componentManager=o}onStarting(){const{createElement:e,useEffect:n,useRef:o}=this._componentManager.reactUtils;this._componentManager.setHandler("web-component",(r,i)=>()=>e(b,{component:r,props:{name:i},reactUtils:{createElement:e,useEffect:n,useRef:o}}))}};P(exports.UniverWebComponentAdapterPlugin,"pluginName","UNIVER_UI_ADAPTER_WEB_COMPONENT_PLUGIN");exports.UniverWebComponentAdapterPlugin=v([c.DependentOn(m.UniverUIPlugin),l(1,c.Inject(c.Injector)),l(2,c.Inject(m.ComponentManager))],exports.UniverWebComponentAdapterPlugin);function b(t){const{component:e,props:n,reactUtils:o}=t,{name:r}=n!=null?n:{},{createElement:i,useEffect:a,useRef:d}=o;if(!r)throw new Error("WebComponentComponentWrapper requires a name prop to define the custom element.");customElements.get(r)||customElements.define(r,e);const u=d(null);return a(()=>{if(!u.current)return;const p=document.createElement(r);return u.current.appendChild(p),()=>{var s;(s=u.current)==null||s.removeChild(p)}},[]),i("div",{ref:u})}
|
package/lib/es/index.js
CHANGED
|
@@ -1,47 +1,46 @@
|
|
|
1
|
-
import { DependentOn as
|
|
2
|
-
import { UniverUIPlugin as
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
super(), this._config = e, this._injector = n, this._componentManager = r;
|
|
1
|
+
import { DependentOn as _, Inject as u, Injector as d, Plugin as g } from "@univerjs/core";
|
|
2
|
+
import { UniverUIPlugin as v, ComponentManager as E } from "@univerjs/ui";
|
|
3
|
+
var P = Object.defineProperty, C = Object.getOwnPropertyDescriptor, h = (e, t, n) => t in e ? P(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, b = (e, t, n, o) => {
|
|
4
|
+
for (var r = o > 1 ? void 0 : o ? C(t, n) : t, c = e.length - 1, a; c >= 0; c--)
|
|
5
|
+
(a = e[c]) && (r = a(r) || r);
|
|
6
|
+
return r;
|
|
7
|
+
}, l = (e, t) => (n, o) => t(n, o, e), U = (e, t, n) => h(e, t + "", n);
|
|
8
|
+
let m = class extends g {
|
|
9
|
+
constructor(e = {}, t, n) {
|
|
10
|
+
super(), this._config = e, this._injector = t, this._componentManager = n;
|
|
12
11
|
}
|
|
13
12
|
onStarting() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
));
|
|
13
|
+
const { createElement: e, useEffect: t, useRef: n } = this._componentManager.reactUtils;
|
|
14
|
+
this._componentManager.setHandler("web-component", (o, r) => () => e(w, {
|
|
15
|
+
component: o,
|
|
16
|
+
props: {
|
|
17
|
+
name: r
|
|
18
|
+
},
|
|
19
|
+
reactUtils: { createElement: e, useEffect: t, useRef: n }
|
|
20
|
+
}));
|
|
22
21
|
}
|
|
23
22
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
],
|
|
30
|
-
function
|
|
31
|
-
const { component:
|
|
32
|
-
if (!
|
|
23
|
+
U(m, "pluginName", "UNIVER_UI_ADAPTER_WEB_COMPONENT_PLUGIN");
|
|
24
|
+
m = b([
|
|
25
|
+
_(v),
|
|
26
|
+
l(1, u(d)),
|
|
27
|
+
l(2, u(E))
|
|
28
|
+
], m);
|
|
29
|
+
function w(e) {
|
|
30
|
+
const { component: t, props: n, reactUtils: o } = e, { name: r } = n != null ? n : {}, { createElement: c, useEffect: a, useRef: f } = o;
|
|
31
|
+
if (!r)
|
|
33
32
|
throw new Error("WebComponentComponentWrapper requires a name prop to define the custom element.");
|
|
34
|
-
customElements.get(
|
|
35
|
-
const
|
|
36
|
-
return
|
|
37
|
-
if (!
|
|
38
|
-
const
|
|
39
|
-
return
|
|
40
|
-
var
|
|
41
|
-
(
|
|
33
|
+
customElements.get(r) || customElements.define(r, t);
|
|
34
|
+
const i = f(null);
|
|
35
|
+
return a(() => {
|
|
36
|
+
if (!i.current) return;
|
|
37
|
+
const p = document.createElement(r);
|
|
38
|
+
return i.current.appendChild(p), () => {
|
|
39
|
+
var s;
|
|
40
|
+
(s = i.current) == null || s.removeChild(p);
|
|
42
41
|
};
|
|
43
|
-
}, []),
|
|
42
|
+
}, []), c("div", { ref: i });
|
|
44
43
|
}
|
|
45
44
|
export {
|
|
46
|
-
|
|
45
|
+
m as UniverWebComponentAdapterPlugin
|
|
47
46
|
};
|
package/lib/index.js
CHANGED
|
@@ -1,47 +1,46 @@
|
|
|
1
|
-
import { DependentOn as
|
|
2
|
-
import { UniverUIPlugin as
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
super(), this._config = e, this._injector = n, this._componentManager = r;
|
|
1
|
+
import { DependentOn as _, Inject as u, Injector as d, Plugin as g } from "@univerjs/core";
|
|
2
|
+
import { UniverUIPlugin as v, ComponentManager as E } from "@univerjs/ui";
|
|
3
|
+
var P = Object.defineProperty, C = Object.getOwnPropertyDescriptor, h = (e, t, n) => t in e ? P(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, b = (e, t, n, o) => {
|
|
4
|
+
for (var r = o > 1 ? void 0 : o ? C(t, n) : t, c = e.length - 1, a; c >= 0; c--)
|
|
5
|
+
(a = e[c]) && (r = a(r) || r);
|
|
6
|
+
return r;
|
|
7
|
+
}, l = (e, t) => (n, o) => t(n, o, e), U = (e, t, n) => h(e, t + "", n);
|
|
8
|
+
let m = class extends g {
|
|
9
|
+
constructor(e = {}, t, n) {
|
|
10
|
+
super(), this._config = e, this._injector = t, this._componentManager = n;
|
|
12
11
|
}
|
|
13
12
|
onStarting() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
));
|
|
13
|
+
const { createElement: e, useEffect: t, useRef: n } = this._componentManager.reactUtils;
|
|
14
|
+
this._componentManager.setHandler("web-component", (o, r) => () => e(w, {
|
|
15
|
+
component: o,
|
|
16
|
+
props: {
|
|
17
|
+
name: r
|
|
18
|
+
},
|
|
19
|
+
reactUtils: { createElement: e, useEffect: t, useRef: n }
|
|
20
|
+
}));
|
|
22
21
|
}
|
|
23
22
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
],
|
|
30
|
-
function
|
|
31
|
-
const { component:
|
|
32
|
-
if (!
|
|
23
|
+
U(m, "pluginName", "UNIVER_UI_ADAPTER_WEB_COMPONENT_PLUGIN");
|
|
24
|
+
m = b([
|
|
25
|
+
_(v),
|
|
26
|
+
l(1, u(d)),
|
|
27
|
+
l(2, u(E))
|
|
28
|
+
], m);
|
|
29
|
+
function w(e) {
|
|
30
|
+
const { component: t, props: n, reactUtils: o } = e, { name: r } = n != null ? n : {}, { createElement: c, useEffect: a, useRef: f } = o;
|
|
31
|
+
if (!r)
|
|
33
32
|
throw new Error("WebComponentComponentWrapper requires a name prop to define the custom element.");
|
|
34
|
-
customElements.get(
|
|
35
|
-
const
|
|
36
|
-
return
|
|
37
|
-
if (!
|
|
38
|
-
const
|
|
39
|
-
return
|
|
40
|
-
var
|
|
41
|
-
(
|
|
33
|
+
customElements.get(r) || customElements.define(r, t);
|
|
34
|
+
const i = f(null);
|
|
35
|
+
return a(() => {
|
|
36
|
+
if (!i.current) return;
|
|
37
|
+
const p = document.createElement(r);
|
|
38
|
+
return i.current.appendChild(p), () => {
|
|
39
|
+
var s;
|
|
40
|
+
(s = i.current) == null || s.removeChild(p);
|
|
42
41
|
};
|
|
43
|
-
}, []),
|
|
42
|
+
}, []), c("div", { ref: i });
|
|
44
43
|
}
|
|
45
44
|
export {
|
|
46
|
-
|
|
45
|
+
m as UniverWebComponentAdapterPlugin
|
|
47
46
|
};
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -14,4 +14,5 @@ export declare class UniverWebComponentAdapterPlugin extends Plugin {
|
|
|
14
14
|
export declare function WebComponentComponentWrapper(options: {
|
|
15
15
|
component: CustomElementConstructor;
|
|
16
16
|
props?: Record<string, any>;
|
|
17
|
+
reactUtils: typeof ComponentManager.prototype.reactUtils;
|
|
17
18
|
}): import('react').DetailedReactHTMLElement<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(r,
|
|
1
|
+
(function(r,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@univerjs/core"),require("@univerjs/ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui"],u):(r=typeof globalThis<"u"?globalThis:r||self,u(r.UniverUiAdapterWebComponent={},r.UniverCore,r.UniverUi))})(this,function(r,u,a){"use strict";var l=Object.defineProperty,v=Object.getOwnPropertyDescriptor,_=(t,e,n)=>e in t?l(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,g=(t,e,n,i)=>{for(var o=i>1?void 0:i?v(e,n):e,p=t.length-1,c;p>=0;p--)(c=t[p])&&(o=c(o)||o);return o},m=(t,e)=>(n,i)=>e(n,i,t),U=(t,e,n)=>_(t,e+"",n);r.UniverWebComponentAdapterPlugin=class extends u.Plugin{constructor(e={},n,i){super(),this._config=e,this._injector=n,this._componentManager=i}onStarting(){const{createElement:e,useEffect:n,useRef:i}=this._componentManager.reactUtils;this._componentManager.setHandler("web-component",(o,p)=>()=>e(C,{component:o,props:{name:p},reactUtils:{createElement:e,useEffect:n,useRef:i}}))}},U(r.UniverWebComponentAdapterPlugin,"pluginName","UNIVER_UI_ADAPTER_WEB_COMPONENT_PLUGIN"),r.UniverWebComponentAdapterPlugin=g([u.DependentOn(a.UniverUIPlugin),m(1,u.Inject(u.Injector)),m(2,u.Inject(a.ComponentManager))],r.UniverWebComponentAdapterPlugin);function C(t){const{component:e,props:n,reactUtils:i}=t,{name:o}=n!=null?n:{},{createElement:p,useEffect:c,useRef:P}=i;if(!o)throw new Error("WebComponentComponentWrapper requires a name prop to define the custom element.");customElements.get(o)||customElements.define(o,e);const s=P(null);return c(()=>{if(!s.current)return;const f=document.createElement(o);return s.current.appendChild(f),()=>{var d;(d=s.current)==null||d.removeChild(f)}},[]),p("div",{ref:s})}Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/ui-adapter-web-component",
|
|
3
|
-
"version": "0.8.3-nightly.
|
|
3
|
+
"version": "0.8.3-nightly.202507021607",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Web component adapter for Univer UI",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -48,11 +48,10 @@
|
|
|
48
48
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@univerjs/core": "0.8.3-nightly.
|
|
52
|
-
"@univerjs/ui": "0.8.3-nightly.
|
|
51
|
+
"@univerjs/core": "0.8.3-nightly.202507021607",
|
|
52
|
+
"@univerjs/ui": "0.8.3-nightly.202507021607"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"react": "18.3.1",
|
|
56
55
|
"typescript": "^5.8.3",
|
|
57
56
|
"vite": "^6.3.5",
|
|
58
57
|
"vitest": "^3.2.4",
|