Skip to content

Commit a0cc631

Browse files
authored
Merge pull request #6982 from umbraco/docs/remove-property-value-change-event
Change UmbPropertyValueChangeEvent to UmbChangeEvent and updates wrong import paths
2 parents b5c6bbd + 6ee1c85 commit a0cc631

File tree

9 files changed

+498
-476
lines changed

9 files changed

+498
-476
lines changed

15/umbraco-cms/customizing/extending-overview/extension-types/menu.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The manifest can also be written in TypeScript.
3636
For this TypeScript example we used a [Backoffice Entry Point](../../extending-overview/extension-types/backoffice-entry-point.md) extension to register the manifests.
3737

3838
```typescript
39-
import { ManifestMenu } from "@umbraco-cms/backoffice/extension-registry";
39+
import type { ManifestMenu } from '@umbraco-cms/backoffice/menu';
4040

4141
const menuManifest: Array<ManifestMenu> = [
4242
{
@@ -55,7 +55,7 @@ const menuManifest: Array<ManifestMenu> = [
5555

5656
<figure><img src="../../../.gitbook/assets/menu-item.png" alt="" width="250"><figcaption><p>Menu Item</p></figcaption></figure>
5757

58-
Menu items are the items that appear in the menu.
58+
Menu items are the items that appear in the menu.
5959

6060
## Creating a custom menu items
6161

@@ -139,10 +139,9 @@ You can fetch the data and render the menu items using the Lit element above. By
139139

140140
{% code title="menu-items.ts" overflow="wrap" lineNumbers="true" %}
141141
```typescript
142-
import { UmbMenuItemElement } from '@umbraco-cms/backoffice/extension-registry';
142+
import type { UmbMenuItemElement } from '@umbraco-cms/backoffice/menu';
143143
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
144-
import { html, TemplateResult } from 'lit';
145-
import { customElement, state } from 'lit/decorators.js';
144+
import { html, TemplateResult, customElement, state } from '@umbraco-cms/backoffice/external/lit';
146145
import { MyMenuItemResponseModel, MyMenuResource } from '../../../api';
147146

