update import paths to observable-api

This commit is contained in:
Jacob Overgaard
2023-01-23 14:39:19 +01:00
parent c42d824d10
commit fbd1971be9
3 changed files with 21 additions and 20 deletions

View File

@@ -9,7 +9,7 @@ import { createExtensionElement } from '@umbraco-cms/extensions-api';
import type { ManifestCollectionView, MediaDetails } from '@umbraco-cms/models';
import { umbExtensionsRegistry } from '@umbraco-cms/extensions-registry';
import { UmbLitElement } from '@umbraco-cms/element';
import type { UmbObserverController } from 'src/core/observable-api/observer.controller';
import type { UmbObserverController } from '@umbraco-cms/observable-api';
@customElement('umb-collection')
export class UmbCollectionElement extends UmbLitElement {

View File

@@ -9,7 +9,7 @@ import type { DataTypePropertyData, ManifestPropertyEditorUI, ManifestTypes } fr
import '../../property-actions/shared/property-action-menu/property-action-menu.element';
import '../../../../backoffice/shared/components/workspace/workspace-property-layout/workspace-property-layout.element';
import { UmbObserverController } from 'src/core/observable-api/observer.controller';
import { UmbObserverController } from '@umbraco-cms/observable-api';
import { UmbLitElement } from '@umbraco-cms/element';
/**
@@ -49,10 +49,10 @@ export class UmbWorkspacePropertyElement extends UmbLitElement {
];
@state()
private _label?:string;
private _label?: string;
@state()
private _description?:string;
private _description?: string;
/**
* Label. Name of the property
@@ -98,7 +98,7 @@ export class UmbWorkspacePropertyElement extends UmbLitElement {
private _propertyEditorUIAlias = '';
@property({ type: String, attribute: 'property-editor-ui-alias' })
public set propertyEditorUIAlias(value: string) {
if(this._propertyEditorUIAlias === value) return;
if (this._propertyEditorUIAlias === value) return;
this._propertyEditorUIAlias = value;
this._observePropertyEditorUI();
}
@@ -110,7 +110,7 @@ export class UmbWorkspacePropertyElement extends UmbLitElement {
* @attr
* @default undefined
*/
@property({attribute: false })
@property({ attribute: false })
public set value(value: unknown) {
this._propertyContext.setValue(value);
}
@@ -131,7 +131,6 @@ export class UmbWorkspacePropertyElement extends UmbLitElement {
@state()
private _element?: { value?: any; config?: any } & HTMLElement; // TODO: invent interface for propertyEditorUI.
private _propertyContext = new UmbWorkspacePropertyContext(this);
private propertyEditorUIObserver?: UmbObserverController<ManifestTypes>;
@@ -139,7 +138,6 @@ export class UmbWorkspacePropertyElement extends UmbLitElement {
private _valueObserver?: UmbObserverController<unknown>;
private _configObserver?: UmbObserverController<unknown>;
constructor() {
super();
@@ -149,21 +147,23 @@ export class UmbWorkspacePropertyElement extends UmbLitElement {
this.observe(this._propertyContext.description, (description) => {
this._description = description;
});
}
private _onPropertyEditorChange = (e: CustomEvent) => {
const target = e.composedPath()[0] as any;
this.value = target.value;// Sets value in context.
this.value = target.value; // Sets value in context.
e.stopPropagation();
};
private _observePropertyEditorUI() {
this.propertyEditorUIObserver?.destroy();
this.propertyEditorUIObserver = this.observe(umbExtensionsRegistry.getByTypeAndAlias('propertyEditorUI', this._propertyEditorUIAlias), (manifest) => {
this._gotEditorUI(manifest);
});
this.propertyEditorUIObserver = this.observe(
umbExtensionsRegistry.getByTypeAndAlias('propertyEditorUI', this._propertyEditorUIAlias),
(manifest) => {
this._gotEditorUI(manifest);
}
);
}
private _gotEditorUI(manifest?: ManifestPropertyEditorUI | null) {
@@ -183,33 +183,34 @@ export class UmbWorkspacePropertyElement extends UmbLitElement {
this._valueObserver?.destroy();
this._configObserver?.destroy();
if(this._element) {
if (this._element) {
this._element.addEventListener('property-value-change', this._onPropertyEditorChange as any as EventListener);
this._valueObserver = this.observe(this._propertyContext.value, (value) => {
if(this._element) {
if (this._element) {
this._element.value = value;
}
});
this._configObserver = this.observe(this._propertyContext.config, (config) => {
if(this._element) {
if (this._element) {
this._element.config = config;
}
});
}
this.requestUpdate('element', oldValue);
})
.catch(() => {
// TODO: loading JS failed so we should do some nice UI. (This does only happen if extension has a js prop, otherwise we concluded that no source was needed resolved the load.)
});
}
render() {
return html`
<umb-workspace-property-layout id="layout" label="${ifDefined(this._label)}" description="${ifDefined(this._description)}">
<umb-workspace-property-layout
id="layout"
label="${ifDefined(this._label)}"
description="${ifDefined(this._description)}">
${this._renderPropertyActionMenu()}
<div slot="editor">${this._element}</div>
</umb-workspace-property-layout>

View File

@@ -1,5 +1,5 @@
import type { Observable } from 'rxjs';
import { UniqueBehaviorSubject } from '../observable-api/unique-behavior-subject';
import { UniqueBehaviorSubject } from '@umbraco-cms/observable-api';
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
export interface UmbDataStoreIdentifiers {