MCPcopy
hub / github.com/alibaba/lowcode-engine / Widget

Class Widget

packages/editor-skeleton/src/widget/widget.ts:30–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30export class Widget implements IWidget {
31 readonly isWidget = true;
32
33 readonly id = uniqueId('widget');
34
35 readonly name: string;
36
37 readonly align?: string;
38
39 @obx.ref private _visible = true;
40
41 get visible(): boolean {
42 return this._visible;
43 }
44
45 @obx.ref inited = false;
46
47 @obx.ref private _disabled = false;
48
49 private _body: ReactNode;
50
51 get body() {
52 if (this.inited) {
53 return this._body;
54 }
55 this.inited = true;
56 const { content, contentProps } = this.config;
57 this._body = createContent(content, {
58 ...contentProps,
59 config: this.config,
60 editor: getEvent(this.skeleton.editor),
61 });
62 return this._body;
63 }
64
65 get content(): ReactNode {
66 return createElement(WidgetView, {
67 widget: this,
68 key: this.id,
69 });
70 }
71
72 readonly title: IPublicTypeTitleContent;
73
74 constructor(readonly skeleton: ISkeleton, readonly config: WidgetConfig) {
75 makeObservable(this);
76 const { props = {}, name } = config;
77 this.name = name;
78 this.align = props.align;
79 this.title = props.title || name;
80 if (props.onInit) {
81 props.onInit.call(this, this);
82 }
83 }
84
85 getId() {
86 return this.id;
87 }

Callers

nothing calls this directly

Calls 1

uniqueIdFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…