148147
const elementName = 'my-menu-item';
@@ -151,13 +150,14 @@ const elementName = 'my-menu-item';
151150
class MyMenuItems extends UmbLitElement implements UmbMenuItemElement {
152151
@state()
153152
private _items: MyMenuItemResponseModel[] = []; // Store fetched items
153+
154154
@state()
155155
private _loading: boolean = true; // Track loading state
156+
156157
@state()
157158
private _error: string | null = null; // Track any errors
158159

159-
constructor() {
160-
super();
160+
override firstUpdated() {
161161
this.fetchInitialItems(); // Start fetching on component load
162162
}
163163

@@ -178,8 +178,8 @@ class MyMenuItems extends UmbLitElement implements UmbMenuItemElement {
178178
return html`
179179
${items.map(element => html`
180180
<uui-menu-item label="${element.name}" ?has-children=${element.hasChildren}>
181-
${element.type === 1
182-
? html`<uui-icon slot="icon" name="icon-folder"></uui-icon>`
181+
${element.type === 1
182+
? html`<uui-icon slot="icon" name="icon-folder"></uui-icon>`
183183
: html`<uui-icon slot="icon" name="icon-autofill"></uui-icon>`}
184184
<!-- recursively render children -->
185185
${element.hasChildren ? this.renderItems(element.children) : ''}
@@ -189,7 +189,7 @@ class MyMenuItems extends UmbLitElement implements UmbMenuItemElement {
189189
}
190190

191191
// Main render function
192-
render() {
192+
override render() {
193193
if (this._loading) {
194194
return html`<uui-loader></uui-loader>`;
195195
}
@@ -200,7 +200,7 @@ class MyMenuItems extends UmbLitElement implements UmbMenuItemElement {
200200
}
201201

202202
// Render items if loading is done and no error occurred
203-
return html`${this.renderItems(this._items)}`;
203+
return this.renderItems(this._items);
204204
}
205205
}
206206

@@ -212,15 +212,15 @@ declare global {
212212
}
213213
}
214214

215-
```
215+
```
216216
{% endcode %}
217217

218218

219219
## Tree Menu Item
220220

221221
### Manifest
222222

223-
```typescript
223+
```json
224224
// it will be something like this
225225
{
226226
"type": "menuItem",
@@ -236,9 +236,10 @@ declare global {
236236

237237
#### Default Element
238238

239+
The default element supports rendering a subtree of menu items.
240+
239241
```typescript
240-
// get interface
241-
interface UmbTreeMenuItemElement {}
242+
class UmbMenuItemTreeDefaultElement {}
242243
```
243244

244245
### Adding menu items to an existing menu

15/umbraco-cms/customizing/extending-overview/extension-types/modals/custom-modals.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ There are two parts to creating a custom modal:
2020
A modal token is a string that identifies a modal. This is the modal extension alias. It is used to open a modal and is also to set default options for the modal. It should also have a unique alias to avoid conflicts with other modals.
2121

2222
```ts
23-
import { UmbModalToken } from "@umbraco-cms/backoffice/modal";
23+
import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
2424

2525
export type MyModalData = {
2626
headline: string;
@@ -48,15 +48,15 @@ Additionally, the modal element can see its data parameters through the `modalCo
4848

4949
{% code title="my-modal.element.ts" %}
5050
```ts
51-
import { html, LitElement, property, customElement } from "@umbraco-cms/backoffice/external/lit";
52-
import { UmbElementMixin } from "@umbraco-cms/backoffice/element-api";
53-
import type { UmbModalContext } from "@umbraco-cms/backoffice/modal";
54-
import type { MyModalData, MyModalValue } from "./my-modal.token.ts";
55-
import { UmbModalExtensionElement } from "@umbraco-cms/backoffice/extension-registry";
51+
import { customElement, html, property } from '@umbraco-cms/backoffice/external/lit';
52+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
53+
import { UmbModalExtensionElement } from '@umbraco-cms/backoffice/modal';
54+
import type { UmbModalContext } from '@umbraco-cms/backoffice/modal';
55+
import type { MyModalData, MyModalValue } from './my-modal.token.js';
5656

5757
@customElement('my-dialog')
5858
export default class MyDialogElement
59-
extends UmbElementMixin(LitElement)
59+
extends UmbLitElement
6060
implements UmbModalExtensionElement<MyModalData, MyModalValue> {
6161

6262
@property({ attribute: false })
@@ -70,14 +70,14 @@ export default class MyDialogElement
7070
}
7171

7272
private _handleSubmit() {
73-
this.modalContext?.updateValue({ myData: "hello world" });
73+
this.modalContext?.updateValue({ myData: 'hello world' });
7474
this.modalContext?.submit();
7575
}
7676

7777
render() {
7878
return html`
7979
<div>
80-
<h1>${this.modalContext?.data.headline ?? "Default headline"}</h1>
80+
<h1>${this.modalContext?.data.headline ?? 'Default headline'}</h1>
8181
<button @click=${this._handleCancel}>Cancel</button>
8282
<button @click=${this._handleSubmit}>Submit</button>
8383
</div>
@@ -106,14 +106,13 @@ To open the modal, you need to consume the `UmbModalManagerContext` and then use
106106

107107
{% code title="my-element.ts" %}
108108
```ts
109-
import { MY_MODAL_TOKEN } from './my-modal.token';
109+
import { customElement, html } from '@umbraco-cms/backoffice/external/lit';
110+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
111+
import { MY_MODAL_TOKEN } from './my-modal.token.js';
110112
import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
111-
import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api';
112-
import { LitElement, html } from 'lit';
113-
import { customElement } from 'lit/decorators.js';
114113

115114
@customElement('my-element')
116-
class MyElement extends UmbElementMixin(LitElement) {
115+
class MyElement extends UmbLitElement {
117116
#modalManagerContext?: typeof UMB_MODAL_MANAGER_CONTEXT.TYPE;
118117

119118
constructor() {
@@ -124,7 +123,7 @@ class MyElement extends UmbElementMixin(LitElement) {
124123
});
125124
}
126125

127-
render() {
126+
override render() {
128127
return html`
129128
<uui-button look="primary" label="Open modal" @click=${this._openModal}></uui-button>
130129
`;
@@ -138,5 +137,11 @@ class MyElement extends UmbElementMixin(LitElement) {
138137
});
139138
}
140139
}
140+
141+
declare global {
142+
interface HTMLElementTagNameMap {
143+
'my-element': MyElement;
144+
}
145+
}
141146
```
142147
{% endcode %}

15/umbraco-cms/customizing/extending-overview/extension-types/sections/section-view.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The manifest can also be written in TypeScript.
5151
For this TypeScript example we used a [Backoffice Entry Point](../backoffice-entry-point.md) extension to register the manifests.
5252

5353
```typescript
54-
import { ManifestSectionView } from "@umbraco-cms/backoffice/extension-registry";
54+
import { ManifestSectionView } from '@umbraco-cms/backoffice/section';
5555

5656
const sectionViews: Array<ManifestSectionView> = [
5757
{
@@ -83,21 +83,21 @@ Creating the Section View Element using a Lit Element.
8383
**my-section.element.ts:**
8484

8585
```typescript
86-
import { UmbLitElement } from "@umbraco-cms/backoffice/lit-element";
86+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
8787
import { css, html, customElement, property } from '@umbraco-cms/backoffice/external/lit';
8888

8989
@customElement('my-sectionview-element')
9090
export class MySectionViewElement extends UmbLitElement {
9191

92-
render() {
92+
override render() {
9393
return html`
9494
<uui-box headline="Sectionview Title goes here">
9595
Sectionview content goes here
9696
</uui-box>
9797
`
9898
}
9999

100-
static override styles = [
100+
static override readonly styles = [
101101
css`
102102
:host {
103103
display: block;

15/umbraco-cms/customizing/property-editors/composition/property-editor-ui.md

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The Property Editor UI is a pure front-end extension. This determines how the da
1414

1515
### Property Editor UI
1616

17+
{% code title="umbraco-package.json" %}
1718
```json
1819
{
1920
"type": "propertyEditorUi",
@@ -29,6 +30,7 @@ The Property Editor UI is a pure front-end extension. This determines how the da
2930
}
3031
}
3132
```
33+
{% endcode %}
3234

3335
The Property Editor UI cannot be used for Content Types if no Property Editor Schema is specified in the manifest. However, it can still be utilized to manipulate JSON. A case of that could be a Settings property for another Property Editor UI or Schema.
3436

@@ -42,6 +44,7 @@ The Property Editor UI inherits the Settings of its Property Editor Schema.
4244

4345
**Manifest**
4446

47+
{% code title="umbraco-package.json" %}
4548
```json
4649
{
4750
"type": "propertyEditorUi",
@@ -68,47 +71,73 @@ The Property Editor UI inherits the Settings of its Property Editor Schema.
6871
},
6972
};
7073
```
74+
{% endcode %}
7175

7276
## The Property Editor UI Element
7377

74-
Inherit the interface, to secure your Element live up to the requirements of this.
78+
Implement the `UmbPropertyEditorUiElement` interface, to secure your Element live up to the requirements of this.
7579

7680
```typescript
77-
// TODO: get interface
78-
interface UmbPropertyEditorUIElement {}
81+
interface UmbPropertyEditorUiElement extends HTMLElement {
82+
name?: string;
83+
value?: unknown;
84+
config?: UmbPropertyEditorConfigCollection;
85+
mandatory?: boolean;
86+
mandatoryMessage?: string;
87+
destroy?: () => void;
88+
}
7989
```
8090

91+
{% hint style="info" %}
92+
The `UmbPropertyEditorUiElement` interface ensures that your Element has the necessary properties and methods to be used as a Property Editor UI Element.
93+
94+
See the [UI API documentation](https://apidocs.umbraco.com/v15/ui-api/interfaces/packages_core_property-editor.UmbPropertyEditorUiElement.html) for more information.
95+
{% endhint %}
96+
8197
**Example with LitElement**
8298

99+
{% code title="my-text-box.ts" lineNumbers="true" %}
83100
```typescript
84-
import { LitElement, html, css, customElement, property } from '@umbraco-cms/backoffice/external/lit';
85-
import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api';
86-
import { UmbPropertyValueChangeEvent } from '@umbraco-cms/backoffice/property-editor';
87-
88-
@customElement('my-text-box')
89-
export default class UmbPropertyEditorUITextBoxElement extends UmbElementMixin(LitElement) {
90-
91-
@property()
92-
value: string | undefined;
93-
94-
@property({ attribute: false })
95-
public config: UmbPropertyEditorConfigCollection | undefined;
96-
97-
private onInput(e: InputEvent) {
98-
this.value = (e.target as HTMLInputElement).value;
99-
this.dispatchEvent(new UmbPropertyValueChangeEvent());
100-
}
101+
import { UmbChangeEvent } from '@umbraco-cms/backoffice/event';
102+
import { css, customElement, html, property } from '@umbraco-cms/backoffice/external/lit';
103+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
104+
import type {
105+
UmbPropertyEditorConfigCollection,
106+
UmbPropertyEditorUiElement,
107+
} from '@umbraco-cms/backoffice/property-editor';
108+
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
109+
110+
@customElement('umb-property-editor-ui-text-box')
111+
export default class UmbPropertyEditorUITextBoxElement extends UmbLitElement implements UmbPropertyEditorUiElement {
112+
@property()
113+
value?: string;
114+
115+
@property({ attribute: false })
116+
config?: UmbPropertyEditorConfigCollection;
117+
118+
#onInput(e: InputEvent) {
119+
this.value = (e.target as HTMLInputElement).value;
120+
this.dispatchEvent(new UmbChangeEvent());
121+
}
122+
123+
override render() {
124+
return html`<uui-input .value=${this.value ?? ''} type="text" @input=${this.#onInput}></uui-input>`;
125+
}
126+
127+
static override readonly styles = [
128+
UmbTextStyles,
129+
css`
130+
uui-input {
131+
width: 100%;
132+
}
133+
`,
134+
];
135+
}
101136

102-
render() {
103-
return html`<uui-input .value=${this.value} type="text" @input=${this.onInput}></uui-input>`;
104-
}
105-
106-
static styles = [
107-
css`
108-
uui-input {
109-
width: 100%;
110-
}
111-
`,
112-
];
137+
declare global {
138+
interface HTMLElementTagNameMap {
139+
'umb-property-editor-ui-text-box': UmbPropertyEditorUITextBoxElement;
140+
}
113141
}
114142
```
143+
{% endcode %}

15/umbraco-cms/tutorials/creating-a-custom-dashboard/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ Now let's create the web component we need for our property editor. This web com
9999
1. Create a file in the `src` folder with the name `welcome-dashboard.element.ts`
100100
2. In this new file, add the following code:
101101

102-
{% code title="welcome-dashboard.element.ts" lineNumbers="true" %}
102+
{% code title="welcome-dashboard.element.ts" lineNumbers="true" overflow="wrap" %}
103103
```typescript
104-
import { LitElement, css, html, customElement } from "@umbraco-cms/backoffice/external/lit";
105-
import { UmbLitElement } from "@umbraco-cms/backoffice/lit-element";
104+
import { LitElement, css, html, customElement } from '@umbraco-cms/backoffice/external/lit';
105+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
106106

107107
@customElement('my-welcome-dashboard')
108108
export class MyWelcomeDashboardElement extends UmbLitElement {
109109

110-
render() {
110+
override render() {
111111
return html`
112112
<h1>Welcome Dashboard</h1>
113113
<div>
@@ -120,7 +120,7 @@ export class MyWelcomeDashboardElement extends UmbLitElement {
120120
`;
121121
}
122122

123-
static styles = [
123+
static override readonly styles = [
124124
css`
125125
:host {
126126
display: block;

0 commit comments

Comments
 (0)