| 11 | * 带图标(主要)/标题(次要)的扩展 |
| 12 | */ |
| 13 | export class Dock implements IWidget { |
| 14 | readonly isWidget = true; |
| 15 | |
| 16 | readonly id = uniqueId('dock'); |
| 17 | |
| 18 | readonly name: string; |
| 19 | |
| 20 | readonly align?: string; |
| 21 | |
| 22 | @obx.ref private _visible = true; |
| 23 | |
| 24 | get visible(): boolean { |
| 25 | return this._visible; |
| 26 | } |
| 27 | |
| 28 | @obx.ref private _disabled = false; |
| 29 | |
| 30 | get content(): ReactNode { |
| 31 | return createElement(WidgetView, { |
| 32 | widget: this, |
| 33 | key: this.id, |
| 34 | }); |
| 35 | } |
| 36 | |
| 37 | private inited = false; |
| 38 | |
| 39 | private _body: ReactNode; |
| 40 | |
| 41 | get body() { |
| 42 | if (this.inited) { |
| 43 | return this._body; |
| 44 | } |
| 45 | |
| 46 | const { props, content, contentProps } = this.config; |
| 47 | |
| 48 | if (content) { |
| 49 | this._body = createContent(content, { |
| 50 | ...contentProps, |
| 51 | config: this.config, |
| 52 | editor: getEvent(this.skeleton.editor), |
| 53 | }); |
| 54 | } else { |
| 55 | this._body = createElement(DockView, props); |
| 56 | } |
| 57 | this.inited = true; |
| 58 | |
| 59 | return this._body; |
| 60 | } |
| 61 | |
| 62 | constructor(readonly skeleton: ISkeleton, readonly config: DockConfig) { |
| 63 | makeObservable(this); |
| 64 | const { props = {}, name } = config; |
| 65 | this.name = name; |
| 66 | this.align = props.align; |
| 67 | if (props.onInit) { |
| 68 | props.onInit.call(this, this); |
| 69 | } |
| 70 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…