- ${this.#renderLabel()}
+ ${when(
+ !this.file && this.path,
+ () => html`
${this.label}`,
+ () => html`
${this.label}`,
+ )}
`;
}
@@ -81,26 +71,30 @@ export default class UmbInputUploadFieldFileElement extends UmbLitElement {
box-sizing: border-box;
color: var(--uui-color-text);
}
+
#file-symbol {
aspect-ratio: 1 / 1;
margin: auto;
max-width: 100%;
max-height: 100%;
}
+
#label {
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: var(--uui-color-text);
- }
- a#label {
- text-decoration: none;
- color: var(--uui-color-interactive);
- }
- a#label:hover {
- text-decoration: underline;
- color: var(--uui-color-interactive-emphasis);
+
+ &:is(a) {
+ text-decoration: none;
+ color: var(--uui-color-interactive);
+
+ &:hover {
+ text-decoration: underline;
+ color: var(--uui-color-interactive-emphasis);
+ }
+ }
}
`,
];
diff --git a/src/Umbraco.Web.UI.Client/src/packages/media/media/property-editors/upload-field/Umbraco.UploadField.ts b/src/Umbraco.Web.UI.Client/src/packages/media/media/property-editors/upload-field/Umbraco.UploadField.ts
index fe697d8989..ba74e968d8 100644
--- a/src/Umbraco.Web.UI.Client/src/packages/media/media/property-editors/upload-field/Umbraco.UploadField.ts
+++ b/src/Umbraco.Web.UI.Client/src/packages/media/media/property-editors/upload-field/Umbraco.UploadField.ts
@@ -11,7 +11,7 @@ export const manifest: ManifestPropertyEditorSchema = {
{
alias: 'fileExtensions',
label: 'Accepted file extensions',
- propertyEditorUiAlias: 'Umb.PropertyEditorUi.MultipleTextString',
+ propertyEditorUiAlias: 'Umb.PropertyEditorUi.AcceptedUploadTypes',
},
],
},
diff --git a/src/Umbraco.Web.UI.Client/src/packages/property-editors/accepted-types/index.ts b/src/Umbraco.Web.UI.Client/src/packages/property-editors/accepted-types/index.ts
new file mode 100644
index 0000000000..0d1a4e6250
--- /dev/null
+++ b/src/Umbraco.Web.UI.Client/src/packages/property-editors/accepted-types/index.ts
@@ -0,0 +1 @@
+export * from './property-editor-ui-accepted-upload-types.element.js';
diff --git a/src/Umbraco.Web.UI.Client/src/packages/property-editors/accepted-types/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/property-editors/accepted-types/manifests.ts
new file mode 100644
index 0000000000..a88774c861
--- /dev/null
+++ b/src/Umbraco.Web.UI.Client/src/packages/property-editors/accepted-types/manifests.ts
@@ -0,0 +1,15 @@
+import type { ManifestPropertyEditorUi } from '@umbraco-cms/backoffice/property-editor';
+
+export const manifest: ManifestPropertyEditorUi = {
+ type: 'propertyEditorUi',
+ alias: 'Umb.PropertyEditorUi.AcceptedUploadTypes',
+ name: 'Accepted Upload Types Property Editor UI',
+ element: () => import('./property-editor-ui-accepted-upload-types.element.js'),
+ meta: {
+ label: 'Accepted Upload Types',
+ propertyEditorSchemaAlias: 'Umbraco.MultipleTextstring',
+ icon: 'icon-ordered-list',
+ group: 'lists',
+ supportsReadOnly: true,
+ },
+};
diff --git a/src/Umbraco.Web.UI.Client/src/packages/property-editors/accepted-types/property-editor-ui-accepted-upload-types.element.ts b/src/Umbraco.Web.UI.Client/src/packages/property-editors/accepted-types/property-editor-ui-accepted-upload-types.element.ts
new file mode 100644
index 0000000000..9a85fa2b83
--- /dev/null
+++ b/src/Umbraco.Web.UI.Client/src/packages/property-editors/accepted-types/property-editor-ui-accepted-upload-types.element.ts
@@ -0,0 +1,143 @@
+import { UmbPropertyEditorUIMultipleTextStringElement } from '../multiple-text-string/property-editor-ui-multiple-text-string.element.js';
+import { css, customElement, html, nothing, state, when } from '@umbraco-cms/backoffice/external/lit';
+import { formatBytes } from '@umbraco-cms/backoffice/utils';
+import { UmbTemporaryFileConfigRepository } from '@umbraco-cms/backoffice/temporary-file';
+import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/property-editor';
+import type { UmbTemporaryFileConfigurationModel } from '@umbraco-cms/backoffice/temporary-file';
+
+/**
+ * @element umb-property-editor-ui-accepted-upload-types
+ */
+@customElement('umb-property-editor-ui-accepted-upload-types')
+export class UmbPropertyEditorUIAcceptedUploadTypesElement
+ extends UmbPropertyEditorUIMultipleTextStringElement
+ implements UmbPropertyEditorUiElement
+{
+ #temporaryFileConfigRepository = new UmbTemporaryFileConfigRepository(this);
+
+ @state()
+ protected _acceptedTypes: string[] = [];
+
+ @state()
+ protected _disallowedTypes: string[] = [];
+
+ @state()
+ protected _maxFileSize?: number | null;
+
+ override async connectedCallback() {
+ super.connectedCallback();
+
+ await this.#temporaryFileConfigRepository.initialized;
+ this.observe(this.#temporaryFileConfigRepository.all(), (config) => {
+ if (!config) return;
+
+ this.#addValidators(config);
+
+ this._acceptedTypes = config.allowedUploadedFileExtensions;
+ this._disallowedTypes = config.disallowedUploadedFilesExtensions;
+ this._maxFileSize = config.maxFileSize ? config.maxFileSize * 1024 : null;
+ });
+ }
+
+ #addValidators(config: UmbTemporaryFileConfigurationModel) {
+ this._inputElement?.addValidator(
+ 'badInput',
+ () => {
+ let message = this.localize.term('validation_invalidExtensions');
+ if (config.allowedUploadedFileExtensions.length) {
+ message += `
+
+ ${when(
+ this._acceptedTypes.length,
+ () => html`
+
+
+ ${this._acceptedTypes.join(', ')}
+
+ `,
+ )}
+ ${when(
+ this._disallowedTypes.length,
+ () => html`
+
+
+ ${this._disallowedTypes.join(', ')}
+
+ `,
+ )}
+ ${when(
+ this._maxFileSize,
+ () => html`
+
+ ${this.localize.term('media_maxFileSize')}
+ ${formatBytes(this._maxFileSize!, { decimals: 2 })}.
+
+ `,
+ )}
+
+ `;
+ }
+
+ override render() {
+ return html`${this.#renderAcceptedTypes()} ${super.render()}`;
+ }
+
+ static override readonly styles = [
+ css`
+ #notice {
+ --uui-box-default-padding: var(--uui-size-space-4);
+ --uui-box-header-padding: var(--uui-size-space-4);
+ --uui-color-divider-standalone: var(--uui-color-warning-standalone);
+
+ border: 1px solid var(--uui-color-divider-standalone);
+ background-color: var(--uui-color-warning);
+ color: var(--uui-color-warning-contrast);
+ margin-bottom: var(--uui-size-layout-1);
+
+ p {
+ margin: 0.5rem 0;
+ }
+ }
+ `,
+ ];
+}
+
+export default UmbPropertyEditorUIAcceptedUploadTypesElement;
+
+declare global {
+ interface HTMLElementTagNameMap {
+ 'umb-property-editor-ui-accepted-upload-types': UmbPropertyEditorUIAcceptedUploadTypesElement;
+ }
+}
diff --git a/src/Umbraco.Web.UI.Client/src/packages/property-editors/accepted-types/property-editor-ui-accepted-upload-types.stories.ts b/src/Umbraco.Web.UI.Client/src/packages/property-editors/accepted-types/property-editor-ui-accepted-upload-types.stories.ts
new file mode 100644
index 0000000000..b2803dff05
--- /dev/null
+++ b/src/Umbraco.Web.UI.Client/src/packages/property-editors/accepted-types/property-editor-ui-accepted-upload-types.stories.ts
@@ -0,0 +1,15 @@
+import type { UmbPropertyEditorUIAcceptedUploadTypesElement } from './property-editor-ui-accepted-upload-types.element.js';
+import type { Meta, StoryFn } from '@storybook/web-components';
+import { html } from '@umbraco-cms/backoffice/external/lit';
+
+import './property-editor-ui-accepted-types.element.js';
+
+export default {
+ title: 'Property Editor UIs/Accepted Types',
+ component: 'umb-property-editor-ui-accepted-types',
+ id: 'umb-property-editor-ui-accepted-types',
+} as Meta;
+
+export const AAAOverview: StoryFn