Fix: rename and implement fallbackRenderMethod (#20005)
* rename and implement fallbackRender * re introducing method as part of the name * rename impls --------- Co-authored-by: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Co-authored-by: Andrej Davidovič <andrejd@cdata.com>
This commit is contained in:
@@ -467,7 +467,7 @@ export class UmbBlockGridEntryElement extends UmbLitElement implements UmbProper
|
||||
<umb-extension-slot
|
||||
.filter=${this.#extensionSlotFilterMethod}
|
||||
.renderMethod=${this.#extensionSlotRenderMethod}
|
||||
.defaultRenderMethod=${this.#renderBuiltinBlockView}
|
||||
.fallbackRenderMethod=${this.#renderBuiltinBlockView}
|
||||
.props=${this._blockViewProps}
|
||||
default-element=${this._inlineEditingMode ? 'umb-block-grid-block-inline' : 'umb-block-grid-block'}
|
||||
type="blockEditorCustomView"
|
||||
|
||||
@@ -399,7 +399,7 @@ export class UmbBlockListEntryElement extends UmbLitElement implements UmbProper
|
||||
${umbDestroyOnDisconnect()}></umb-unsupported-list-block>`;
|
||||
}
|
||||
|
||||
#renderBuiltinBlockView() {
|
||||
#renderBuiltinBlockView = () => {
|
||||
if (this._unsupported) {
|
||||
return this.#renderUnsupportedBlock();
|
||||
}
|
||||
@@ -407,7 +407,7 @@ export class UmbBlockListEntryElement extends UmbLitElement implements UmbProper
|
||||
return this.#renderInlineBlock();
|
||||
}
|
||||
return this.#renderRefBlock();
|
||||
}
|
||||
};
|
||||
|
||||
#renderBlock() {
|
||||
return this.contentKey && (this._contentTypeAlias || this._unsupported)
|
||||
@@ -417,11 +417,10 @@ export class UmbBlockListEntryElement extends UmbLitElement implements UmbProper
|
||||
type="blockEditorCustomView"
|
||||
default-element=${this._inlineEditingMode ? 'umb-inline-list-block' : 'umb-ref-list-block'}
|
||||
.renderMethod=${this.#extensionSlotRenderMethod}
|
||||
.fallbackRenderMethod=${this.#renderBuiltinBlockView}
|
||||
.props=${this._blockViewProps}
|
||||
.filter=${this.#extensionSlotFilterMethod}
|
||||
single
|
||||
>${this.#renderBuiltinBlockView()}</umb-extension-slot
|
||||
>
|
||||
single></umb-extension-slot>
|
||||
${this.#renderActionBar()}
|
||||
${!this._showContentEdit && this._contentInvalid
|
||||
? html`<uui-badge attention color="invalid" label="Invalid content">!</uui-badge>`
|
||||
|
||||
@@ -277,11 +277,10 @@ export class UmbBlockRteEntryElement extends UmbLitElement implements UmbPropert
|
||||
type="blockEditorCustomView"
|
||||
default-element="umb-ref-rte-block"
|
||||
.renderMethod=${this.#extensionSlotRenderMethod}
|
||||
.fallbackRenderMethod=${this.#renderBuiltinBlockView}
|
||||
.props=${this._blockViewProps}
|
||||
.filter=${this.#filterBlockCustomViews}
|
||||
single>
|
||||
${this.#renderRefBlock()}
|
||||
</umb-extension-slot>
|
||||
single></umb-extension-slot>
|
||||
${this.#renderActionBar()}
|
||||
${!this._showContentEdit && this._contentInvalid
|
||||
? html`<uui-badge attention color="invalid" label="Invalid content">!</uui-badge>`
|
||||
@@ -297,6 +296,14 @@ export class UmbBlockRteEntryElement extends UmbLitElement implements UmbPropert
|
||||
: nothing;
|
||||
}
|
||||
|
||||
#renderBuiltinBlockView = () => {
|
||||
// TODO: Missing unsupported rendering [NL]
|
||||
/*if (this._unsupported) {
|
||||
return this.#renderUnsupportedBlock();
|
||||
}*/
|
||||
return this.#renderRefBlock();
|
||||
};
|
||||
|
||||
#renderRefBlock() {
|
||||
return html`<umb-ref-rte-block
|
||||
.label=${this._label}
|
||||
|
||||
@@ -98,7 +98,7 @@ export class UmbExtensionSlotElement extends UmbLitElement {
|
||||
) => TemplateResult | TemplateResult<1> | HTMLElement | null | undefined | typeof nothing;
|
||||
|
||||
@property({ attribute: false })
|
||||
public defaultRenderMethod?: () =>
|
||||
public fallbackRenderMethod?: () =>
|
||||
| TemplateResult
|
||||
| TemplateResult<1>
|
||||
| HTMLElement
|
||||
@@ -142,15 +142,18 @@ export class UmbExtensionSlotElement extends UmbLitElement {
|
||||
}
|
||||
|
||||
override render() {
|
||||
// First renders something once _permitted is set, this is to avoid flickering. [NL]
|
||||
return this._permitted
|
||||
? this._permitted.length > 0
|
||||
? repeat(this._permitted, (ext) => ext.alias, this.#renderExtension)
|
||||
: this.defaultRenderMethod
|
||||
? this.defaultRenderMethod()
|
||||
: html`<slot></slot>`
|
||||
: this.#renderNoting()
|
||||
: nothing;
|
||||
}
|
||||
|
||||
#renderNoting() {
|
||||
return this.fallbackRenderMethod ? this.fallbackRenderMethod() : html`<slot></slot>`;
|
||||
}
|
||||
|
||||
#renderExtension = (ext: UmbExtensionElementInitializer, i: number) => {
|
||||
return this.renderMethod ? this.renderMethod(ext, i) : ext.component;
|
||||
};
|
||||
|
||||
@@ -143,6 +143,15 @@ export class UmbExtensionWithApiSlotElement extends UmbLitElement {
|
||||
index: number,
|
||||
) => TemplateResult | TemplateResult<1> | HTMLElement | null | undefined | typeof nothing;
|
||||
|
||||
@property({ attribute: false })
|
||||
public fallbackRenderMethod?: () =>
|
||||
| TemplateResult
|
||||
| TemplateResult<1>
|
||||
| HTMLElement
|
||||
| null
|
||||
| undefined
|
||||
| typeof nothing;
|
||||
|
||||
override connectedCallback(): void {
|
||||
super.connectedCallback();
|
||||
this.#attached = true;
|
||||
@@ -185,10 +194,14 @@ export class UmbExtensionWithApiSlotElement extends UmbLitElement {
|
||||
return this._permitted
|
||||
? this._permitted.length > 0
|
||||
? repeat(this._permitted, (ext) => ext.alias, this.#renderExtension)
|
||||
: html`<slot></slot>`
|
||||
: this.#renderNoting()
|
||||
: nothing;
|
||||
}
|
||||
|
||||
#renderNoting() {
|
||||
return this.fallbackRenderMethod ? this.fallbackRenderMethod() : html`<slot></slot>`;
|
||||
}
|
||||
|
||||
#renderExtension = (ext: UmbExtensionElementAndApiInitializer, i: number) => {
|
||||
return this.renderMethod ? this.renderMethod(ext, i) : ext.component;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user