Skip to content

Commit 1bb25e3

Browse files
authored
Merge branch 'main' into v14/chore/check-paths-in-dist-cms
2 parents 4ade5c4 + 5f8b8d6 commit 1bb25e3

File tree

88 files changed

+415
-230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+415
-230
lines changed

package-lock.json

Lines changed: 44 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@
139139
"./src/packages/webhook",
140140
"./src/packages/health-check",
141141
"./src/packages/tags",
142-
"./src/packages/templating"
142+
"./src/packages/templating",
143+
"./src/packages/property-editors"
143144
],
144145
"scripts": {
145146
"backoffice:test:e2e": "npx playwright test",
@@ -179,7 +180,7 @@
179180
"test:dev": "web-test-runner --config ./web-test-runner.dev.config.mjs",
180181
"test:dev-watch": "web-test-runner --watch --config ./web-test-runner.dev.config.mjs",
181182
"test:watch": "web-test-runner --watch",
182-
"test": "web-test-runner --coverage",
183+
"test": "web-test-runner",
183184
"wc-analyze:vscode": "wca **/*.element.ts --format vscode --outFile dist-cms/vscode-html-custom-data.json",
184185
"wc-analyze": "wca **/*.element.ts --outFile dist-cms/custom-elements.json",
185186
"generate:tsconfig": "node ./devops/tsconfig/index.js",
@@ -215,7 +216,7 @@
215216
"@hey-api/openapi-ts": "^0.48.1",
216217
"@mdx-js/react": "^3.0.0",
217218
"@open-wc/testing": "^4.0.0",
218-
"@playwright/test": "^1.41.1",
219+
"@playwright/test": "^1.45.1",
219220
"@rollup/plugin-commonjs": "^25.0.7",
220221
"@rollup/plugin-json": "^6.1.0",
221222
"@rollup/plugin-node-resolve": "^15.2.3",

src/packages/block/block-grid/components/block-grid-areas-container/block-grid-areas-container.element.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import '../block-grid-entries/index.js';
1212
@customElement('umb-block-grid-areas-container')
1313
export class UmbBlockGridAreasContainerElement extends UmbLitElement {
1414
//
15-
#styleElement?: HTMLLinkElement;
15+
@state()
16+
_styleElement?: HTMLLinkElement;
1617

1718
@state()
1819
_areas?: Array<UmbBlockGridTypeAreaType> = [];
@@ -44,9 +45,11 @@ export class UmbBlockGridAreasContainerElement extends UmbLitElement {
4445
this.observe(
4546
manager.layoutStylesheet,
4647
(stylesheet) => {
47-
this.#styleElement = document.createElement('link');
48-
this.#styleElement.setAttribute('rel', 'stylesheet');
49-
this.#styleElement.setAttribute('href', stylesheet);
48+
// Do not re-render stylesheet if its the same href.
49+
if (!stylesheet || this._styleElement?.href === stylesheet) return;
50+
this._styleElement = document.createElement('link');
51+
this._styleElement.rel = 'stylesheet';
52+
this._styleElement.href = stylesheet;
5053
},
5154
'observeStylesheet',
5255
);
@@ -55,7 +58,7 @@ export class UmbBlockGridAreasContainerElement extends UmbLitElement {
5558

5659
override render() {
5760
return this._areas && this._areas.length > 0
58-
? html` ${this.#styleElement}
61+
? html` ${this._styleElement}
5962
<div
6063
class="umb-block-grid__area-container"
6164
style="--umb-block-grid--area-grid-columns: ${this._areaGridColumns}">

src/packages/block/block-grid/components/block-grid-entries/block-grid-entries.element.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import { UmbBlockGridEntriesContext } from '../../context/block-grid-entries.context.js';
2-
import type { UmbBlockGridEntryElement } from '../block-grid-entry/index.js';
31
import {
42
getAccumulatedValueOfIndex,
53
getInterpolatedIndexOfPositionInWeightMap,
64
isWithinRect,
75
} from '@umbraco-cms/backoffice/utils';
86
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
9-
import type { UmbBlockGridLayoutModel } from '@umbraco-cms/backoffice/block-grid';
107
import { html, customElement, state, repeat, css, property, nothing } from '@umbraco-cms/backoffice/external/lit';
118
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
129
import '../block-grid-entry/index.js';
@@ -17,6 +14,9 @@ import {
1714
type UmbFormControlValidatorConfig,
1815
} from '@umbraco-cms/backoffice/validation';
1916
import type { UmbNumberRangeValueType } from '@umbraco-cms/backoffice/models';
17+
import { UmbBlockGridEntriesContext } from '../../context/block-grid-entries.context.js';
18+
import type { UmbBlockGridEntryElement } from '../block-grid-entry/index.js';
19+
import type { UmbBlockGridLayoutModel } from '@umbraco-cms/backoffice/block-grid';
2020

2121
/**
2222
* Notice this utility method is not really shareable with others as it also takes areas into account. [NL]
@@ -209,10 +209,10 @@ export class UmbBlockGridEntriesElement extends UmbFormControlMixin(UmbLitElemen
209209
this.observe(
210210
manager.layoutStylesheet,
211211
(stylesheet) => {
212-
if (this._styleElement && this._styleElement.href === stylesheet) return;
212+
if (!stylesheet || this._styleElement?.href === stylesheet) return;
213213
this._styleElement = document.createElement('link');
214-
this._styleElement.setAttribute('rel', 'stylesheet');
215-
this._styleElement.setAttribute('href', stylesheet);
214+
this._styleElement.rel = 'stylesheet';
215+
this._styleElement.href = stylesheet;
216216
},
217217
'observeStylesheet',
218218
);

src/packages/block/block-grid/context/block-grid-manager.context.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import type { UmbBlockGridLayoutModel, UmbBlockGridTypeModel } from '../types.js';
22
import type { UmbBlockGridWorkspaceData } from '../index.js';
33
import { UmbArrayState, appendToFrozenArray, pushAtToUniqueArray } from '@umbraco-cms/backoffice/observable-api';
4+
import { removeInitialSlashFromPath, transformServerPathToClientPath } from '@umbraco-cms/backoffice/utils';
5+
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
6+
import { UMB_APP_CONTEXT } from '@umbraco-cms/backoffice/app';
7+
import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor';
48
import { type UmbBlockDataType, UmbBlockManagerContext } from '@umbraco-cms/backoffice/block';
59
import type { UmbBlockTypeGroup } from '@umbraco-cms/backoffice/block-type';
610

@@ -13,24 +17,49 @@ export class UmbBlockGridManagerContext<
1317
BlockLayoutType extends UmbBlockGridLayoutModel = UmbBlockGridLayoutModel,
1418
> extends UmbBlockManagerContext<UmbBlockGridTypeModel, UmbBlockGridLayoutModel> {
1519
//
20+
#initAppUrl: Promise<void>;
21+
#appUrl?: string;
1622
#blockGroups = new UmbArrayState(<Array<UmbBlockTypeGroup>>[], (x) => x.key);
1723
public readonly blockGroups = this.#blockGroups.asObservable();
1824

19-
layoutStylesheet = this._editorConfiguration.asObservablePart(
20-
(x) => (x?.getValueByAlias('layoutStylesheet') as string) ?? UMB_BLOCK_GRID_DEFAULT_LAYOUT_STYLESHEET,
21-
);
25+
layoutStylesheet = this._editorConfiguration.asObservablePart((x) => {
26+
if (!x) return undefined;
27+
const layoutStylesheet = x.getValueByAlias<string>('layoutStylesheet');
28+
if (!layoutStylesheet) return UMB_BLOCK_GRID_DEFAULT_LAYOUT_STYLESHEET;
29+
30+
if (layoutStylesheet) {
31+
// Cause we await initAppUrl in setting the _editorConfiguration, we can trust the appUrl begin here.
32+
return this.#appUrl! + removeInitialSlashFromPath(transformServerPathToClientPath(layoutStylesheet));
33+
}
34+
return undefined;
35+
});
2236
gridColumns = this._editorConfiguration.asObservablePart((x) => {
2337
const value = x?.getValueByAlias('gridColumns') as string | undefined;
2438
return parseInt(value && value !== '' ? value : '12');
2539
});
2640

41+
override setEditorConfiguration(configs: UmbPropertyEditorConfigCollection) {
42+
this.#initAppUrl.then(() => {
43+
// we await initAppUrl, So the appUrl begin here is available when retrieving the layoutStylesheet.
44+
this._editorConfiguration.setValue(configs);
45+
});
46+
}
47+
2748
setBlockGroups(blockGroups: Array<UmbBlockTypeGroup>) {
2849
this.#blockGroups.setValue(blockGroups);
2950
}
3051
getBlockGroups() {
3152
return this.#blockGroups.value;
3253
}
3354

55+
constructor(host: UmbControllerHost) {
56+
super(host);
57+
58+
this.#initAppUrl = this.getContext(UMB_APP_CONTEXT).then((appContext) => {
59+
this.#appUrl = appContext.getServerUrl() + appContext.getBackofficePath();
60+
});
61+
}
62+
3463
create(
3564
contentElementTypeKey: string,
3665
partialLayoutEntry?: Omit<BlockLayoutType, 'contentUdi'>,

src/packages/block/block-grid/property-editors/block-grid-editor/manifests.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ export const manifests: Array<ManifestTypes> = [
5555
label: 'Layout Stylesheet',
5656
description: 'Override default stylesheet for backoffice layout.',
5757
propertyEditorUiAlias: 'Umb.PropertyEditorUi.BlockGridLayoutStylesheet',
58+
config: [
59+
{
60+
alias: 'singleItemMode',
61+
value: true,
62+
},
63+
],
5864
},
5965
],
6066
},

src/packages/block/block-grid/property-editors/block-grid-editor/property-editor-ui-block-grid.element.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { UmbBlockGridManagerContext } from '../../context/block-grid-manager.context.js';
2-
import { UMB_BLOCK_GRID_PROPERTY_EDITOR_ALIAS } from './manifests.js';
31
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
42
import { html, customElement, property, state, css, type PropertyValueMap } from '@umbraco-cms/backoffice/external/lit';
53
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
64
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/extension-registry';
75
import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor';
8-
import type { UmbBlockTypeGroup } from '@umbraco-cms/backoffice/block-type';
9-
import type { UmbBlockGridTypeModel, UmbBlockGridValueModel } from '@umbraco-cms/backoffice/block-grid';
106
import '../../components/block-grid-entries/index.js';
117
import { observeMultiple } from '@umbraco-cms/backoffice/observable-api';
128
import { UMB_PROPERTY_CONTEXT } from '@umbraco-cms/backoffice/property';
139
import { UmbFormControlMixin } from '@umbraco-cms/backoffice/validation';
10+
import { UmbBlockGridManagerContext } from '../../context/block-grid-manager.context.js';
11+
import { UMB_BLOCK_GRID_PROPERTY_EDITOR_ALIAS } from './manifests.js';
12+
import type { UmbBlockTypeGroup } from '@umbraco-cms/backoffice/block-type';
13+
import type { UmbBlockGridTypeModel, UmbBlockGridValueModel } from '@umbraco-cms/backoffice/block-grid';
1414

1515
/**
1616
* @element umb-property-editor-ui-block-grid

0 commit comments

Comments
 (0)