@conduction/nextcloud-vue 2.185.1 → 2.186.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/CnCalendarWidget/CnCalendarWidget.vue.js +1 -1
- package/dist/esm/components/CnCalendarWidget/CnCalendarWidget2.vue.js +83 -2
- package/dist/esm/components/CnCalendarWidget/CnCalendarWidget2.vue.js.map +1 -1
- package/dist/esm/components/CnCalendarWidget/CnCalendarWidget3.vue.js +147 -104
- package/dist/esm/components/CnCalendarWidget/CnCalendarWidget3.vue.js.map +1 -1
- package/dist/esm/components/CnChartWidget/CnChartWidget.vue.js +1 -1
- package/dist/esm/components/CnChartWidget/CnChartWidget2.vue.js +58 -0
- package/dist/esm/components/CnChartWidget/CnChartWidget2.vue.js.map +1 -1
- package/dist/esm/components/CnChartWidget/CnChartWidget3.vue.js +2 -2
- package/dist/esm/components/CnChartWidget/CnChartWidget3.vue.js.map +1 -1
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue.js +1 -1
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid2.vue.js +41 -16
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid2.vue.js.map +1 -1
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid3.vue.js.map +1 -1
- package/dist/esm/components/CnDividerWidget/index.js +1 -0
- package/dist/esm/components/CnDividerWidget/index.js.map +1 -1
- package/dist/esm/components/CnFilesWidget/CnFilesWidget.vue.js +1 -1
- package/dist/esm/components/CnFilesWidget/CnFilesWidget2.vue.js +158 -5
- package/dist/esm/components/CnFilesWidget/CnFilesWidget2.vue.js.map +1 -1
- package/dist/esm/components/CnFilesWidget/CnFilesWidget3.vue.js +109 -45
- package/dist/esm/components/CnFilesWidget/CnFilesWidget3.vue.js.map +1 -1
- package/dist/esm/components/CnHeaderWidget/index.js +0 -1
- package/dist/esm/components/CnHeaderWidget/index.js.map +1 -1
- package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm.vue.js +1 -1
- package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm2.vue.js +17 -3
- package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm2.vue.js.map +1 -1
- package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm3.vue.js +3 -3
- package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm3.vue.js.map +1 -1
- package/dist/esm/components/CnVideoWidget/CnVideoWidget.vue.js +1 -1
- package/dist/esm/components/CnVideoWidget/CnVideoWidget2.vue.js +63 -1
- package/dist/esm/components/CnVideoWidget/CnVideoWidget2.vue.js.map +1 -1
- package/dist/esm/components/CnVideoWidget/CnVideoWidget3.vue.js +20 -10
- package/dist/esm/components/CnVideoWidget/CnVideoWidget3.vue.js.map +1 -1
- package/dist/esm/components/CnVideoWidgetForm/CnVideoWidgetForm.vue.js +1 -1
- package/dist/esm/components/CnVideoWidgetForm/CnVideoWidgetForm2.vue.js +15 -0
- package/dist/esm/components/CnVideoWidgetForm/CnVideoWidgetForm2.vue.js.map +1 -1
- package/dist/esm/components/CnVideoWidgetForm/CnVideoWidgetForm3.vue.js +17 -10
- package/dist/esm/components/CnVideoWidgetForm/CnVideoWidgetForm3.vue.js.map +1 -1
- package/dist/esm/components/CnWidgetGrid/dashboardWidgetRegistry.js +1 -0
- package/dist/esm/components/CnWidgetGrid/dashboardWidgetRegistry.js.map +1 -1
- package/dist/esm/dialogs/CnAddWidgetModal.vue.js +1 -1
- package/dist/esm/dialogs/CnAddWidgetModal2.vue.js +18 -4
- package/dist/esm/dialogs/CnAddWidgetModal2.vue.js.map +1 -1
- package/dist/esm/dialogs/CnAddWidgetModal3.vue.js +57 -39
- package/dist/esm/dialogs/CnAddWidgetModal3.vue.js.map +1 -1
- package/dist/esm/l10n/en.json.js +96 -1
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +96 -1
- package/dist/esm/l10n/nl.json.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +309 -192
- package/dist/nextcloud-vue.cjs.js +2359 -1605
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +309 -192
- package/l10n/en.json +96 -1
- package/l10n/nl.json +96 -1
- package/package.json +1 -1
- package/src/components/CnCalendarWidget/CnCalendarWidget.vue +217 -75
- package/src/components/CnChartWidget/CnChartWidget.vue +60 -2
- package/src/components/CnDashboardGrid/CnDashboardGrid.md +1 -1
- package/src/components/CnDashboardGrid/CnDashboardGrid.vue +41 -16
- package/src/components/CnDividerWidget/index.js +1 -0
- package/src/components/CnFilesWidget/CnFilesWidget.vue +278 -5
- package/src/components/CnHeaderWidget/index.js +0 -1
- package/src/components/CnHeaderWidgetForm/CnHeaderWidgetForm.vue +20 -6
- package/src/components/CnVideoWidget/CnVideoWidget.vue +84 -1
- package/src/components/CnVideoWidgetForm/CnVideoWidgetForm.vue +19 -1
- package/src/components/CnWidgetGrid/dashboardWidgetRegistry.js +1 -0
- package/src/dialogs/CnAddWidgetModal.vue +53 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnHeaderWidgetForm3.vue.js","sources":["../../../../src/components/CnHeaderWidgetForm/CnHeaderWidgetForm.vue?vue&type=template&id=7fccc8c4&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-header-widget-form\">\n\t\t<NcTextField\n\t\t\t:modelValue=\"title\"\n\t\t\t:label=\"t('nextcloud-vue', 'Title')\"\n\t\t\t:placeholder=\"t('nextcloud-vue', 'Header title')\"\n\t\t\trequired\n\t\t\t@update:modelValue=\"updateField('title', $event)\" />\n\n\t\t<NcTextField\n\t\t\t:modelValue=\"subtitle\"\n\t\t\t:label=\"t('nextcloud-vue', 'Subtitle (optional)')\"\n\t\t\t:placeholder=\"t('nextcloud-vue', 'Optional subtitle')\"\n\t\t\t@update:modelValue=\"updateField('subtitle', $event)\" />\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"greeting\"\n\t\t\t@update:modelValue=\"updateField('greeting', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Greet the user by name instead of showing the title') }}\n\t\t</NcCheckboxRadioSwitch>\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"showDate\"\n\t\t\t@update:modelValue=\"updateField('showDate', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Show the date of today above the heading') }}\n\t\t</NcCheckboxRadioSwitch>\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"plain\"\n\t\t\t@update:modelValue=\"updateField('plain', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Plain header without a coloured background') }}\n\t\t</NcCheckboxRadioSwitch>\n\n\t\t<!-- Pick a background image. Selection does NOT upload — the file is held\n\t\t and only uploaded when the host modal calls commit() on submit, so\n\t\t re-picking or cancelling writes nothing. Uploads are the reliable\n\t\t path: external image URLs are often blocked by the Nextcloud\n\t\t Content-Security-Policy, so only the background colour would show. -->\n\t\t<div class=\"cn-header-widget-form__upload-row\">\n\t\t\t<label class=\"cn-header-widget-form__upload-label\">\n\t\t\t\t<input\n\t\t\t\t\tref=\"fileInput\"\n\t\t\t\t\ttype=\"file\"\n\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\tclass=\"cn-header-widget-form__file-input\"\n\t\t\t\t\t:disabled=\"uploading\"\n\t\t\t\t\t@change=\"handleFileSelect\">\n\t\t\t\t<span class=\"cn-header-widget-form__upload-button\">\n\t\t\t\t\t{{ pendingFile ? t('nextcloud-vue', 'Change background image') : t('nextcloud-vue', 'Choose background image') }}\n\t\t\t\t</span>\n\t\t\t</label>\n\t\t\t<NcButton\n\t\t\t\tv-if=\"pendingFile\"\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t:disabled=\"uploading\"\n\t\t\t\t@click=\"clearPendingFile\">\n\t\t\t\t{{ t('nextcloud-vue', 'Remove') }}\n\t\t\t</NcButton>\n\t\t</div>\n\t\t<p v-if=\"pendingFile\" class=\"cn-header-widget-form__pending\">\n\t\t\t{{ t('nextcloud-vue', 'Ready to upload on save: {name}', { name: pendingFile.name }) }}\n\t\t</p>\n\t\t<p v-if=\"uploadError\" class=\"cn-header-widget-form__error\" role=\"alert\">\n\t\t\t{{ uploadError }}\n\t\t</p>\n\n\t\t<NcTextField\n\t\t\t:modelValue=\"backgroundImageUrl\"\n\t\t\t:label=\"t('nextcloud-vue', 'Background image URL')\"\n\t\t\tplaceholder=\"https://example.com/banner.jpg\"\n\t\t\t:disabled=\"!!pendingFile\"\n\t\t\t@update:modelValue=\"updateField('backgroundImageUrl', $event)\" />\n\n\t\t<label class=\"cn-header-widget-form__color-label\">\n\t\t\t{{ t('nextcloud-vue', 'Background color') }}\n\t\t\t<CnColorPicker\n\t\t\t\t:value=\"backgroundColor\"\n\t\t\t\tclearable\n\t\t\t\t@input=\"updateField('backgroundColor', $event.hex)\"\n\t\t\t\t@clear=\"updateField('backgroundColor', '')\" />\n\t\t</label>\n\n\t\t<NcSelect\n\t\t\t:modelValue=\"overlayMode\"\n\t\t\t:options=\"overlayModeOptions\"\n\t\t\t:inputLabel=\"t('nextcloud-vue', 'Overlay mode')\"\n\t\t\t:reduce=\"(option) => option.value\"\n\t\t\tlabel=\"label\"\n\t\t\t:clearable=\"false\"\n\t\t\t@update:modelValue=\"updateField('overlayMode', $event)\" />\n\n\t\t<label v-if=\"overlayMode !== 'none'\" class=\"cn-header-widget-form__color-label\">\n\t\t\t{{ t('nextcloud-vue', 'Overlay color') }}\n\t\t\t<CnColorPicker\n\t\t\t\t:value=\"overlayColor\"\n\t\t\t\tclearable\n\t\t\t\t@input=\"updateField('overlayColor', $event.hex)\"\n\t\t\t\t@clear=\"updateField('overlayColor', '')\" />\n\t\t</label>\n\n\t\t<label v-if=\"overlayMode === 'tint'\" class=\"cn-header-widget-form__field\">\n\t\t\t<span class=\"cn-header-widget-form__label\">\n\t\t\t\t{{ t('nextcloud-vue', 'Overlay opacity') }} ({{ overlayOpacity.toFixed(2) }})\n\t\t\t</span>\n\t\t\t<input\n\t\t\t\ttype=\"range\"\n\t\t\t\tmin=\"0\"\n\t\t\t\tmax=\"1\"\n\t\t\t\tstep=\"0.05\"\n\t\t\t\t:value=\"overlayOpacity\"\n\t\t\t\tclass=\"cn-header-widget-form__range\"\n\t\t\t\t@input=\"updateField('overlayOpacity', parseFloat($event.target.value))\">\n\t\t</label>\n\n\t\t<label class=\"cn-header-widget-form__color-label\">\n\t\t\t{{ t('nextcloud-vue', 'Text color') }}\n\t\t\t<CnColorPicker\n\t\t\t\t:value=\"textColor\"\n\t\t\t\tclearable\n\t\t\t\t@input=\"updateField('textColor', $event.hex)\"\n\t\t\t\t@clear=\"updateField('textColor', '')\" />\n\t\t</label>\n\n\t\t<NcSelect\n\t\t\t:modelValue=\"textAlign\"\n\t\t\t:options=\"textAlignOptions\"\n\t\t\t:inputLabel=\"t('nextcloud-vue', 'Text alignment')\"\n\t\t\t:reduce=\"(option) => option.value\"\n\t\t\tlabel=\"label\"\n\t\t\t:clearable=\"false\"\n\t\t\t@update:modelValue=\"updateField('textAlign', $event)\" />\n\n\t\t<NcSelect\n\t\t\t:modelValue=\"verticalAlign\"\n\t\t\t:options=\"verticalAlignOptions\"\n\t\t\t:inputLabel=\"t('nextcloud-vue', 'Vertical alignment')\"\n\t\t\t:reduce=\"(option) => option.value\"\n\t\t\tlabel=\"label\"\n\t\t\t:clearable=\"false\"\n\t\t\t@update:modelValue=\"updateField('verticalAlign', $event)\" />\n\n\t\t<!-- The banner fills its dashboard grid cell, so a fixed Height preset\n\t\t no longer changes anything — resize the widget on the grid instead.\n\t\t (The `height` field is kept in the saved content for back-compat\n\t\t but is no longer surfaced as a control.) -->\n\n\t\t<fieldset class=\"cn-header-widget-form__fieldset\">\n\t\t\t<legend class=\"cn-header-widget-form__legend\">\n\t\t\t\t{{ t('nextcloud-vue', 'Call-to-action button (optional)') }}\n\t\t\t</legend>\n\n\t\t\t<NcTextField\n\t\t\t\t:modelValue=\"ctaLabel\"\n\t\t\t\t:label=\"t('nextcloud-vue', 'Button text')\"\n\t\t\t\t:placeholder=\"t('nextcloud-vue', 'Sign up')\"\n\t\t\t\t@update:modelValue=\"updateCta('label', $event)\" />\n\n\t\t\t<NcTextField\n\t\t\t\t:modelValue=\"ctaUrl\"\n\t\t\t\t:label=\"t('nextcloud-vue', 'Target URL')\"\n\t\t\t\tplaceholder=\"https://...\"\n\t\t\t\t@update:modelValue=\"updateCta('url', $event)\" />\n\n\t\t\t<NcSelect\n\t\t\t\t:modelValue=\"ctaStyle\"\n\t\t\t\t:options=\"ctaStyleOptions\"\n\t\t\t\t:inputLabel=\"t('nextcloud-vue', 'Button style')\"\n\t\t\t\t:reduce=\"(option) => option.value\"\n\t\t\t\tlabel=\"label\"\n\t\t\t\t:clearable=\"false\"\n\t\t\t\t@update:modelValue=\"updateCta('style', $event)\" />\n\t\t</fieldset>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcCheckboxRadioSwitch, NcSelect, NcTextField } from '@nextcloud/vue'\nimport CnColorPicker from '../CnColorPicker/CnColorPicker.vue'\nimport { embedAsDataUrl, extractTransportUrl, readFileAsDataUrl, warnUploadFnDeprecated } from '../../utils/widgetUpload.js'\n\nconst ALLOWED_OVERLAY_MODES = ['none', 'tint', 'gradient-bottom']\nconst ALLOWED_HEIGHTS = ['small', 'medium', 'large', 'xlarge']\nconst ALLOWED_TEXT_ALIGN = ['left', 'center', 'right']\nconst ALLOWED_VERTICAL_ALIGN = ['top', 'middle', 'bottom']\nconst ALLOWED_CTA_STYLES = ['primary', 'secondary', 'ghost']\n\nconst DEFAULT_CONTENT = Object.freeze({\n\ttitle: '',\n\tsubtitle: '',\n\tbackgroundImageUrl: '',\n\tbackgroundImageFileId: null,\n\tbackgroundColor: '',\n\toverlayMode: 'none',\n\toverlayColor: '',\n\toverlayOpacity: 0.4,\n\ttextColor: '',\n\ttextAlign: 'center',\n\tverticalAlign: 'middle',\n\theight: 'medium',\n\tcta: null,\n})\n\n/**\n * CnHeaderWidgetForm — the `CnAddWidgetModal` sub-form for creating or editing\n * a `header` widget placement (renderer: `CnHeaderWidget`).\n *\n * Controls cover every persisted field: title, subtitle, background image URL,\n * background colour, overlay mode/colour/opacity, text colour/alignment/\n * vertical alignment, height preset, and an optional call-to-action with\n * label, URL, and style. `validate()` requires `title`, requires any provided\n * `backgroundImageUrl` to be http(s), and flags a half-filled CTA (label XOR\n * url). Emits `update:content` with the assembled blob on change.\n */\nexport default {\n\tname: 'CnHeaderWidgetForm',\n\n\tcomponents: {\n\t\tNcTextField,\n\t\tNcSelect,\n\t\tNcButton,\n\t\tNcCheckboxRadioSwitch,\n\t\tCnColorPicker,\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The placement being edited, or `null` in create mode.\n\t\t *\n\t\t * @type {{content: object}|null}\n\t\t */\n\t\teditingWidget: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/**\n\t\t * Initial content values — used when not editing and the parent\n\t\t * supplies registry defaults.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tvalue: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({ ...DEFAULT_CONTENT }),\n\t\t},\n\n\t\t/**\n\t\t * Optional raw-file upload transport: `async (file: File) => ({ url })`.\n\t\t * Named `fileUploadFn` (not `uploadFn`) to match `CnAddWidgetModal`'s\n\t\t * File-typed sub-form transport. Called by `commit()` on submit (never on\n\t\t * file selection) with the raw picked `File`; the returned hosted URL is\n\t\t * stored as `backgroundImageUrl`. When omitted, the file is embedded as a\n\t\t * data URL on commit instead (same-origin, so it isn't blocked by the CSP\n\t\t * the way external http(s) URLs are) — but only when the raw file is ≤ 1 MB\n\t\t * (~1.37 MB once base64-encoded and stored) so a huge inline blob can't\n\t\t * freeze the tab. Wire a transport for anything larger.\n\t\t *\n\t\t * @type {((file: File) => Promise<{ url: string }>)|null}\n\t\t */\n\t\tfileUploadFn: {\n\t\t\ttype: Function,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/**\n\t\t * Legacy base64 upload transport, superseded by `fileUploadFn`.\n\t\t *\n\t\t * @deprecated Use `fileUploadFn` instead. Legacy base64 transport\n\t\t * `async (dataUrl: string) => ({ url })`, kept for backward compatibility.\n\t\t * When `fileUploadFn` is not set but this is, `commit()` reads the file to\n\t\t * a data URL and hands that to this function (emitting a one-time\n\t\t * console.warn). `fileUploadFn` takes precedence when both are provided.\n\t\t *\n\t\t * @type {((dataUrl: string) => Promise<{ url: string }>)|null}\n\t\t */\n\t\tuploadFn: {\n\t\t\ttype: Function,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\temits: [\n\t\t/**\n\t\t * Emitted with the assembled content blob on every field change.\n\t\t *\n\t\t * @event update:content\n\t\t * @type {object}\n\t\t */\n\t\t'update:content',\n\t],\n\n\tdata() {\n\t\tconst initial = (this.editingWidget && this.editingWidget.content) || this.value || {}\n\t\tconst cta = (initial.cta && typeof initial.cta === 'object') ? initial.cta : null\n\t\treturn {\n\t\t\ttitle: typeof initial.title === 'string' ? initial.title : DEFAULT_CONTENT.title,\n\t\t\tsubtitle: typeof initial.subtitle === 'string' ? initial.subtitle : DEFAULT_CONTENT.subtitle,\n\t\t\tgreeting: initial.greeting === true || initial.greeting === 'full' || initial.greeting === 'first',\n\t\t\t// `\"full\"` (whole display name) is a manifest choice; kept as written.\n\t\t\tgreetingMode: initial.greeting === 'full' ? 'full' : true,\n\t\t\tshowDate: initial.showDate === true,\n\t\t\tplain: initial.plain === true,\n\t\t\tbackgroundImageUrl: typeof initial.backgroundImageUrl === 'string'\n\t\t\t\t? initial.backgroundImageUrl\n\t\t\t\t: DEFAULT_CONTENT.backgroundImageUrl,\n\n\t\t\tbackgroundImageFileId: (typeof initial.backgroundImageFileId === 'number')\n\t\t\t\t? initial.backgroundImageFileId\n\t\t\t\t: DEFAULT_CONTENT.backgroundImageFileId,\n\n\t\t\tbackgroundColor: typeof initial.backgroundColor === 'string'\n\t\t\t\t? initial.backgroundColor\n\t\t\t\t: DEFAULT_CONTENT.backgroundColor,\n\n\t\t\toverlayMode: ALLOWED_OVERLAY_MODES.includes(initial.overlayMode)\n\t\t\t\t? initial.overlayMode\n\t\t\t\t: DEFAULT_CONTENT.overlayMode,\n\n\t\t\toverlayColor: typeof initial.overlayColor === 'string'\n\t\t\t\t? initial.overlayColor\n\t\t\t\t: DEFAULT_CONTENT.overlayColor,\n\n\t\t\toverlayOpacity: typeof initial.overlayOpacity === 'number'\n\t\t\t\t? initial.overlayOpacity\n\t\t\t\t: DEFAULT_CONTENT.overlayOpacity,\n\n\t\t\ttextColor: typeof initial.textColor === 'string'\n\t\t\t\t? initial.textColor\n\t\t\t\t: DEFAULT_CONTENT.textColor,\n\n\t\t\ttextAlign: ALLOWED_TEXT_ALIGN.includes(initial.textAlign)\n\t\t\t\t? initial.textAlign\n\t\t\t\t: DEFAULT_CONTENT.textAlign,\n\n\t\t\tverticalAlign: ALLOWED_VERTICAL_ALIGN.includes(initial.verticalAlign)\n\t\t\t\t? initial.verticalAlign\n\t\t\t\t: DEFAULT_CONTENT.verticalAlign,\n\n\t\t\theight: ALLOWED_HEIGHTS.includes(initial.height)\n\t\t\t\t? initial.height\n\t\t\t\t: DEFAULT_CONTENT.height,\n\n\t\t\tctaLabel: cta && typeof cta.label === 'string' ? cta.label : '',\n\t\t\tctaUrl: cta && typeof cta.url === 'string' ? cta.url : '',\n\t\t\tctaStyle: (cta && ALLOWED_CTA_STYLES.includes(cta.style)) ? cta.style : 'primary',\n\t\t\tuploading: false,\n\t\t\tuploadError: '',\n\t\t\t// The picked-but-not-yet-uploaded file. Upload is deferred to commit()\n\t\t\t// so nothing is written on selection.\n\t\t\tpendingFile: null,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** Overlay-mode select options. */\n\t\toverlayModeOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: 'none', label: t('nextcloud-vue', 'None') },\n\t\t\t\t{ value: 'tint', label: t('nextcloud-vue', 'Tinted overlay') },\n\t\t\t\t{ value: 'gradient-bottom', label: t('nextcloud-vue', 'Gradient bottom') },\n\t\t\t]\n\t\t},\n\n\t\t/** Text-alignment select options. */\n\t\ttextAlignOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: 'left', label: t('nextcloud-vue', 'Left') },\n\t\t\t\t{ value: 'center', label: t('nextcloud-vue', 'Center') },\n\t\t\t\t{ value: 'right', label: t('nextcloud-vue', 'Right') },\n\t\t\t]\n\t\t},\n\n\t\t/** Vertical-alignment select options. */\n\t\tverticalAlignOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: 'top', label: t('nextcloud-vue', 'Top') },\n\t\t\t\t{ value: 'middle', label: t('nextcloud-vue', 'Middle') },\n\t\t\t\t{ value: 'bottom', label: t('nextcloud-vue', 'Bottom') },\n\t\t\t]\n\t\t},\n\n\t\t/** Height-preset select options. */\n\t\theightOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: 'small', label: t('nextcloud-vue', 'Small (120px)') },\n\t\t\t\t{ value: 'medium', label: t('nextcloud-vue', 'Medium (200px)') },\n\t\t\t\t{ value: 'large', label: t('nextcloud-vue', 'Large (320px)') },\n\t\t\t\t{ value: 'xlarge', label: t('nextcloud-vue', 'Extra large (480px)') },\n\t\t\t]\n\t\t},\n\n\t\t/** CTA-style select options. */\n\t\tctaStyleOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: 'primary', label: t('nextcloud-vue', 'Primary') },\n\t\t\t\t{ value: 'secondary', label: t('nextcloud-vue', 'Secondary') },\n\t\t\t\t{ value: 'ghost', label: t('nextcloud-vue', 'Ghost') },\n\t\t\t]\n\t\t},\n\n\t\t/** The assembled CTA object, or null when both fields are empty. */\n\t\tctaPayload() {\n\t\t\tconst label = typeof this.ctaLabel === 'string' ? this.ctaLabel.trim() : ''\n\t\t\tconst url = typeof this.ctaUrl === 'string' ? this.ctaUrl.trim() : ''\n\t\t\tif (label === '' && url === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\turl,\n\t\t\t\tstyle: this.ctaStyle,\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The greeting keys, written only when they are on, so a header that\n\t\t * never used them keeps the content blob it always had.\n\t\t *\n\t\t * @return {object}\n\t\t * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-greeting-header\n\t\t */\n\t\tgreetingContent() {\n\t\t\tconst content = {}\n\t\t\tif (this.greeting) {\n\t\t\t\tcontent.greeting = this.greetingMode\n\t\t\t}\n\t\t\tif (this.showDate) {\n\t\t\t\tcontent.showDate = true\n\t\t\t}\n\t\t\tif (this.plain) {\n\t\t\t\tcontent.plain = true\n\t\t\t}\n\t\t\treturn content\n\t\t},\n\n\t\t/**\n\t\t * The full content blob assembled from the current field values.\n\t\t *\n\t\t * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-greeting-header\n\t\t */\n\t\tassembledContent() {\n\t\t\treturn {\n\t\t\t\t...this.greetingContent,\n\t\t\t\ttitle: this.title,\n\t\t\t\tsubtitle: this.subtitle,\n\t\t\t\tbackgroundImageUrl: this.backgroundImageUrl,\n\t\t\t\tbackgroundImageFileId: this.backgroundImageFileId,\n\t\t\t\tbackgroundColor: this.backgroundColor,\n\t\t\t\toverlayMode: this.overlayMode,\n\t\t\t\toverlayColor: this.overlayColor,\n\t\t\t\toverlayOpacity: this.overlayOpacity,\n\t\t\t\ttextColor: this.textColor,\n\t\t\t\ttextAlign: this.textAlign,\n\t\t\t\tverticalAlign: this.verticalAlign,\n\t\t\t\theight: this.height,\n\t\t\t\tcta: this.ctaPayload,\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * Set a top-level field and re-emit the assembled payload.\n\t\t *\n\t\t * @param {string} field one of the top-level content keys.\n\t\t * @param {unknown} value the new value.\n\t\t * @return {void}\n\t\t */\n\t\tupdateField(field, value) {\n\t\t\tthis[field] = value\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * Hold the picked file for a deferred upload. Does NOT upload — that\n\t\t * happens in commit() when the host modal submits, so re-picking or\n\t\t * cancelling writes nothing.\n\t\t *\n\t\t * @param {Event} event the file-input change event.\n\t\t * @return {void}\n\t\t *\n\t\t * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n\t\t */\n\t\thandleFileSelect(event) {\n\t\t\tconst file = event.target.files && event.target.files[0]\n\t\t\tif (!file) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.uploadError = ''\n\t\t\tthis.pendingFile = file\n\t\t\tthis.resetFileInput()\n\t\t},\n\n\t\t/**\n\t\t * Upload the pending file (if any) and store it as backgroundImageUrl.\n\t\t * Called by the host modal on submit. A no-op when no file is pending, so\n\t\t * editing without changing the image keeps the existing value.\n\t\t *\n\t\t * @return {Promise<void>} resolves once the URL is set.\n\t\t * @throws {Error} when the upload fails, so the modal can block submit.\n\t\t *\n\t\t * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n\t\t */\n\t\tasync commit() {\n\t\t\tif (this.pendingFile === null) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.uploadError = ''\n\t\t\tthis.uploading = true\n\t\t\ttry {\n\t\t\t\tlet resolvedUrl\n\t\t\t\tif (typeof this.fileUploadFn === 'function') {\n\t\t\t\t\tresolvedUrl = extractTransportUrl(await this.fileUploadFn(this.pendingFile))\n\t\t\t\t} else if (typeof this.uploadFn === 'function') {\n\t\t\t\t\t// Deprecated path: the legacy uploadFn expects a base64 data URL.\n\t\t\t\t\twarnUploadFnDeprecated('CnHeaderWidgetForm')\n\t\t\t\t\tconst dataUrl = await readFileAsDataUrl(this.pendingFile)\n\t\t\t\t\tresolvedUrl = extractTransportUrl(await this.uploadFn(dataUrl))\n\t\t\t\t} else {\n\t\t\t\t\tresolvedUrl = await embedAsDataUrl(this.pendingFile)\n\t\t\t\t}\n\t\t\t\tthis.pendingFile = null\n\t\t\t\tthis.updateField('backgroundImageUrl', resolvedUrl)\n\t\t\t} catch (err) {\n\t\t\t\tthis.uploadError = (err && err.message) || t('nextcloud-vue', 'Failed to upload image')\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.error('Header image upload failed:', err)\n\t\t\t\tthrow err\n\t\t\t} finally {\n\t\t\t\tthis.uploading = false\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Discard the pending file, re-enabling the URL field. Called by the\n\t\t * Remove button.\n\t\t *\n\t\t * @return {void}\n\t\t *\n\t\t * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n\t\t */\n\t\tclearPendingFile() {\n\t\t\tthis.pendingFile = null\n\t\t\tthis.uploadError = ''\n\t\t\tthis.resetFileInput()\n\t\t},\n\n\t\t/**\n\t\t * Clear the native file input so re-selecting the same file re-fires.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\tresetFileInput() {\n\t\t\tif (this.$refs.fileInput) {\n\t\t\t\tthis.$refs.fileInput.value = ''\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Set a CTA sub-field (label, url, style) and re-emit.\n\t\t *\n\t\t * @param {string} field one of: label, url, style.\n\t\t * @param {string} value the new value.\n\t\t * @return {void}\n\t\t */\n\t\tupdateCta(field, value) {\n\t\t\tif (field === 'label') {\n\t\t\t\tthis.ctaLabel = value\n\t\t\t} else if (field === 'url') {\n\t\t\t\tthis.ctaUrl = value\n\t\t\t} else if (field === 'style') {\n\t\t\t\tthis.ctaStyle = value\n\t\t\t}\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * Validate the form; an empty array means valid. Requires a title,\n\t\t * an http(s) background image URL when provided, and a complete CTA\n\t\t * when either CTA field is filled.\n\t\t *\n\t\t * @return {string[]} the validation errors.\n\t\t * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-greeting-header\n\t\t */\n\t\tvalidate() {\n\t\t\tconst errors = []\n\t\t\t// A greeting is the heading, so a greeting header needs no title.\n\t\t\tif (!this.greeting && (typeof this.title !== 'string' || this.title.trim() === '')) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Title is required'))\n\t\t\t}\n\t\t\tif (typeof this.backgroundImageUrl === 'string'\n\t\t\t\t&& this.backgroundImageUrl.trim() !== ''\n\t\t\t\t&& /^(https?:\\/\\/|data:|blob:|\\/)/i.test(this.backgroundImageUrl.trim()) === false) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Background image must be a URL or an uploaded image'))\n\t\t\t}\n\t\t\tconst labelEmpty = typeof this.ctaLabel !== 'string' || this.ctaLabel.trim() === ''\n\t\t\tconst urlEmpty = typeof this.ctaUrl !== 'string' || this.ctaUrl.trim() === ''\n\t\t\tif (labelEmpty !== urlEmpty) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Call-to-action requires both label and URL'))\n\t\t\t}\n\t\t\treturn errors\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-header-widget-form {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n}\n\n.cn-header-widget-form__field {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n\tfont-size: 14px;\n}\n\n.cn-header-widget-form__label {\n\tfont-weight: 500;\n}\n\n.cn-header-widget-form__color-label {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tgap: 12px;\n\tfont-size: 14px;\n}\n\n.cn-header-widget-form__upload-row {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n}\n\n.cn-header-widget-form__upload-label {\n\tdisplay: inline-flex;\n\tcursor: pointer;\n}\n\n.cn-header-widget-form__pending {\n\tmargin: 0;\n\tfont-size: 12px;\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-header-widget-form__file-input {\n\tdisplay: none;\n}\n\n.cn-header-widget-form__upload-button {\n\tpadding: 8px 12px;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n\tbackground-color: var(--color-background-hover);\n\tfont-size: 14px;\n}\n\n.cn-header-widget-form__upload-label:hover .cn-header-widget-form__upload-button {\n\tbackground-color: var(--color-background-dark);\n}\n\n.cn-header-widget-form__error {\n\tmargin: 0;\n\tfont-size: 12px;\n\tcolor: var(--color-error);\n}\n\n.cn-header-widget-form__color {\n\twidth: 48px;\n\theight: 32px;\n\tpadding: 0;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n\tcursor: pointer;\n\tbackground: transparent;\n}\n\n.cn-header-widget-form__range {\n\twidth: 100%;\n}\n\n.cn-header-widget-form__fieldset {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n\tpadding: 12px;\n}\n\n.cn-header-widget-form__legend {\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tpadding: 0 4px;\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_createVNode","_createElementVNode","_toDisplayString","_createBlock","_createTextVNode"],"mappings":";;AAWM,MAAA,UAAA,GAAA,EAAA,KAAI,EAAA,uBAAA;AAmCH,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,mCAAO;AACV,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,qCAA6B;;AAQnC,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,sCAAK;;;AAYhB,EAAA,KAAA,EAAA;;;;AAGmB,EAAA,KAAK,EAAC,8BAAI;AAAA,EAAA,IAAA,EAAA;;AAWzB,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,oCAAoC;;;AAkBb,EAAA,KAAM,EAAC;;;;AAS9B,EAAA,KAAA,EAAA;;AACN,MAAA,WAAA,GAAA,EAAA,KAAC,EAAA,8BAAA;;AAaD,MA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js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-header-widget-form\">\n\t\t<NcTextField\n\t\t\t:modelValue=\"title\"\n\t\t\t:label=\"t('nextcloud-vue', 'Title')\"\n\t\t\t:placeholder=\"t('nextcloud-vue', 'Header title')\"\n\t\t\trequired\n\t\t\t@update:modelValue=\"updateField('title', $event)\" />\n\n\t\t<NcTextField\n\t\t\t:modelValue=\"subtitle\"\n\t\t\t:label=\"t('nextcloud-vue', 'Subtitle (optional)')\"\n\t\t\t:placeholder=\"t('nextcloud-vue', 'Optional subtitle')\"\n\t\t\t@update:modelValue=\"updateField('subtitle', $event)\" />\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"greeting\"\n\t\t\t@update:modelValue=\"updateField('greeting', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Greet the user by name instead of showing the title') }}\n\t\t</NcCheckboxRadioSwitch>\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"showDate\"\n\t\t\t@update:modelValue=\"updateField('showDate', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Show the date of today above the heading') }}\n\t\t</NcCheckboxRadioSwitch>\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"plain\"\n\t\t\t@update:modelValue=\"updateField('plain', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Plain header without a coloured background') }}\n\t\t</NcCheckboxRadioSwitch>\n\n\t\t<!-- Pick a background image. Selection does NOT upload — the file is held\n\t\t and only uploaded when the host modal calls commit() on submit, so\n\t\t re-picking or cancelling writes nothing. Uploads are the reliable\n\t\t path: external image URLs are often blocked by the Nextcloud\n\t\t Content-Security-Policy, so only the background colour would show. -->\n\t\t<div class=\"cn-header-widget-form__upload-row\">\n\t\t\t<label class=\"cn-header-widget-form__upload-label\">\n\t\t\t\t<input\n\t\t\t\t\tref=\"fileInput\"\n\t\t\t\t\ttype=\"file\"\n\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\tclass=\"cn-header-widget-form__file-input\"\n\t\t\t\t\t:disabled=\"uploading\"\n\t\t\t\t\t@change=\"handleFileSelect\">\n\t\t\t\t<span class=\"cn-header-widget-form__upload-button\">\n\t\t\t\t\t{{ pendingFile ? t('nextcloud-vue', 'Change background image') : t('nextcloud-vue', 'Choose background image') }}\n\t\t\t\t</span>\n\t\t\t</label>\n\t\t\t<NcButton\n\t\t\t\tv-if=\"pendingFile\"\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t:disabled=\"uploading\"\n\t\t\t\t@click=\"clearPendingFile\">\n\t\t\t\t{{ t('nextcloud-vue', 'Remove') }}\n\t\t\t</NcButton>\n\t\t</div>\n\t\t<p v-if=\"pendingFile\" class=\"cn-header-widget-form__pending\">\n\t\t\t{{ t('nextcloud-vue', 'Ready to upload on save: {name}', { name: pendingFile.name }) }}\n\t\t</p>\n\t\t<p v-if=\"uploadError\" class=\"cn-header-widget-form__error\" role=\"alert\">\n\t\t\t{{ uploadError }}\n\t\t</p>\n\n\t\t<NcTextField\n\t\t\t:modelValue=\"backgroundImageUrl\"\n\t\t\t:label=\"t('nextcloud-vue', 'Background image URL')\"\n\t\t\tplaceholder=\"https://example.com/banner.jpg\"\n\t\t\t:disabled=\"!!pendingFile\"\n\t\t\t@update:modelValue=\"updateField('backgroundImageUrl', $event)\" />\n\n\t\t<label class=\"cn-header-widget-form__color-label\">\n\t\t\t{{ t('nextcloud-vue', 'Background color') }}\n\t\t\t<CnColorPicker\n\t\t\t\t:value=\"backgroundColor\"\n\t\t\t\tclearable\n\t\t\t\t@input=\"updateField('backgroundColor', $event.hex)\"\n\t\t\t\t@clear=\"updateField('backgroundColor', '')\" />\n\t\t</label>\n\n\t\t<NcSelect\n\t\t\t:modelValue=\"effectiveOverlayMode\"\n\t\t\t:options=\"overlayModeOptions\"\n\t\t\t:inputLabel=\"t('nextcloud-vue', 'Overlay mode')\"\n\t\t\t:reduce=\"(option) => option.value\"\n\t\t\tlabel=\"label\"\n\t\t\t:clearable=\"false\"\n\t\t\t@update:modelValue=\"updateField('overlayMode', $event)\" />\n\n\t\t<label v-if=\"effectiveOverlayMode !== 'none'\" class=\"cn-header-widget-form__color-label\">\n\t\t\t{{ t('nextcloud-vue', 'Overlay color') }}\n\t\t\t<CnColorPicker\n\t\t\t\t:value=\"overlayColor\"\n\t\t\t\tclearable\n\t\t\t\t@input=\"updateField('overlayColor', $event.hex)\"\n\t\t\t\t@clear=\"updateField('overlayColor', '')\" />\n\t\t</label>\n\n\t\t<label v-if=\"effectiveOverlayMode === 'tint'\" class=\"cn-header-widget-form__field\">\n\t\t\t<span class=\"cn-header-widget-form__label\">\n\t\t\t\t{{ t('nextcloud-vue', 'Overlay opacity') }} ({{ overlayOpacity.toFixed(2) }})\n\t\t\t</span>\n\t\t\t<input\n\t\t\t\ttype=\"range\"\n\t\t\t\tmin=\"0\"\n\t\t\t\tmax=\"1\"\n\t\t\t\tstep=\"0.05\"\n\t\t\t\t:value=\"overlayOpacity\"\n\t\t\t\tclass=\"cn-header-widget-form__range\"\n\t\t\t\t@input=\"updateField('overlayOpacity', parseFloat($event.target.value))\">\n\t\t</label>\n\n\t\t<label class=\"cn-header-widget-form__color-label\">\n\t\t\t{{ t('nextcloud-vue', 'Text color') }}\n\t\t\t<CnColorPicker\n\t\t\t\t:value=\"textColor\"\n\t\t\t\tclearable\n\t\t\t\t@input=\"updateField('textColor', $event.hex)\"\n\t\t\t\t@clear=\"updateField('textColor', '')\" />\n\t\t</label>\n\n\t\t<NcSelect\n\t\t\t:modelValue=\"textAlign\"\n\t\t\t:options=\"textAlignOptions\"\n\t\t\t:inputLabel=\"t('nextcloud-vue', 'Text alignment')\"\n\t\t\t:reduce=\"(option) => option.value\"\n\t\t\tlabel=\"label\"\n\t\t\t:clearable=\"false\"\n\t\t\t@update:modelValue=\"updateField('textAlign', $event)\" />\n\n\t\t<NcSelect\n\t\t\t:modelValue=\"verticalAlign\"\n\t\t\t:options=\"verticalAlignOptions\"\n\t\t\t:inputLabel=\"t('nextcloud-vue', 'Vertical alignment')\"\n\t\t\t:reduce=\"(option) => option.value\"\n\t\t\tlabel=\"label\"\n\t\t\t:clearable=\"false\"\n\t\t\t@update:modelValue=\"updateField('verticalAlign', $event)\" />\n\n\t\t<!-- The banner fills its dashboard grid cell, so a fixed Height preset\n\t\t no longer changes anything — resize the widget on the grid instead.\n\t\t (The `height` field is kept in the saved content for back-compat\n\t\t but is no longer surfaced as a control.) -->\n\n\t\t<fieldset class=\"cn-header-widget-form__fieldset\">\n\t\t\t<legend class=\"cn-header-widget-form__legend\">\n\t\t\t\t{{ t('nextcloud-vue', 'Call-to-action button (optional)') }}\n\t\t\t</legend>\n\n\t\t\t<NcTextField\n\t\t\t\t:modelValue=\"ctaLabel\"\n\t\t\t\t:label=\"t('nextcloud-vue', 'Button text')\"\n\t\t\t\t:placeholder=\"t('nextcloud-vue', 'Sign up')\"\n\t\t\t\t@update:modelValue=\"updateCta('label', $event)\" />\n\n\t\t\t<NcTextField\n\t\t\t\t:modelValue=\"ctaUrl\"\n\t\t\t\t:label=\"t('nextcloud-vue', 'Target URL')\"\n\t\t\t\tplaceholder=\"https://...\"\n\t\t\t\t@update:modelValue=\"updateCta('url', $event)\" />\n\n\t\t\t<NcSelect\n\t\t\t\t:modelValue=\"ctaStyle\"\n\t\t\t\t:options=\"ctaStyleOptions\"\n\t\t\t\t:inputLabel=\"t('nextcloud-vue', 'Button style')\"\n\t\t\t\t:reduce=\"(option) => option.value\"\n\t\t\t\tlabel=\"label\"\n\t\t\t\t:clearable=\"false\"\n\t\t\t\t@update:modelValue=\"updateCta('style', $event)\" />\n\t\t</fieldset>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcCheckboxRadioSwitch, NcSelect, NcTextField } from '@nextcloud/vue'\nimport CnColorPicker from '../CnColorPicker/CnColorPicker.vue'\nimport { embedAsDataUrl, extractTransportUrl, readFileAsDataUrl, warnUploadFnDeprecated } from '../../utils/widgetUpload.js'\n\nconst ALLOWED_OVERLAY_MODES = ['none', 'tint', 'gradient-bottom']\nconst ALLOWED_HEIGHTS = ['small', 'medium', 'large', 'xlarge']\nconst ALLOWED_TEXT_ALIGN = ['left', 'center', 'right']\nconst ALLOWED_VERTICAL_ALIGN = ['top', 'middle', 'bottom']\nconst ALLOWED_CTA_STYLES = ['primary', 'secondary', 'ghost']\n\nconst DEFAULT_CONTENT = Object.freeze({\n\ttitle: '',\n\tsubtitle: '',\n\tbackgroundImageUrl: '',\n\tbackgroundImageFileId: null,\n\tbackgroundColor: '',\n\toverlayColor: '',\n\toverlayOpacity: 0.4,\n\ttextColor: '',\n\ttextAlign: 'center',\n\tverticalAlign: 'middle',\n\theight: 'medium',\n\tcta: null,\n})\n\n/**\n * CnHeaderWidgetForm — the `CnAddWidgetModal` sub-form for creating or editing\n * a `header` widget placement (renderer: `CnHeaderWidget`).\n *\n * Controls cover every persisted field: title, subtitle, background image URL,\n * background colour, overlay mode/colour/opacity, text colour/alignment/\n * vertical alignment, height preset, and an optional call-to-action with\n * label, URL, and style. `validate()` requires `title`, requires any provided\n * `backgroundImageUrl` to be http(s), and flags a half-filled CTA (label XOR\n * url). Emits `update:content` with the assembled blob on change.\n */\nexport default {\n\tname: 'CnHeaderWidgetForm',\n\n\tcomponents: {\n\t\tNcTextField,\n\t\tNcSelect,\n\t\tNcButton,\n\t\tNcCheckboxRadioSwitch,\n\t\tCnColorPicker,\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * The placement being edited, or `null` in create mode.\n\t\t *\n\t\t * @type {{content: object}|null}\n\t\t */\n\t\teditingWidget: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/**\n\t\t * Initial content values — used when not editing and the parent\n\t\t * supplies registry defaults.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tvalue: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({ ...DEFAULT_CONTENT }),\n\t\t},\n\n\t\t/**\n\t\t * Optional raw-file upload transport: `async (file: File) => ({ url })`.\n\t\t * Named `fileUploadFn` (not `uploadFn`) to match `CnAddWidgetModal`'s\n\t\t * File-typed sub-form transport. Called by `commit()` on submit (never on\n\t\t * file selection) with the raw picked `File`; the returned hosted URL is\n\t\t * stored as `backgroundImageUrl`. When omitted, the file is embedded as a\n\t\t * data URL on commit instead (same-origin, so it isn't blocked by the CSP\n\t\t * the way external http(s) URLs are) — but only when the raw file is ≤ 1 MB\n\t\t * (~1.37 MB once base64-encoded and stored) so a huge inline blob can't\n\t\t * freeze the tab. Wire a transport for anything larger.\n\t\t *\n\t\t * @type {((file: File) => Promise<{ url: string }>)|null}\n\t\t */\n\t\tfileUploadFn: {\n\t\t\ttype: Function,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/**\n\t\t * Legacy base64 upload transport, superseded by `fileUploadFn`.\n\t\t *\n\t\t * @deprecated Use `fileUploadFn` instead. Legacy base64 transport\n\t\t * `async (dataUrl: string) => ({ url })`, kept for backward compatibility.\n\t\t * When `fileUploadFn` is not set but this is, `commit()` reads the file to\n\t\t * a data URL and hands that to this function (emitting a one-time\n\t\t * console.warn). `fileUploadFn` takes precedence when both are provided.\n\t\t *\n\t\t * @type {((dataUrl: string) => Promise<{ url: string }>)|null}\n\t\t */\n\t\tuploadFn: {\n\t\t\ttype: Function,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\temits: [\n\t\t/**\n\t\t * Emitted with the assembled content blob on every field change.\n\t\t *\n\t\t * @event update:content\n\t\t * @type {object}\n\t\t */\n\t\t'update:content',\n\t],\n\n\tdata() {\n\t\tconst initial = (this.editingWidget && this.editingWidget.content) || this.value || {}\n\t\tconst cta = (initial.cta && typeof initial.cta === 'object') ? initial.cta : null\n\t\treturn {\n\t\t\ttitle: typeof initial.title === 'string' ? initial.title : DEFAULT_CONTENT.title,\n\t\t\tsubtitle: typeof initial.subtitle === 'string' ? initial.subtitle : DEFAULT_CONTENT.subtitle,\n\t\t\tgreeting: initial.greeting === true || initial.greeting === 'full' || initial.greeting === 'first',\n\t\t\t// `\"full\"` (whole display name) is a manifest choice; kept as written.\n\t\t\tgreetingMode: initial.greeting === 'full' ? 'full' : true,\n\t\t\tshowDate: initial.showDate === true,\n\t\t\tplain: initial.plain === true,\n\t\t\tbackgroundImageUrl: typeof initial.backgroundImageUrl === 'string'\n\t\t\t\t? initial.backgroundImageUrl\n\t\t\t\t: DEFAULT_CONTENT.backgroundImageUrl,\n\n\t\t\tbackgroundImageFileId: (typeof initial.backgroundImageFileId === 'number')\n\t\t\t\t? initial.backgroundImageFileId\n\t\t\t\t: DEFAULT_CONTENT.backgroundImageFileId,\n\n\t\t\tbackgroundColor: typeof initial.backgroundColor === 'string'\n\t\t\t\t? initial.backgroundColor\n\t\t\t\t: DEFAULT_CONTENT.backgroundColor,\n\n\t\t\t// Empty until chosen: an unset mode is stored as no value, so the\n\t\t\t// renderer keeps its default (`tint` over an image, else `none`).\n\t\t\toverlayMode: ALLOWED_OVERLAY_MODES.includes(initial.overlayMode)\n\t\t\t\t? initial.overlayMode\n\t\t\t\t: '',\n\n\t\t\toverlayColor: typeof initial.overlayColor === 'string'\n\t\t\t\t? initial.overlayColor\n\t\t\t\t: DEFAULT_CONTENT.overlayColor,\n\n\t\t\toverlayOpacity: typeof initial.overlayOpacity === 'number'\n\t\t\t\t? initial.overlayOpacity\n\t\t\t\t: DEFAULT_CONTENT.overlayOpacity,\n\n\t\t\ttextColor: typeof initial.textColor === 'string'\n\t\t\t\t? initial.textColor\n\t\t\t\t: DEFAULT_CONTENT.textColor,\n\n\t\t\ttextAlign: ALLOWED_TEXT_ALIGN.includes(initial.textAlign)\n\t\t\t\t? initial.textAlign\n\t\t\t\t: DEFAULT_CONTENT.textAlign,\n\n\t\t\tverticalAlign: ALLOWED_VERTICAL_ALIGN.includes(initial.verticalAlign)\n\t\t\t\t? initial.verticalAlign\n\t\t\t\t: DEFAULT_CONTENT.verticalAlign,\n\n\t\t\theight: ALLOWED_HEIGHTS.includes(initial.height)\n\t\t\t\t? initial.height\n\t\t\t\t: DEFAULT_CONTENT.height,\n\n\t\t\tctaLabel: cta && typeof cta.label === 'string' ? cta.label : '',\n\t\t\tctaUrl: cta && typeof cta.url === 'string' ? cta.url : '',\n\t\t\tctaStyle: (cta && ALLOWED_CTA_STYLES.includes(cta.style)) ? cta.style : 'primary',\n\t\t\tuploading: false,\n\t\t\tuploadError: '',\n\t\t\t// The picked-but-not-yet-uploaded file. Upload is deferred to commit()\n\t\t\t// so nothing is written on selection.\n\t\t\tpendingFile: null,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The overlay mode the select shows and the overlay fields follow: the\n\t\t * chosen one, else the renderer's default (`tint` over an image).\n\t\t *\n\t\t * @return {string} `none`, `tint` or `gradient-bottom`.\n\t\t */\n\t\teffectiveOverlayMode() {\n\t\t\tif (this.overlayMode) {\n\t\t\t\treturn this.overlayMode\n\t\t\t}\n\t\t\treturn this.backgroundImageUrl || this.backgroundImageFileId !== null || this.pendingFile ? 'tint' : 'none'\n\t\t},\n\n\t\t/** Overlay-mode select options. */\n\t\toverlayModeOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: 'none', label: t('nextcloud-vue', 'None') },\n\t\t\t\t{ value: 'tint', label: t('nextcloud-vue', 'Tinted overlay') },\n\t\t\t\t{ value: 'gradient-bottom', label: t('nextcloud-vue', 'Gradient bottom') },\n\t\t\t]\n\t\t},\n\n\t\t/** Text-alignment select options. */\n\t\ttextAlignOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: 'left', label: t('nextcloud-vue', 'Left') },\n\t\t\t\t{ value: 'center', label: t('nextcloud-vue', 'Center') },\n\t\t\t\t{ value: 'right', label: t('nextcloud-vue', 'Right') },\n\t\t\t]\n\t\t},\n\n\t\t/** Vertical-alignment select options. */\n\t\tverticalAlignOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: 'top', label: t('nextcloud-vue', 'Top') },\n\t\t\t\t{ value: 'middle', label: t('nextcloud-vue', 'Middle') },\n\t\t\t\t{ value: 'bottom', label: t('nextcloud-vue', 'Bottom') },\n\t\t\t]\n\t\t},\n\n\t\t/** Height-preset select options. */\n\t\theightOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: 'small', label: t('nextcloud-vue', 'Small (120px)') },\n\t\t\t\t{ value: 'medium', label: t('nextcloud-vue', 'Medium (200px)') },\n\t\t\t\t{ value: 'large', label: t('nextcloud-vue', 'Large (320px)') },\n\t\t\t\t{ value: 'xlarge', label: t('nextcloud-vue', 'Extra large (480px)') },\n\t\t\t]\n\t\t},\n\n\t\t/** CTA-style select options. */\n\t\tctaStyleOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: 'primary', label: t('nextcloud-vue', 'Primary') },\n\t\t\t\t{ value: 'secondary', label: t('nextcloud-vue', 'Secondary') },\n\t\t\t\t{ value: 'ghost', label: t('nextcloud-vue', 'Ghost') },\n\t\t\t]\n\t\t},\n\n\t\t/** The assembled CTA object, or null when both fields are empty. */\n\t\tctaPayload() {\n\t\t\tconst label = typeof this.ctaLabel === 'string' ? this.ctaLabel.trim() : ''\n\t\t\tconst url = typeof this.ctaUrl === 'string' ? this.ctaUrl.trim() : ''\n\t\t\tif (label === '' && url === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tlabel,\n\t\t\t\turl,\n\t\t\t\tstyle: this.ctaStyle,\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The greeting keys, written only when they are on, so a header that\n\t\t * never used them keeps the content blob it always had.\n\t\t *\n\t\t * @return {object}\n\t\t * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-greeting-header\n\t\t */\n\t\tgreetingContent() {\n\t\t\tconst content = {}\n\t\t\tif (this.greeting) {\n\t\t\t\tcontent.greeting = this.greetingMode\n\t\t\t}\n\t\t\tif (this.showDate) {\n\t\t\t\tcontent.showDate = true\n\t\t\t}\n\t\t\tif (this.plain) {\n\t\t\t\tcontent.plain = true\n\t\t\t}\n\t\t\treturn content\n\t\t},\n\n\t\t/**\n\t\t * The full content blob assembled from the current field values.\n\t\t *\n\t\t * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-greeting-header\n\t\t */\n\t\tassembledContent() {\n\t\t\treturn {\n\t\t\t\t...this.greetingContent,\n\t\t\t\ttitle: this.title,\n\t\t\t\tsubtitle: this.subtitle,\n\t\t\t\tbackgroundImageUrl: this.backgroundImageUrl,\n\t\t\t\tbackgroundImageFileId: this.backgroundImageFileId,\n\t\t\t\tbackgroundColor: this.backgroundColor,\n\t\t\t\t...(this.overlayMode ? { overlayMode: this.overlayMode } : {}),\n\t\t\t\toverlayColor: this.overlayColor,\n\t\t\t\toverlayOpacity: this.overlayOpacity,\n\t\t\t\ttextColor: this.textColor,\n\t\t\t\ttextAlign: this.textAlign,\n\t\t\t\tverticalAlign: this.verticalAlign,\n\t\t\t\theight: this.height,\n\t\t\t\tcta: this.ctaPayload,\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * Set a top-level field and re-emit the assembled payload.\n\t\t *\n\t\t * @param {string} field one of the top-level content keys.\n\t\t * @param {unknown} value the new value.\n\t\t * @return {void}\n\t\t */\n\t\tupdateField(field, value) {\n\t\t\tthis[field] = value\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * Hold the picked file for a deferred upload. Does NOT upload — that\n\t\t * happens in commit() when the host modal submits, so re-picking or\n\t\t * cancelling writes nothing.\n\t\t *\n\t\t * @param {Event} event the file-input change event.\n\t\t * @return {void}\n\t\t *\n\t\t * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n\t\t */\n\t\thandleFileSelect(event) {\n\t\t\tconst file = event.target.files && event.target.files[0]\n\t\t\tif (!file) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.uploadError = ''\n\t\t\tthis.pendingFile = file\n\t\t\tthis.resetFileInput()\n\t\t},\n\n\t\t/**\n\t\t * Upload the pending file (if any) and store it as backgroundImageUrl.\n\t\t * Called by the host modal on submit. A no-op when no file is pending, so\n\t\t * editing without changing the image keeps the existing value.\n\t\t *\n\t\t * @return {Promise<void>} resolves once the URL is set.\n\t\t * @throws {Error} when the upload fails, so the modal can block submit.\n\t\t *\n\t\t * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n\t\t */\n\t\tasync commit() {\n\t\t\tif (this.pendingFile === null) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.uploadError = ''\n\t\t\tthis.uploading = true\n\t\t\ttry {\n\t\t\t\tlet resolvedUrl\n\t\t\t\tif (typeof this.fileUploadFn === 'function') {\n\t\t\t\t\tresolvedUrl = extractTransportUrl(await this.fileUploadFn(this.pendingFile))\n\t\t\t\t} else if (typeof this.uploadFn === 'function') {\n\t\t\t\t\t// Deprecated path: the legacy uploadFn expects a base64 data URL.\n\t\t\t\t\twarnUploadFnDeprecated('CnHeaderWidgetForm')\n\t\t\t\t\tconst dataUrl = await readFileAsDataUrl(this.pendingFile)\n\t\t\t\t\tresolvedUrl = extractTransportUrl(await this.uploadFn(dataUrl))\n\t\t\t\t} else {\n\t\t\t\t\tresolvedUrl = await embedAsDataUrl(this.pendingFile)\n\t\t\t\t}\n\t\t\t\tthis.pendingFile = null\n\t\t\t\tthis.updateField('backgroundImageUrl', resolvedUrl)\n\t\t\t} catch (err) {\n\t\t\t\tthis.uploadError = (err && err.message) || t('nextcloud-vue', 'Failed to upload image')\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.error('Header image upload failed:', err)\n\t\t\t\tthrow err\n\t\t\t} finally {\n\t\t\t\tthis.uploading = false\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Discard the pending file, re-enabling the URL field. Called by the\n\t\t * Remove button.\n\t\t *\n\t\t * @return {void}\n\t\t *\n\t\t * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n\t\t */\n\t\tclearPendingFile() {\n\t\t\tthis.pendingFile = null\n\t\t\tthis.uploadError = ''\n\t\t\tthis.resetFileInput()\n\t\t},\n\n\t\t/**\n\t\t * Clear the native file input so re-selecting the same file re-fires.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\tresetFileInput() {\n\t\t\tif (this.$refs.fileInput) {\n\t\t\t\tthis.$refs.fileInput.value = ''\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Set a CTA sub-field (label, url, style) and re-emit.\n\t\t *\n\t\t * @param {string} field one of: label, url, style.\n\t\t * @param {string} value the new value.\n\t\t * @return {void}\n\t\t */\n\t\tupdateCta(field, value) {\n\t\t\tif (field === 'label') {\n\t\t\t\tthis.ctaLabel = value\n\t\t\t} else if (field === 'url') {\n\t\t\t\tthis.ctaUrl = value\n\t\t\t} else if (field === 'style') {\n\t\t\t\tthis.ctaStyle = value\n\t\t\t}\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * Validate the form; an empty array means valid. Requires a title,\n\t\t * an http(s) background image URL when provided, and a complete CTA\n\t\t * when either CTA field is filled.\n\t\t *\n\t\t * @return {string[]} the validation errors.\n\t\t * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-greeting-header\n\t\t */\n\t\tvalidate() {\n\t\t\tconst errors = []\n\t\t\t// A greeting is the heading, so a greeting header needs no title.\n\t\t\tif (!this.greeting && (typeof this.title !== 'string' || this.title.trim() === '')) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Title is required'))\n\t\t\t}\n\t\t\tif (typeof this.backgroundImageUrl === 'string'\n\t\t\t\t&& this.backgroundImageUrl.trim() !== ''\n\t\t\t\t&& /^(https?:\\/\\/|data:|blob:|\\/)/i.test(this.backgroundImageUrl.trim()) === false) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Background image must be a URL or an uploaded image'))\n\t\t\t}\n\t\t\tconst labelEmpty = typeof this.ctaLabel !== 'string' || this.ctaLabel.trim() === ''\n\t\t\tconst urlEmpty = typeof this.ctaUrl !== 'string' || this.ctaUrl.trim() === ''\n\t\t\tif (labelEmpty !== urlEmpty) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Call-to-action requires both label and URL'))\n\t\t\t}\n\t\t\treturn errors\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-header-widget-form {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n}\n\n.cn-header-widget-form__field {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n\tfont-size: 14px;\n}\n\n.cn-header-widget-form__label {\n\tfont-weight: 500;\n}\n\n.cn-header-widget-form__color-label {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tgap: 12px;\n\tfont-size: 14px;\n}\n\n.cn-header-widget-form__upload-row {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n}\n\n.cn-header-widget-form__upload-label {\n\tdisplay: inline-flex;\n\tcursor: pointer;\n}\n\n.cn-header-widget-form__pending {\n\tmargin: 0;\n\tfont-size: 12px;\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-header-widget-form__file-input {\n\tdisplay: none;\n}\n\n.cn-header-widget-form__upload-button {\n\tpadding: 8px 12px;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n\tbackground-color: var(--color-background-hover);\n\tfont-size: 14px;\n}\n\n.cn-header-widget-form__upload-label:hover .cn-header-widget-form__upload-button {\n\tbackground-color: var(--color-background-dark);\n}\n\n.cn-header-widget-form__error {\n\tmargin: 0;\n\tfont-size: 12px;\n\tcolor: var(--color-error);\n}\n\n.cn-header-widget-form__color {\n\twidth: 48px;\n\theight: 32px;\n\tpadding: 0;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n\tcursor: pointer;\n\tbackground: transparent;\n}\n\n.cn-header-widget-form__range {\n\twidth: 100%;\n}\n\n.cn-header-widget-form__fieldset {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n\tpadding: 12px;\n}\n\n.cn-header-widget-form__legend {\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tpadding: 0 4px;\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_createVNode","_createElementVNode","_toDisplayString","_createBlock","_createTextVNode"],"mappings":";;AAWM,MAAA,UAAA,GAAA,EAAA,KAAI,EAAA,uBAAA;AAmCH,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,mCAAO;AACV,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,qCAA6B;;AAQnC,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,sCAAK;;;AAYhB,EAAA,KAAA,EAAA;;;;AAGmB,EAAA,KAAK,EAAC,8BAAI;AAAA,EAAA,IAAA,EAAA;;AAWzB,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,oCAAoC;;;AAkBH,EAAA,KAAG,EAAA;;;;AASpC,EAAA,KAAA,EAAA;;AACN,MAAA,WAAA,GAAA,EAAA,KAAC,EAAA,8BAAA;;AAaD,MAAA,WAAA,GAAA,EAAA,KAAK,EAAC,oCAAiC;AAgCpC,MAAA,WAAA,GAAA,EAAA,KAAE,EAAA,iCAAA;AACH,MAAA,WAAA,GAAA,EAAA,KAAK,EAAC,+BAAQ;;;;;;;;;AAhJtB,EAAA,QAAAA,SAAA,EAAA,EAAAC,kBAAA,QAAA;gBAMoD,sBAAA,EAAA;;AAHnD,MAAA,KAAK,EAAE,QAAA,CAAA,CAAC,CAAA,eAAA,EAAA,OAAA,CAAA;AACR,MAAA,WAAW,EAAE,QAAA,CAAA,CAAC,CAAA,eAAA,EAAA,cAAA,CAAA;AACf,MAAA,QAAQ,EAAR,EAAQ;MACP,qBAAiB,EAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAA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EAAA,CAAA,KAAA,MAAA,CAAA,EAAA,CAAA,GAAA,MAAA,KAAE,QAAA,CAAA,SAAI,CAAA,OAAA,EAAA,MAAA,CAAA,CAAA;;kBAMuB,sBAAA,EAAA;AAH9C,QAAA,UAAM,EAAA,KAAA,CAAA,MAAA;AACN,QAAA,KAAK,EAAE,QAAA,CAAA,CAAC,CAAA,eAAA,EAAA,YAAA,CAAA;AACT,QAAA,WAAW,EAAC,aAAa;QACxB,qBAAiB,EAAA,MAAA,CAAA,EAAA,CAAA,KAAA,MAAA,CAAA,EAAA,CAAA,GAAA,MAAA,KAAE,QAAA,CAAA,SAAS,CAAA,KAAA,EAAQ,MAAM,CAAA,CAAA;;;AAG1C,QAAA,UAAU,EAAE,KAAA,CAAA,QAAI;AAChB,QAAA,OAAO,EAAE,QAAA,CAAA,eAAe;AACxB,QAAA,UAAO,EAAA,QAAA,CAAA,CAAA,CAAA,eAAA,EAAA,cAAA,CAAA;AACP,QAAA,MAAC,EAAA,CAAA,MAAA,KAAA,MAAA,CAAA,KAAA;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import script from './CnVideoWidget2.vue.js';
|
|
|
2
2
|
import { render } from './CnVideoWidget3.vue.js';
|
|
3
3
|
|
|
4
4
|
script.render = render;
|
|
5
|
-
script.__scopeId = "data-v-
|
|
5
|
+
script.__scopeId = "data-v-e01017fa";
|
|
6
6
|
const __sfc_main = script;
|
|
7
7
|
|
|
8
8
|
export { __sfc_main as default };
|
|
@@ -48,6 +48,17 @@ var script = {
|
|
|
48
48
|
default: () => ({}),
|
|
49
49
|
},
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Whether the viewer may edit this placement (the host's edit mode).
|
|
53
|
+
* The empty state then offers "Configure now", which emits `edit`.
|
|
54
|
+
*
|
|
55
|
+
* @type {boolean}
|
|
56
|
+
*/
|
|
57
|
+
canEdit: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: false,
|
|
60
|
+
},
|
|
61
|
+
|
|
51
62
|
/* eslint-disable vue/no-unused-properties -- part of the widget contract: CnContainerChild and the dashboard pages bind :placement on every widget, so declaring it keeps it out of $attrs */
|
|
52
63
|
/** The placement record (reserved — kept to match the renderer contract). */
|
|
53
64
|
placement: {
|
|
@@ -57,11 +68,24 @@ var script = {
|
|
|
57
68
|
/* eslint-enable vue/no-unused-properties */
|
|
58
69
|
},
|
|
59
70
|
|
|
71
|
+
emits: [
|
|
72
|
+
/**
|
|
73
|
+
* "Configure now" was chosen in the empty state, so the host can open
|
|
74
|
+
* the widget settings.
|
|
75
|
+
*
|
|
76
|
+
* @event edit
|
|
77
|
+
*/
|
|
78
|
+
'edit',
|
|
79
|
+
],
|
|
80
|
+
|
|
60
81
|
data() {
|
|
61
82
|
return {
|
|
62
83
|
// Set when the HTML5 <video> fires an error so subsequent renders
|
|
63
84
|
// show the error placeholder rather than a broken element.
|
|
64
85
|
videoLoadFailed: false,
|
|
86
|
+
// The widget's own size, so a portrait ratio in a landscape cell
|
|
87
|
+
// is fitted by its height instead of overflowing it.
|
|
88
|
+
box: { width: 0, height: 0 },
|
|
65
89
|
}
|
|
66
90
|
},
|
|
67
91
|
|
|
@@ -275,6 +299,11 @@ var script = {
|
|
|
275
299
|
}
|
|
276
300
|
if (this.loop) {
|
|
277
301
|
params.push('loop=1');
|
|
302
|
+
// YouTube loops a single video only as a one-item playlist.
|
|
303
|
+
const id = this.sourceType === 'youtube' ? this.youtubeVideoId : '';
|
|
304
|
+
if (id) {
|
|
305
|
+
params.push(`playlist=${encodeURIComponent(id)}`);
|
|
306
|
+
}
|
|
278
307
|
}
|
|
279
308
|
if (params.length === 0) {
|
|
280
309
|
return this.videoUrl
|
|
@@ -283,6 +312,16 @@ var script = {
|
|
|
283
312
|
return this.videoUrl + separator + params.join('&')
|
|
284
313
|
},
|
|
285
314
|
|
|
315
|
+
/**
|
|
316
|
+
* The video id in a canonical YouTube embed URL (`/embed/<id>`).
|
|
317
|
+
*
|
|
318
|
+
* @return {string} the id, or `''`.
|
|
319
|
+
*/
|
|
320
|
+
youtubeVideoId() {
|
|
321
|
+
const match = this.videoUrl.match(/\/embed\/([^/?#&]+)/);
|
|
322
|
+
return match ? decodeURIComponent(match[1]) : ''
|
|
323
|
+
},
|
|
324
|
+
|
|
286
325
|
/**
|
|
287
326
|
* The placeholder icon colour (a theme variable).
|
|
288
327
|
*
|
|
@@ -316,8 +355,12 @@ var script = {
|
|
|
316
355
|
*/
|
|
317
356
|
mediaStyle() {
|
|
318
357
|
const [w, h] = this.aspectRatio.split(':');
|
|
358
|
+
const ratio = Number(w) / Number(h);
|
|
359
|
+
// A cell wider than the ratio fits the video by its height.
|
|
360
|
+
const { width, height } = this.box;
|
|
361
|
+
const fitsByHeight = height > 0 && width / height > ratio;
|
|
319
362
|
return {
|
|
320
|
-
width: '100%',
|
|
363
|
+
width: fitsByHeight ? `${Math.floor(height * ratio)}px` : '100%',
|
|
321
364
|
'max-width': '100%',
|
|
322
365
|
'aspect-ratio': `${w} / ${h}`,
|
|
323
366
|
display: 'flex',
|
|
@@ -340,6 +383,25 @@ var script = {
|
|
|
340
383
|
},
|
|
341
384
|
},
|
|
342
385
|
|
|
386
|
+
mounted() {
|
|
387
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
388
|
+
return
|
|
389
|
+
}
|
|
390
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
391
|
+
const rect = entries[0] && entries[0].contentRect;
|
|
392
|
+
if (rect) {
|
|
393
|
+
this.box = { width: rect.width, height: rect.height };
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
this.resizeObserver.observe(this.$el);
|
|
397
|
+
},
|
|
398
|
+
|
|
399
|
+
beforeUnmount() {
|
|
400
|
+
if (this.resizeObserver) {
|
|
401
|
+
this.resizeObserver.disconnect();
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
|
|
343
405
|
methods: {
|
|
344
406
|
/**
|
|
345
407
|
* HTML5 `<video>` error handler — swaps to the error placeholder. The
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnVideoWidget2.vue.js","sources":["../../../../src/components/CnVideoWidget/CnVideoWidget.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div\n\t\tclass=\"cn-video-widget\"\n\t\t:style=\"wrapperStyle\">\n\t\t<div v-if=\"!hasSource\" class=\"cn-video-widget__placeholder\">\n\t\t\t<VideoIcon :size=\"48\" :fillColor=\"placeholderColor\" />\n\t\t\t<span class=\"cn-video-widget__placeholder-label\">{{ t('nextcloud-vue', 'No video URL configured') }}</span>\n\t\t</div>\n\t\t<div v-else-if=\"hasError\" class=\"cn-video-widget__placeholder\">\n\t\t\t<VideoIcon :size=\"48\" :fillColor=\"placeholderColor\" />\n\t\t\t<span class=\"cn-video-widget__placeholder-label\">{{ errorMessage }}</span>\n\t\t</div>\n\t\t<div\n\t\t\tv-else\n\t\t\tclass=\"cn-video-widget__media\"\n\t\t\t:style=\"mediaStyle\">\n\t\t\t<iframe\n\t\t\t\tv-if=\"isIframeSource\"\n\t\t\t\tclass=\"cn-video-widget__iframe\"\n\t\t\t\t:src=\"embedUrl\"\n\t\t\t\tsandbox=\"allow-scripts allow-same-origin allow-presentation\"\n\t\t\t\treferrerpolicy=\"strict-origin-when-cross-origin\"\n\t\t\t\tallowfullscreen\n\t\t\t\tframeborder=\"0\" />\n\t\t\t<video\n\t\t\t\tv-else-if=\"isFileSource\"\n\t\t\t\tclass=\"cn-video-widget__video\"\n\t\t\t\t:src=\"fileStreamingUrl\"\n\t\t\t\t:poster=\"posterUrl || null\"\n\t\t\t\t:autoplay=\"effectiveAutoplay\"\n\t\t\t\t:muted=\"effectiveMuted\"\n\t\t\t\t:loop=\"loop\"\n\t\t\t\t:controls=\"controls\"\n\t\t\t\t@error=\"onVideoError\" />\n\t\t</div>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport VideoIcon from 'vue-material-design-icons/Video.vue'\n\nconst VALID_SOURCE_TYPES = ['youtube', 'vimeo', 'peertube', 'nc-file']\nconst VALID_ASPECT_RATIOS = ['16:9', '4:3', '1:1', '9:16']\nconst DEFAULT_ASPECT_RATIO = '16:9'\n\n/**\n * CnVideoWidget renders an embedded video inside a dashboard cell. It\n * dispatches on `content.sourceType` to one of three render branches:\n *\n * - `youtube` / `vimeo` / `peertube` → sandboxed `<iframe>` whose `src` is\n * the canonical embed URL stored in `content.videoUrl`.\n * - `nc-file` → HTML5 `<video>` whose `src` is `content.fileStreamingUrl`\n * (resolved upstream).\n * - anything else / missing source / render error → a centered placeholder.\n *\n * Autoplay forces muted=true because browsers block autoplay of unmuted media.\n * Aspect ratio uses the CSS `aspect-ratio` property; `16:9`, `4:3`, `1:1`, and\n * `9:16` are supported and unknown values fall back to `16:9`.\n *\n * The iframe sets `referrerpolicy=\"strict-origin-when-cross-origin\"` because\n * Nextcloud's own default security headers send `Referrer-Policy: no-referrer`\n * — without an explicit override the iframe inherits that and YouTube's\n * player rejects the request with \"Error 153: Video player configuration\n * error\" (it requires a referrer to validate the embed).\n *\n * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n */\nexport default {\n\tname: 'CnVideoWidget',\n\n\tcomponents: {\n\t\tVideoIcon,\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * Persisted content blob `{sourceType, videoUrl, fileId,\n\t\t * fileStreamingUrl, autoplay, muted, loop, controls, aspectRatio,\n\t\t * posterUrl, error}`. `videoUrl` is the canonical embed URL;\n\t\t * `error` (when set) triggers the error placeholder.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/* eslint-disable vue/no-unused-properties -- part of the widget contract: CnContainerChild and the dashboard pages bind :placement on every widget, so declaring it keeps it out of $attrs */\n\t\t/** The placement record (reserved — kept to match the renderer contract). */\n\t\tplacement: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t\t/* eslint-enable vue/no-unused-properties */\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\t// Set when the HTML5 <video> fires an error so subsequent renders\n\t\t\t// show the error placeholder rather than a broken element.\n\t\t\tvideoLoadFailed: false,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The validated source type, or `null` when unrecognised.\n\t\t *\n\t\t * @return {string|null} one of the supported source types.\n\t\t */\n\t\tsourceType() {\n\t\t\tconst raw = this.content && this.content.sourceType\n\t\t\treturn VALID_SOURCE_TYPES.includes(raw) ? raw : null\n\t\t},\n\n\t\t/**\n\t\t * The canonical embed URL string.\n\t\t *\n\t\t * @return {string} the embed URL, or `''`.\n\t\t */\n\t\tvideoUrl() {\n\t\t\tconst value = this.content && this.content.videoUrl\n\t\t\treturn typeof value === 'string' ? value : ''\n\t\t},\n\n\t\t/**\n\t\t * The resolved streaming URL for `nc-file` sources.\n\t\t *\n\t\t * @return {string} the streaming URL, or `''`.\n\t\t */\n\t\tfileStreamingUrl() {\n\t\t\tconst value = this.content && this.content.fileStreamingUrl\n\t\t\treturn typeof value === 'string' ? value : ''\n\t\t},\n\n\t\t/**\n\t\t * The Nextcloud file id for `nc-file` sources.\n\t\t *\n\t\t * @return {number|null} the file id, or `null`.\n\t\t */\n\t\tfileId() {\n\t\t\tconst value = this.content && this.content.fileId\n\t\t\treturn typeof value === 'number' && Number.isFinite(value) ? value : null\n\t\t},\n\n\t\t/**\n\t\t * Whether autoplay is requested.\n\t\t *\n\t\t * @return {boolean} the autoplay flag.\n\t\t */\n\t\tautoplay() {\n\t\t\treturn Boolean(this.content && this.content.autoplay)\n\t\t},\n\n\t\t/**\n\t\t * Whether the video is muted (defaults to true).\n\t\t *\n\t\t * @return {boolean} the muted flag.\n\t\t */\n\t\tmuted() {\n\t\t\tif (this.content && typeof this.content.muted === 'boolean') {\n\t\t\t\treturn this.content.muted\n\t\t\t}\n\t\t\treturn true\n\t\t},\n\n\t\t/**\n\t\t * Whether the video loops.\n\t\t *\n\t\t * @return {boolean} the loop flag.\n\t\t */\n\t\tloop() {\n\t\t\treturn Boolean(this.content && this.content.loop)\n\t\t},\n\n\t\t/**\n\t\t * Whether native controls are shown (defaults to true).\n\t\t *\n\t\t * @return {boolean} the controls flag.\n\t\t */\n\t\tcontrols() {\n\t\t\tif (this.content && typeof this.content.controls === 'boolean') {\n\t\t\t\treturn this.content.controls\n\t\t\t}\n\t\t\treturn true\n\t\t},\n\n\t\t/**\n\t\t * The validated aspect ratio (defaults to `16:9`).\n\t\t *\n\t\t * @return {string} one of the supported aspect ratios.\n\t\t */\n\t\taspectRatio() {\n\t\t\tconst raw = this.content && this.content.aspectRatio\n\t\t\tif (typeof raw === 'string' && VALID_ASPECT_RATIOS.includes(raw)) {\n\t\t\t\treturn raw\n\t\t\t}\n\t\t\treturn DEFAULT_ASPECT_RATIO\n\t\t},\n\n\t\t/**\n\t\t * The poster image URL for HTML5 video.\n\t\t *\n\t\t * @return {string} the poster URL, or `''`.\n\t\t */\n\t\tposterUrl() {\n\t\t\tconst value = this.content && this.content.posterUrl\n\t\t\treturn typeof value === 'string' && value.trim() !== '' ? value : ''\n\t\t},\n\n\t\t/**\n\t\t * Effective muted value — autoplay forces muted=true (browsers block\n\t\t * autoplay of unmuted media).\n\t\t *\n\t\t * @return {boolean} the muted value passed to the media element.\n\t\t */\n\t\teffectiveMuted() {\n\t\t\treturn this.autoplay ? true : this.muted\n\t\t},\n\n\t\t/**\n\t\t * Effective autoplay value — never autoplay when no source resolved.\n\t\t *\n\t\t * @return {boolean} the autoplay value passed to the media element.\n\t\t */\n\t\teffectiveAutoplay() {\n\t\t\treturn this.autoplay && this.hasSource\n\t\t},\n\n\t\t/**\n\t\t * Whether a usable source is configured.\n\t\t *\n\t\t * @return {boolean} true when the widget has something to render.\n\t\t */\n\t\thasSource() {\n\t\t\tif (this.sourceType === null) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif (this.sourceType === 'nc-file') {\n\t\t\t\treturn this.fileId !== null\n\t\t\t}\n\t\t\treturn this.videoUrl.trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * Whether the current source renders in an iframe.\n\t\t *\n\t\t * @return {boolean} true for youtube/vimeo/peertube.\n\t\t */\n\t\tisIframeSource() {\n\t\t\treturn ['youtube', 'vimeo', 'peertube'].includes(this.sourceType)\n\t\t},\n\n\t\t/**\n\t\t * Whether the current source renders in an HTML5 video element.\n\t\t *\n\t\t * @return {boolean} true for nc-file.\n\t\t */\n\t\tisFileSource() {\n\t\t\treturn this.sourceType === 'nc-file'\n\t\t},\n\n\t\t/**\n\t\t * Whether the widget is in an error state.\n\t\t *\n\t\t * @return {boolean} true when an error placeholder should show.\n\t\t */\n\t\thasError() {\n\t\t\tif (this.content && typeof this.content.error === 'string' && this.content.error.trim() !== '') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (this.isFileSource && this.fileId !== null && this.fileStreamingUrl === '') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn this.videoLoadFailed\n\t\t},\n\n\t\t/**\n\t\t * The localised error message for the error placeholder.\n\t\t *\n\t\t * @return {string} the error message.\n\t\t */\n\t\terrorMessage() {\n\t\t\tconst raw = this.content && this.content.error\n\t\t\tif (typeof raw === 'string' && raw.trim() !== '') {\n\t\t\t\treturn raw\n\t\t\t}\n\t\t\tif (this.isFileSource && this.fileId !== null && this.fileStreamingUrl === '') {\n\t\t\t\treturn t('nextcloud-vue', 'Video not accessible')\n\t\t\t}\n\t\t\tif (this.videoLoadFailed) {\n\t\t\t\treturn t('nextcloud-vue', 'Video failed to load')\n\t\t\t}\n\t\t\treturn t('nextcloud-vue', 'Invalid video URL or domain not allowed.')\n\t\t},\n\n\t\t/**\n\t\t * The iframe `src` with playback query params appended.\n\t\t *\n\t\t * @return {string} the iframe URL, or `''`.\n\t\t */\n\t\tembedUrl() {\n\t\t\tif (!this.isIframeSource || this.videoUrl === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst params = []\n\t\t\tif (this.autoplay) {\n\t\t\t\tparams.push('autoplay=1')\n\t\t\t\tparams.push('mute=1')\n\t\t\t} else if (this.muted) {\n\t\t\t\tparams.push('mute=1')\n\t\t\t}\n\t\t\tif (this.loop) {\n\t\t\t\tparams.push('loop=1')\n\t\t\t}\n\t\t\tif (params.length === 0) {\n\t\t\t\treturn this.videoUrl\n\t\t\t}\n\t\t\tconst separator = this.videoUrl.includes('?') ? '&' : '?'\n\t\t\treturn this.videoUrl + separator + params.join('&')\n\t\t},\n\n\t\t/**\n\t\t * The placeholder icon colour (a theme variable).\n\t\t *\n\t\t * @return {string} the CSS colour.\n\t\t */\n\t\tplaceholderColor() {\n\t\t\treturn 'var(--color-text-maxcontrast)'\n\t\t},\n\n\t\t/**\n\t\t * Inline style for the widget wrapper.\n\t\t *\n\t\t * @return {object} the wrapper style.\n\t\t */\n\t\twrapperStyle() {\n\t\t\treturn {\n\t\t\t\twidth: '100%',\n\t\t\t\theight: '100%',\n\t\t\t\toverflow: 'hidden',\n\t\t\t\tposition: 'relative',\n\t\t\t\tdisplay: 'flex',\n\t\t\t\t'align-items': 'center',\n\t\t\t\t'justify-content': 'center',\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Inline style for the media wrapper, enforcing the aspect ratio.\n\t\t *\n\t\t * @return {object} the media style.\n\t\t */\n\t\tmediaStyle() {\n\t\t\tconst [w, h] = this.aspectRatio.split(':')\n\t\t\treturn {\n\t\t\t\twidth: '100%',\n\t\t\t\t'max-width': '100%',\n\t\t\t\t'aspect-ratio': `${w} / ${h}`,\n\t\t\t\tdisplay: 'flex',\n\t\t\t\t'align-items': 'center',\n\t\t\t\t'justify-content': 'center',\n\t\t\t\tbackground: 'var(--color-background-dark)',\n\t\t\t}\n\t\t},\n\t},\n\n\twatch: {\n\t\t// Re-arm the failure flag when the source changes so a previously\n\t\t// failed file does not permanently lock the cell.\n\t\tfileStreamingUrl() {\n\t\t\tthis.videoLoadFailed = false\n\t\t},\n\n\t\tvideoUrl() {\n\t\t\tthis.videoLoadFailed = false\n\t\t},\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * HTML5 `<video>` error handler — swaps to the error placeholder. The\n\t\t * event is swallowed so no exception bubbles into the grid layer.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\tonVideoError() {\n\t\t\tthis.videoLoadFailed = true\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-video-widget {\n\twidth: 100%;\n\theight: 100%;\n\toverflow: hidden;\n}\n\n.cn-video-widget__media {\n\tposition: relative;\n}\n\n.cn-video-widget__iframe,\n.cn-video-widget__video {\n\twidth: 100%;\n\theight: 100%;\n\tborder: 0;\n\tdisplay: block;\n\tbackground: var(--color-background-dark);\n}\n\n.cn-video-widget__placeholder {\n\twidth: 100%;\n\theight: 100%;\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: center;\n\tjustify-content: center;\n\tgap: 8px;\n\tcolor: var(--color-text-maxcontrast);\n\tpadding: 16px;\n\ttext-align: center;\n}\n\n.cn-video-widget__placeholder-label {\n\tfont-size: 13px;\n}\n</style>\n"],"names":["VideoIcon","t"],"mappings":";;;AA+CA,MAAM,kBAAiB,GAAI,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS;AACrE,MAAM,mBAAkB,GAAI,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM;AACzD,MAAM,oBAAmB,GAAI;;AAE7B;;;AAGC;;;AAGA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;;AAIA;AACA;;AAED,aAAe;AACd,CAAA,IAAI,EAAE,eAAe;;CAErB,UAAU,EAAE;AACX,aAAAA,KAAS;EACT;;AAED,CAAA,KAAK,EAAE;AACN;;;;AAIC;AACA;;;AAGD,EAAA,OAAO,EAAE;GACR,IAAI,EAAE,MAAM;AACZ,GAAA,OAAO,EAAE,OAAO,EAAE,CAAC;GACnB;;AAED;AACA;EAC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EC;;;EAGD,UAAU,GAAG;AACZ,GAAA,MAAM,CAAC,CAAC,EAAE,CAAC,CAAA,GAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG;AACzC,GAAA,OAAO;IACN,KAAK,EAAE,MAAM;AACb,IAAA,WAAW,EAAE,MAAM;IACnB,cAAc,EAAE,CAAC,EAAE,CAAC,CAAA,GAAI,EAAE,CAAC,CAAC,CAAC;AAC7B,IAAA,OAAO,EAAE,MAAM;IACf,aAAa,EAAE,QAAQ;IACvB,iBAAiB,EAAE,QAAQ;AAC3B,IAAA,UAAU,EAAE,8BAA8B;AAC3C;EACD,CAAC;EACD;;AAED,CAAA,KAAK,EAAE;;AAEN;AACA,EAAA,gBAAgB,GAAG;GAClB,IAAI,CAAC,kBAAkB;EACxB,CAAC;;EAED,QAAQ,GAAG;GACV,IAAI,CAAC,kBAAkB;EACxB,CAAC;EACD;;AAED,CAAA,OAAO,EAAE;AACR;;;AAGC;;;AAGD,EAAA,YAAY,GAAG;GACd,IAAI,CAAC,eAAc,GAAI;EACxB,CAAC;EACD;AACF;;"}
|
|
1
|
+
{"version":3,"file":"CnVideoWidget2.vue.js","sources":["../../../../src/components/CnVideoWidget/CnVideoWidget.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div\n\t\tclass=\"cn-video-widget\"\n\t\t:style=\"wrapperStyle\">\n\t\t<div v-if=\"!hasSource\" class=\"cn-video-widget__placeholder\">\n\t\t\t<VideoIcon :size=\"48\" :fillColor=\"placeholderColor\" />\n\t\t\t<span class=\"cn-video-widget__placeholder-label\">{{ t('nextcloud-vue', 'No video URL configured') }}</span>\n\t\t\t<span class=\"cn-video-widget__placeholder-help\">{{ t('nextcloud-vue', 'Edit the widget to add a video') }}</span>\n\t\t\t<button\n\t\t\t\tv-if=\"canEdit\"\n\t\t\t\ttype=\"button\"\n\t\t\t\tclass=\"cn-video-widget__configure\"\n\t\t\t\t@click=\"$emit('edit')\">\n\t\t\t\t{{ t('nextcloud-vue', 'Configure now') }}\n\t\t\t</button>\n\t\t</div>\n\t\t<div v-else-if=\"hasError\" class=\"cn-video-widget__placeholder\">\n\t\t\t<VideoIcon :size=\"48\" :fillColor=\"placeholderColor\" />\n\t\t\t<span class=\"cn-video-widget__placeholder-label\">{{ errorMessage }}</span>\n\t\t</div>\n\t\t<div\n\t\t\tv-else\n\t\t\tclass=\"cn-video-widget__media\"\n\t\t\t:style=\"mediaStyle\">\n\t\t\t<iframe\n\t\t\t\tv-if=\"isIframeSource\"\n\t\t\t\tclass=\"cn-video-widget__iframe\"\n\t\t\t\t:src=\"embedUrl\"\n\t\t\t\tsandbox=\"allow-scripts allow-same-origin allow-presentation\"\n\t\t\t\treferrerpolicy=\"strict-origin-when-cross-origin\"\n\t\t\t\tallowfullscreen\n\t\t\t\tframeborder=\"0\" />\n\t\t\t<video\n\t\t\t\tv-else-if=\"isFileSource\"\n\t\t\t\tclass=\"cn-video-widget__video\"\n\t\t\t\t:src=\"fileStreamingUrl\"\n\t\t\t\t:poster=\"posterUrl || null\"\n\t\t\t\t:autoplay=\"effectiveAutoplay\"\n\t\t\t\t:muted=\"effectiveMuted\"\n\t\t\t\t:loop=\"loop\"\n\t\t\t\t:controls=\"controls\"\n\t\t\t\t@error=\"onVideoError\" />\n\t\t</div>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport VideoIcon from 'vue-material-design-icons/Video.vue'\n\nconst VALID_SOURCE_TYPES = ['youtube', 'vimeo', 'peertube', 'nc-file']\nconst VALID_ASPECT_RATIOS = ['16:9', '4:3', '1:1', '9:16']\nconst DEFAULT_ASPECT_RATIO = '16:9'\n\n/**\n * CnVideoWidget renders an embedded video inside a dashboard cell. It\n * dispatches on `content.sourceType` to one of three render branches:\n *\n * - `youtube` / `vimeo` / `peertube` → sandboxed `<iframe>` whose `src` is\n * the canonical embed URL stored in `content.videoUrl`.\n * - `nc-file` → HTML5 `<video>` whose `src` is `content.fileStreamingUrl`\n * (resolved upstream).\n * - anything else / missing source / render error → a centered placeholder.\n *\n * Autoplay forces muted=true because browsers block autoplay of unmuted media.\n * Aspect ratio uses the CSS `aspect-ratio` property; `16:9`, `4:3`, `1:1`, and\n * `9:16` are supported and unknown values fall back to `16:9`.\n *\n * The iframe sets `referrerpolicy=\"strict-origin-when-cross-origin\"` because\n * Nextcloud's own default security headers send `Referrer-Policy: no-referrer`\n * — without an explicit override the iframe inherits that and YouTube's\n * player rejects the request with \"Error 153: Video player configuration\n * error\" (it requires a referrer to validate the embed).\n *\n * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n */\nexport default {\n\tname: 'CnVideoWidget',\n\n\tcomponents: {\n\t\tVideoIcon,\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * Persisted content blob `{sourceType, videoUrl, fileId,\n\t\t * fileStreamingUrl, autoplay, muted, loop, controls, aspectRatio,\n\t\t * posterUrl, error}`. `videoUrl` is the canonical embed URL;\n\t\t * `error` (when set) triggers the error placeholder.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/**\n\t\t * Whether the viewer may edit this placement (the host's edit mode).\n\t\t * The empty state then offers \"Configure now\", which emits `edit`.\n\t\t *\n\t\t * @type {boolean}\n\t\t */\n\t\tcanEdit: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/* eslint-disable vue/no-unused-properties -- part of the widget contract: CnContainerChild and the dashboard pages bind :placement on every widget, so declaring it keeps it out of $attrs */\n\t\t/** The placement record (reserved — kept to match the renderer contract). */\n\t\tplacement: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t\t/* eslint-enable vue/no-unused-properties */\n\t},\n\n\temits: [\n\t\t/**\n\t\t * \"Configure now\" was chosen in the empty state, so the host can open\n\t\t * the widget settings.\n\t\t *\n\t\t * @event edit\n\t\t */\n\t\t'edit',\n\t],\n\n\tdata() {\n\t\treturn {\n\t\t\t// Set when the HTML5 <video> fires an error so subsequent renders\n\t\t\t// show the error placeholder rather than a broken element.\n\t\t\tvideoLoadFailed: false,\n\t\t\t// The widget's own size, so a portrait ratio in a landscape cell\n\t\t\t// is fitted by its height instead of overflowing it.\n\t\t\tbox: { width: 0, height: 0 },\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The validated source type, or `null` when unrecognised.\n\t\t *\n\t\t * @return {string|null} one of the supported source types.\n\t\t */\n\t\tsourceType() {\n\t\t\tconst raw = this.content && this.content.sourceType\n\t\t\treturn VALID_SOURCE_TYPES.includes(raw) ? raw : null\n\t\t},\n\n\t\t/**\n\t\t * The canonical embed URL string.\n\t\t *\n\t\t * @return {string} the embed URL, or `''`.\n\t\t */\n\t\tvideoUrl() {\n\t\t\tconst value = this.content && this.content.videoUrl\n\t\t\treturn typeof value === 'string' ? value : ''\n\t\t},\n\n\t\t/**\n\t\t * The resolved streaming URL for `nc-file` sources.\n\t\t *\n\t\t * @return {string} the streaming URL, or `''`.\n\t\t */\n\t\tfileStreamingUrl() {\n\t\t\tconst value = this.content && this.content.fileStreamingUrl\n\t\t\treturn typeof value === 'string' ? value : ''\n\t\t},\n\n\t\t/**\n\t\t * The Nextcloud file id for `nc-file` sources.\n\t\t *\n\t\t * @return {number|null} the file id, or `null`.\n\t\t */\n\t\tfileId() {\n\t\t\tconst value = this.content && this.content.fileId\n\t\t\treturn typeof value === 'number' && Number.isFinite(value) ? value : null\n\t\t},\n\n\t\t/**\n\t\t * Whether autoplay is requested.\n\t\t *\n\t\t * @return {boolean} the autoplay flag.\n\t\t */\n\t\tautoplay() {\n\t\t\treturn Boolean(this.content && this.content.autoplay)\n\t\t},\n\n\t\t/**\n\t\t * Whether the video is muted (defaults to true).\n\t\t *\n\t\t * @return {boolean} the muted flag.\n\t\t */\n\t\tmuted() {\n\t\t\tif (this.content && typeof this.content.muted === 'boolean') {\n\t\t\t\treturn this.content.muted\n\t\t\t}\n\t\t\treturn true\n\t\t},\n\n\t\t/**\n\t\t * Whether the video loops.\n\t\t *\n\t\t * @return {boolean} the loop flag.\n\t\t */\n\t\tloop() {\n\t\t\treturn Boolean(this.content && this.content.loop)\n\t\t},\n\n\t\t/**\n\t\t * Whether native controls are shown (defaults to true).\n\t\t *\n\t\t * @return {boolean} the controls flag.\n\t\t */\n\t\tcontrols() {\n\t\t\tif (this.content && typeof this.content.controls === 'boolean') {\n\t\t\t\treturn this.content.controls\n\t\t\t}\n\t\t\treturn true\n\t\t},\n\n\t\t/**\n\t\t * The validated aspect ratio (defaults to `16:9`).\n\t\t *\n\t\t * @return {string} one of the supported aspect ratios.\n\t\t */\n\t\taspectRatio() {\n\t\t\tconst raw = this.content && this.content.aspectRatio\n\t\t\tif (typeof raw === 'string' && VALID_ASPECT_RATIOS.includes(raw)) {\n\t\t\t\treturn raw\n\t\t\t}\n\t\t\treturn DEFAULT_ASPECT_RATIO\n\t\t},\n\n\t\t/**\n\t\t * The poster image URL for HTML5 video.\n\t\t *\n\t\t * @return {string} the poster URL, or `''`.\n\t\t */\n\t\tposterUrl() {\n\t\t\tconst value = this.content && this.content.posterUrl\n\t\t\treturn typeof value === 'string' && value.trim() !== '' ? value : ''\n\t\t},\n\n\t\t/**\n\t\t * Effective muted value — autoplay forces muted=true (browsers block\n\t\t * autoplay of unmuted media).\n\t\t *\n\t\t * @return {boolean} the muted value passed to the media element.\n\t\t */\n\t\teffectiveMuted() {\n\t\t\treturn this.autoplay ? true : this.muted\n\t\t},\n\n\t\t/**\n\t\t * Effective autoplay value — never autoplay when no source resolved.\n\t\t *\n\t\t * @return {boolean} the autoplay value passed to the media element.\n\t\t */\n\t\teffectiveAutoplay() {\n\t\t\treturn this.autoplay && this.hasSource\n\t\t},\n\n\t\t/**\n\t\t * Whether a usable source is configured.\n\t\t *\n\t\t * @return {boolean} true when the widget has something to render.\n\t\t */\n\t\thasSource() {\n\t\t\tif (this.sourceType === null) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif (this.sourceType === 'nc-file') {\n\t\t\t\treturn this.fileId !== null\n\t\t\t}\n\t\t\treturn this.videoUrl.trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * Whether the current source renders in an iframe.\n\t\t *\n\t\t * @return {boolean} true for youtube/vimeo/peertube.\n\t\t */\n\t\tisIframeSource() {\n\t\t\treturn ['youtube', 'vimeo', 'peertube'].includes(this.sourceType)\n\t\t},\n\n\t\t/**\n\t\t * Whether the current source renders in an HTML5 video element.\n\t\t *\n\t\t * @return {boolean} true for nc-file.\n\t\t */\n\t\tisFileSource() {\n\t\t\treturn this.sourceType === 'nc-file'\n\t\t},\n\n\t\t/**\n\t\t * Whether the widget is in an error state.\n\t\t *\n\t\t * @return {boolean} true when an error placeholder should show.\n\t\t */\n\t\thasError() {\n\t\t\tif (this.content && typeof this.content.error === 'string' && this.content.error.trim() !== '') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (this.isFileSource && this.fileId !== null && this.fileStreamingUrl === '') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn this.videoLoadFailed\n\t\t},\n\n\t\t/**\n\t\t * The localised error message for the error placeholder.\n\t\t *\n\t\t * @return {string} the error message.\n\t\t */\n\t\terrorMessage() {\n\t\t\tconst raw = this.content && this.content.error\n\t\t\tif (typeof raw === 'string' && raw.trim() !== '') {\n\t\t\t\treturn raw\n\t\t\t}\n\t\t\tif (this.isFileSource && this.fileId !== null && this.fileStreamingUrl === '') {\n\t\t\t\treturn t('nextcloud-vue', 'Video not accessible')\n\t\t\t}\n\t\t\tif (this.videoLoadFailed) {\n\t\t\t\treturn t('nextcloud-vue', 'Video failed to load')\n\t\t\t}\n\t\t\treturn t('nextcloud-vue', 'Invalid video URL or domain not allowed.')\n\t\t},\n\n\t\t/**\n\t\t * The iframe `src` with playback query params appended.\n\t\t *\n\t\t * @return {string} the iframe URL, or `''`.\n\t\t */\n\t\tembedUrl() {\n\t\t\tif (!this.isIframeSource || this.videoUrl === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst params = []\n\t\t\tif (this.autoplay) {\n\t\t\t\tparams.push('autoplay=1')\n\t\t\t\tparams.push('mute=1')\n\t\t\t} else if (this.muted) {\n\t\t\t\tparams.push('mute=1')\n\t\t\t}\n\t\t\tif (this.loop) {\n\t\t\t\tparams.push('loop=1')\n\t\t\t\t// YouTube loops a single video only as a one-item playlist.\n\t\t\t\tconst id = this.sourceType === 'youtube' ? this.youtubeVideoId : ''\n\t\t\t\tif (id) {\n\t\t\t\t\tparams.push(`playlist=${encodeURIComponent(id)}`)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (params.length === 0) {\n\t\t\t\treturn this.videoUrl\n\t\t\t}\n\t\t\tconst separator = this.videoUrl.includes('?') ? '&' : '?'\n\t\t\treturn this.videoUrl + separator + params.join('&')\n\t\t},\n\n\t\t/**\n\t\t * The video id in a canonical YouTube embed URL (`/embed/<id>`).\n\t\t *\n\t\t * @return {string} the id, or `''`.\n\t\t */\n\t\tyoutubeVideoId() {\n\t\t\tconst match = this.videoUrl.match(/\\/embed\\/([^/?#&]+)/)\n\t\t\treturn match ? decodeURIComponent(match[1]) : ''\n\t\t},\n\n\t\t/**\n\t\t * The placeholder icon colour (a theme variable).\n\t\t *\n\t\t * @return {string} the CSS colour.\n\t\t */\n\t\tplaceholderColor() {\n\t\t\treturn 'var(--color-text-maxcontrast)'\n\t\t},\n\n\t\t/**\n\t\t * Inline style for the widget wrapper.\n\t\t *\n\t\t * @return {object} the wrapper style.\n\t\t */\n\t\twrapperStyle() {\n\t\t\treturn {\n\t\t\t\twidth: '100%',\n\t\t\t\theight: '100%',\n\t\t\t\toverflow: 'hidden',\n\t\t\t\tposition: 'relative',\n\t\t\t\tdisplay: 'flex',\n\t\t\t\t'align-items': 'center',\n\t\t\t\t'justify-content': 'center',\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Inline style for the media wrapper, enforcing the aspect ratio.\n\t\t *\n\t\t * @return {object} the media style.\n\t\t */\n\t\tmediaStyle() {\n\t\t\tconst [w, h] = this.aspectRatio.split(':')\n\t\t\tconst ratio = Number(w) / Number(h)\n\t\t\t// A cell wider than the ratio fits the video by its height.\n\t\t\tconst { width, height } = this.box\n\t\t\tconst fitsByHeight = height > 0 && width / height > ratio\n\t\t\treturn {\n\t\t\t\twidth: fitsByHeight ? `${Math.floor(height * ratio)}px` : '100%',\n\t\t\t\t'max-width': '100%',\n\t\t\t\t'aspect-ratio': `${w} / ${h}`,\n\t\t\t\tdisplay: 'flex',\n\t\t\t\t'align-items': 'center',\n\t\t\t\t'justify-content': 'center',\n\t\t\t\tbackground: 'var(--color-background-dark)',\n\t\t\t}\n\t\t},\n\t},\n\n\twatch: {\n\t\t// Re-arm the failure flag when the source changes so a previously\n\t\t// failed file does not permanently lock the cell.\n\t\tfileStreamingUrl() {\n\t\t\tthis.videoLoadFailed = false\n\t\t},\n\n\t\tvideoUrl() {\n\t\t\tthis.videoLoadFailed = false\n\t\t},\n\t},\n\n\tmounted() {\n\t\tif (typeof ResizeObserver === 'undefined') {\n\t\t\treturn\n\t\t}\n\t\tthis.resizeObserver = new ResizeObserver((entries) => {\n\t\t\tconst rect = entries[0] && entries[0].contentRect\n\t\t\tif (rect) {\n\t\t\t\tthis.box = { width: rect.width, height: rect.height }\n\t\t\t}\n\t\t})\n\t\tthis.resizeObserver.observe(this.$el)\n\t},\n\n\tbeforeUnmount() {\n\t\tif (this.resizeObserver) {\n\t\t\tthis.resizeObserver.disconnect()\n\t\t}\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * HTML5 `<video>` error handler — swaps to the error placeholder. The\n\t\t * event is swallowed so no exception bubbles into the grid layer.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\tonVideoError() {\n\t\t\tthis.videoLoadFailed = true\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-video-widget {\n\twidth: 100%;\n\theight: 100%;\n\toverflow: hidden;\n}\n\n.cn-video-widget__media {\n\tposition: relative;\n}\n\n.cn-video-widget__iframe,\n.cn-video-widget__video {\n\twidth: 100%;\n\theight: 100%;\n\tborder: 0;\n\tdisplay: block;\n\tbackground: var(--color-background-dark);\n}\n\n.cn-video-widget__placeholder {\n\twidth: 100%;\n\theight: 100%;\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: center;\n\tjustify-content: center;\n\tgap: 8px;\n\tcolor: var(--color-text-maxcontrast);\n\tpadding: 16px;\n\ttext-align: center;\n}\n\n.cn-video-widget__placeholder-label {\n\tfont-size: 13px;\n}\n\n.cn-video-widget__placeholder-help {\n\tfont-size: 12px;\n}\n\n.cn-video-widget__configure {\n\tpadding: 4px 12px;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n\tbackground: transparent;\n\tcolor: var(--color-main-text);\n\tcursor: pointer;\n}\n</style>\n"],"names":["VideoIcon","t"],"mappings":";;;AAuDA,MAAM,kBAAiB,GAAI,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS;AACrE,MAAM,mBAAkB,GAAI,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM;AACzD,MAAM,oBAAmB,GAAI;;AAE7B;;;AAGC;;;AAGA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;;AAIA;AACA;;AAED,aAAe;AACd,CAAA,IAAI,EAAE,eAAe;;CAErB,UAAU,EAAE;AACX,aAAAA,KAAS;EACT;;AAED,CAAA,KAAK,EAAE;AACN;;;;AAIC;AACA;;;AAGD,EAAA,OAAO,EAAE;GACR,IAAI,EAAE,MAAM;AACZ,GAAA,OAAO,EAAE,OAAO,EAAE,CAAC;GACnB;;AAED;;;AAGC;AACA;;AAED,EAAA,OAAO,EAAE;GACR,IAAI,EAAE,OAAO;GACb,OAAO,EAAE,KAAK;GACd;;AAED;AACA;EACA,SAAS,EAAE;GACV,IAAI,EAAE,MAAM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K,EAAE;;AAEN;AACA,EAAA,gBAAgB,GAAG;GAClB,IAAI,CAAC,kBAAkB;EACxB,CAAC;;EAED,QAAQ,GAAG;GACV,IAAI,CAAC,kBAAkB;EACxB,CAAC;EACD;;AAED,CAAA,OAAO,GAAG;AACT,EAAA,IAAI,OAAO,cAAa,KAAM,WAAW,EAAE;GAC1C;AACD,EAAA;EACA,IAAI,CAAC,cAAa,GAAI,IAAI,cAAc,CAAC,CAAC,OAAO,KAAK;AACrD,GAAA,MAAM,IAAG,GAAI,OAAO,CAAC,CAAC,CAAA,IAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AACtC,GAAA,IAAI,IAAI,EAAE;AACT,IAAA,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAK;AACnD,GAAA;EACD,CAAC;AACD,EAAA,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG;CACrC,CAAC;;AAED,CAAA,aAAa,GAAG;EACf,IAAI,IAAI,CAAC,cAAc,EAAE;AACxB,GAAA,IAAI,CAAC,cAAc,CAAC,UAAU;AAC/B,EAAA;CACD,CAAC;;AAED,CAAA,OAAO,EAAE;AACR;;;AAGC;;;AAGD,EAAA,YAAY,GAAG;GACd,IAAI,CAAC,eAAc,GAAI;EACxB,CAAC;EACD;AACF;;"}
|
|
@@ -5,13 +5,14 @@ const _hoisted_1 = {
|
|
|
5
5
|
class: "cn-video-widget__placeholder"
|
|
6
6
|
};
|
|
7
7
|
const _hoisted_2 = { class: "cn-video-widget__placeholder-label" };
|
|
8
|
-
const _hoisted_3 = {
|
|
8
|
+
const _hoisted_3 = { class: "cn-video-widget__placeholder-help" };
|
|
9
|
+
const _hoisted_4 = {
|
|
9
10
|
key: 1,
|
|
10
11
|
class: "cn-video-widget__placeholder"
|
|
11
12
|
};
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
13
|
+
const _hoisted_5 = { class: "cn-video-widget__placeholder-label" };
|
|
14
|
+
const _hoisted_6 = ["src"];
|
|
15
|
+
const _hoisted_7 = ["src", "poster", "autoplay", "muted", "loop", "controls"];
|
|
15
16
|
|
|
16
17
|
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
17
18
|
const _component_VideoIcon = resolveComponent("VideoIcon");
|
|
@@ -26,15 +27,24 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
26
27
|
size: 48,
|
|
27
28
|
fillColor: $options.placeholderColor
|
|
28
29
|
}, null, 8 /* PROPS */, ["fillColor"]),
|
|
29
|
-
createElementVNode("span", _hoisted_2, toDisplayString(_ctx.t('nextcloud-vue', 'No video URL configured')), 1 /* TEXT */)
|
|
30
|
+
createElementVNode("span", _hoisted_2, toDisplayString(_ctx.t('nextcloud-vue', 'No video URL configured')), 1 /* TEXT */),
|
|
31
|
+
createElementVNode("span", _hoisted_3, toDisplayString(_ctx.t('nextcloud-vue', 'Edit the widget to add a video')), 1 /* TEXT */),
|
|
32
|
+
($props.canEdit)
|
|
33
|
+
? (openBlock(), createElementBlock("button", {
|
|
34
|
+
key: 0,
|
|
35
|
+
type: "button",
|
|
36
|
+
class: "cn-video-widget__configure",
|
|
37
|
+
onClick: _cache[0] || (_cache[0] = $event => (_ctx.$emit('edit')))
|
|
38
|
+
}, toDisplayString(_ctx.t('nextcloud-vue', 'Configure now')), 1 /* TEXT */))
|
|
39
|
+
: createCommentVNode("v-if", true)
|
|
30
40
|
]))
|
|
31
41
|
: ($options.hasError)
|
|
32
|
-
? (openBlock(), createElementBlock("div",
|
|
42
|
+
? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
33
43
|
createVNode(_component_VideoIcon, {
|
|
34
44
|
size: 48,
|
|
35
45
|
fillColor: $options.placeholderColor
|
|
36
46
|
}, null, 8 /* PROPS */, ["fillColor"]),
|
|
37
|
-
createElementVNode("span",
|
|
47
|
+
createElementVNode("span", _hoisted_5, toDisplayString($options.errorMessage), 1 /* TEXT */)
|
|
38
48
|
]))
|
|
39
49
|
: (openBlock(), createElementBlock("div", {
|
|
40
50
|
key: 2,
|
|
@@ -50,7 +60,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
50
60
|
referrerpolicy: "strict-origin-when-cross-origin",
|
|
51
61
|
allowfullscreen: "",
|
|
52
62
|
frameborder: "0"
|
|
53
|
-
}, null, 8 /* PROPS */,
|
|
63
|
+
}, null, 8 /* PROPS */, _hoisted_6))
|
|
54
64
|
: ($options.isFileSource)
|
|
55
65
|
? (openBlock(), createElementBlock("video", {
|
|
56
66
|
key: 1,
|
|
@@ -61,8 +71,8 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
61
71
|
muted: $options.effectiveMuted,
|
|
62
72
|
loop: $options.loop,
|
|
63
73
|
controls: $options.controls,
|
|
64
|
-
onError: _cache[
|
|
65
|
-
}, null, 40 /* PROPS, NEED_HYDRATION */,
|
|
74
|
+
onError: _cache[1] || (_cache[1] = (...args) => ($options.onVideoError && $options.onVideoError(...args)))
|
|
75
|
+
}, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_7))
|
|
66
76
|
: createCommentVNode("v-if", true)
|
|
67
77
|
], 4 /* STYLE */))
|
|
68
78
|
], 4 /* STYLE */))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnVideoWidget3.vue.js","sources":["../../../../src/components/CnVideoWidget/CnVideoWidget.vue?vue&type=template&id=7569b1b5&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div\n\t\tclass=\"cn-video-widget\"\n\t\t:style=\"wrapperStyle\">\n\t\t<div v-if=\"!hasSource\" class=\"cn-video-widget__placeholder\">\n\t\t\t<VideoIcon :size=\"48\" :fillColor=\"placeholderColor\" />\n\t\t\t<span class=\"cn-video-widget__placeholder-label\">{{ t('nextcloud-vue', 'No video URL configured') }}</span>\n\t\t</div>\n\t\t<div v-else-if=\"hasError\" class=\"cn-video-widget__placeholder\">\n\t\t\t<VideoIcon :size=\"48\" :fillColor=\"placeholderColor\" />\n\t\t\t<span class=\"cn-video-widget__placeholder-label\">{{ errorMessage }}</span>\n\t\t</div>\n\t\t<div\n\t\t\tv-else\n\t\t\tclass=\"cn-video-widget__media\"\n\t\t\t:style=\"mediaStyle\">\n\t\t\t<iframe\n\t\t\t\tv-if=\"isIframeSource\"\n\t\t\t\tclass=\"cn-video-widget__iframe\"\n\t\t\t\t:src=\"embedUrl\"\n\t\t\t\tsandbox=\"allow-scripts allow-same-origin allow-presentation\"\n\t\t\t\treferrerpolicy=\"strict-origin-when-cross-origin\"\n\t\t\t\tallowfullscreen\n\t\t\t\tframeborder=\"0\" />\n\t\t\t<video\n\t\t\t\tv-else-if=\"isFileSource\"\n\t\t\t\tclass=\"cn-video-widget__video\"\n\t\t\t\t:src=\"fileStreamingUrl\"\n\t\t\t\t:poster=\"posterUrl || null\"\n\t\t\t\t:autoplay=\"effectiveAutoplay\"\n\t\t\t\t:muted=\"effectiveMuted\"\n\t\t\t\t:loop=\"loop\"\n\t\t\t\t:controls=\"controls\"\n\t\t\t\t@error=\"onVideoError\" />\n\t\t</div>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport VideoIcon from 'vue-material-design-icons/Video.vue'\n\nconst VALID_SOURCE_TYPES = ['youtube', 'vimeo', 'peertube', 'nc-file']\nconst VALID_ASPECT_RATIOS = ['16:9', '4:3', '1:1', '9:16']\nconst DEFAULT_ASPECT_RATIO = '16:9'\n\n/**\n * CnVideoWidget renders an embedded video inside a dashboard cell. It\n * dispatches on `content.sourceType` to one of three render branches:\n *\n * - `youtube` / `vimeo` / `peertube` → sandboxed `<iframe>` whose `src` is\n * the canonical embed URL stored in `content.videoUrl`.\n * - `nc-file` → HTML5 `<video>` whose `src` is `content.fileStreamingUrl`\n * (resolved upstream).\n * - anything else / missing source / render error → a centered placeholder.\n *\n * Autoplay forces muted=true because browsers block autoplay of unmuted media.\n * Aspect ratio uses the CSS `aspect-ratio` property; `16:9`, `4:3`, `1:1`, and\n * `9:16` are supported and unknown values fall back to `16:9`.\n *\n * The iframe sets `referrerpolicy=\"strict-origin-when-cross-origin\"` because\n * Nextcloud's own default security headers send `Referrer-Policy: no-referrer`\n * — without an explicit override the iframe inherits that and YouTube's\n * player rejects the request with \"Error 153: Video player configuration\n * error\" (it requires a referrer to validate the embed).\n *\n * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n */\nexport default {\n\tname: 'CnVideoWidget',\n\n\tcomponents: {\n\t\tVideoIcon,\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * Persisted content blob `{sourceType, videoUrl, fileId,\n\t\t * fileStreamingUrl, autoplay, muted, loop, controls, aspectRatio,\n\t\t * posterUrl, error}`. `videoUrl` is the canonical embed URL;\n\t\t * `error` (when set) triggers the error placeholder.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/* eslint-disable vue/no-unused-properties -- part of the widget contract: CnContainerChild and the dashboard pages bind :placement on every widget, so declaring it keeps it out of $attrs */\n\t\t/** The placement record (reserved — kept to match the renderer contract). */\n\t\tplacement: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t\t/* eslint-enable vue/no-unused-properties */\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\t// Set when the HTML5 <video> fires an error so subsequent renders\n\t\t\t// show the error placeholder rather than a broken element.\n\t\t\tvideoLoadFailed: false,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The validated source type, or `null` when unrecognised.\n\t\t *\n\t\t * @return {string|null} one of the supported source types.\n\t\t */\n\t\tsourceType() {\n\t\t\tconst raw = this.content && this.content.sourceType\n\t\t\treturn VALID_SOURCE_TYPES.includes(raw) ? raw : null\n\t\t},\n\n\t\t/**\n\t\t * The canonical embed URL string.\n\t\t *\n\t\t * @return {string} the embed URL, or `''`.\n\t\t */\n\t\tvideoUrl() {\n\t\t\tconst value = this.content && this.content.videoUrl\n\t\t\treturn typeof value === 'string' ? value : ''\n\t\t},\n\n\t\t/**\n\t\t * The resolved streaming URL for `nc-file` sources.\n\t\t *\n\t\t * @return {string} the streaming URL, or `''`.\n\t\t */\n\t\tfileStreamingUrl() {\n\t\t\tconst value = this.content && this.content.fileStreamingUrl\n\t\t\treturn typeof value === 'string' ? value : ''\n\t\t},\n\n\t\t/**\n\t\t * The Nextcloud file id for `nc-file` sources.\n\t\t *\n\t\t * @return {number|null} the file id, or `null`.\n\t\t */\n\t\tfileId() {\n\t\t\tconst value = this.content && this.content.fileId\n\t\t\treturn typeof value === 'number' && Number.isFinite(value) ? value : null\n\t\t},\n\n\t\t/**\n\t\t * Whether autoplay is requested.\n\t\t *\n\t\t * @return {boolean} the autoplay flag.\n\t\t */\n\t\tautoplay() {\n\t\t\treturn Boolean(this.content && this.content.autoplay)\n\t\t},\n\n\t\t/**\n\t\t * Whether the video is muted (defaults to true).\n\t\t *\n\t\t * @return {boolean} the muted flag.\n\t\t */\n\t\tmuted() {\n\t\t\tif (this.content && typeof this.content.muted === 'boolean') {\n\t\t\t\treturn this.content.muted\n\t\t\t}\n\t\t\treturn true\n\t\t},\n\n\t\t/**\n\t\t * Whether the video loops.\n\t\t *\n\t\t * @return {boolean} the loop flag.\n\t\t */\n\t\tloop() {\n\t\t\treturn Boolean(this.content && this.content.loop)\n\t\t},\n\n\t\t/**\n\t\t * Whether native controls are shown (defaults to true).\n\t\t *\n\t\t * @return {boolean} the controls flag.\n\t\t */\n\t\tcontrols() {\n\t\t\tif (this.content && typeof this.content.controls === 'boolean') {\n\t\t\t\treturn this.content.controls\n\t\t\t}\n\t\t\treturn true\n\t\t},\n\n\t\t/**\n\t\t * The validated aspect ratio (defaults to `16:9`).\n\t\t *\n\t\t * @return {string} one of the supported aspect ratios.\n\t\t */\n\t\taspectRatio() {\n\t\t\tconst raw = this.content && this.content.aspectRatio\n\t\t\tif (typeof raw === 'string' && VALID_ASPECT_RATIOS.includes(raw)) {\n\t\t\t\treturn raw\n\t\t\t}\n\t\t\treturn DEFAULT_ASPECT_RATIO\n\t\t},\n\n\t\t/**\n\t\t * The poster image URL for HTML5 video.\n\t\t *\n\t\t * @return {string} the poster URL, or `''`.\n\t\t */\n\t\tposterUrl() {\n\t\t\tconst value = this.content && this.content.posterUrl\n\t\t\treturn typeof value === 'string' && value.trim() !== '' ? value : ''\n\t\t},\n\n\t\t/**\n\t\t * Effective muted value — autoplay forces muted=true (browsers block\n\t\t * autoplay of unmuted media).\n\t\t *\n\t\t * @return {boolean} the muted value passed to the media element.\n\t\t */\n\t\teffectiveMuted() {\n\t\t\treturn this.autoplay ? true : this.muted\n\t\t},\n\n\t\t/**\n\t\t * Effective autoplay value — never autoplay when no source resolved.\n\t\t *\n\t\t * @return {boolean} the autoplay value passed to the media element.\n\t\t */\n\t\teffectiveAutoplay() {\n\t\t\treturn this.autoplay && this.hasSource\n\t\t},\n\n\t\t/**\n\t\t * Whether a usable source is configured.\n\t\t *\n\t\t * @return {boolean} true when the widget has something to render.\n\t\t */\n\t\thasSource() {\n\t\t\tif (this.sourceType === null) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif (this.sourceType === 'nc-file') {\n\t\t\t\treturn this.fileId !== null\n\t\t\t}\n\t\t\treturn this.videoUrl.trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * Whether the current source renders in an iframe.\n\t\t *\n\t\t * @return {boolean} true for youtube/vimeo/peertube.\n\t\t */\n\t\tisIframeSource() {\n\t\t\treturn ['youtube', 'vimeo', 'peertube'].includes(this.sourceType)\n\t\t},\n\n\t\t/**\n\t\t * Whether the current source renders in an HTML5 video element.\n\t\t *\n\t\t * @return {boolean} true for nc-file.\n\t\t */\n\t\tisFileSource() {\n\t\t\treturn this.sourceType === 'nc-file'\n\t\t},\n\n\t\t/**\n\t\t * Whether the widget is in an error state.\n\t\t *\n\t\t * @return {boolean} true when an error placeholder should show.\n\t\t */\n\t\thasError() {\n\t\t\tif (this.content && typeof this.content.error === 'string' && this.content.error.trim() !== '') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (this.isFileSource && this.fileId !== null && this.fileStreamingUrl === '') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn this.videoLoadFailed\n\t\t},\n\n\t\t/**\n\t\t * The localised error message for the error placeholder.\n\t\t *\n\t\t * @return {string} the error message.\n\t\t */\n\t\terrorMessage() {\n\t\t\tconst raw = this.content && this.content.error\n\t\t\tif (typeof raw === 'string' && raw.trim() !== '') {\n\t\t\t\treturn raw\n\t\t\t}\n\t\t\tif (this.isFileSource && this.fileId !== null && this.fileStreamingUrl === '') {\n\t\t\t\treturn t('nextcloud-vue', 'Video not accessible')\n\t\t\t}\n\t\t\tif (this.videoLoadFailed) {\n\t\t\t\treturn t('nextcloud-vue', 'Video failed to load')\n\t\t\t}\n\t\t\treturn t('nextcloud-vue', 'Invalid video URL or domain not allowed.')\n\t\t},\n\n\t\t/**\n\t\t * The iframe `src` with playback query params appended.\n\t\t *\n\t\t * @return {string} the iframe URL, or `''`.\n\t\t */\n\t\tembedUrl() {\n\t\t\tif (!this.isIframeSource || this.videoUrl === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst params = []\n\t\t\tif (this.autoplay) {\n\t\t\t\tparams.push('autoplay=1')\n\t\t\t\tparams.push('mute=1')\n\t\t\t} else if (this.muted) {\n\t\t\t\tparams.push('mute=1')\n\t\t\t}\n\t\t\tif (this.loop) {\n\t\t\t\tparams.push('loop=1')\n\t\t\t}\n\t\t\tif (params.length === 0) {\n\t\t\t\treturn this.videoUrl\n\t\t\t}\n\t\t\tconst separator = this.videoUrl.includes('?') ? '&' : '?'\n\t\t\treturn this.videoUrl + separator + params.join('&')\n\t\t},\n\n\t\t/**\n\t\t * The placeholder icon colour (a theme variable).\n\t\t *\n\t\t * @return {string} the CSS colour.\n\t\t */\n\t\tplaceholderColor() {\n\t\t\treturn 'var(--color-text-maxcontrast)'\n\t\t},\n\n\t\t/**\n\t\t * Inline style for the widget wrapper.\n\t\t *\n\t\t * @return {object} the wrapper style.\n\t\t */\n\t\twrapperStyle() {\n\t\t\treturn {\n\t\t\t\twidth: '100%',\n\t\t\t\theight: '100%',\n\t\t\t\toverflow: 'hidden',\n\t\t\t\tposition: 'relative',\n\t\t\t\tdisplay: 'flex',\n\t\t\t\t'align-items': 'center',\n\t\t\t\t'justify-content': 'center',\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Inline style for the media wrapper, enforcing the aspect ratio.\n\t\t *\n\t\t * @return {object} the media style.\n\t\t */\n\t\tmediaStyle() {\n\t\t\tconst [w, h] = this.aspectRatio.split(':')\n\t\t\treturn {\n\t\t\t\twidth: '100%',\n\t\t\t\t'max-width': '100%',\n\t\t\t\t'aspect-ratio': `${w} / ${h}`,\n\t\t\t\tdisplay: 'flex',\n\t\t\t\t'align-items': 'center',\n\t\t\t\t'justify-content': 'center',\n\t\t\t\tbackground: 'var(--color-background-dark)',\n\t\t\t}\n\t\t},\n\t},\n\n\twatch: {\n\t\t// Re-arm the failure flag when the source changes so a previously\n\t\t// failed file does not permanently lock the cell.\n\t\tfileStreamingUrl() {\n\t\t\tthis.videoLoadFailed = false\n\t\t},\n\n\t\tvideoUrl() {\n\t\t\tthis.videoLoadFailed = false\n\t\t},\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * HTML5 `<video>` error handler — swaps to the error placeholder. The\n\t\t * event is swallowed so no exception bubbles into the grid layer.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\tonVideoError() {\n\t\t\tthis.videoLoadFailed = true\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-video-widget {\n\twidth: 100%;\n\theight: 100%;\n\toverflow: hidden;\n}\n\n.cn-video-widget__media {\n\tposition: relative;\n}\n\n.cn-video-widget__iframe,\n.cn-video-widget__video {\n\twidth: 100%;\n\theight: 100%;\n\tborder: 0;\n\tdisplay: block;\n\tbackground: var(--color-background-dark);\n}\n\n.cn-video-widget__placeholder {\n\twidth: 100%;\n\theight: 100%;\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: center;\n\tjustify-content: center;\n\tgap: 8px;\n\tcolor: var(--color-text-maxcontrast);\n\tpadding: 16px;\n\ttext-align: center;\n}\n\n.cn-video-widget__placeholder-label {\n\tfont-size: 13px;\n}\n</style>\n"],"names":["_createVNode","_createElementVNode","_toDisplayString","_createElementBlock"],"mappings":";;;;AAcyB,EAAA,KAAK,EAAC;;AAExB,MAAA,UAAA,GAAA,EAAA,KAAA,EAAA,oCAAA;;;AAEC,EAAA,KAAA,EAAA;;AAEC,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,oCAAO;;;;;;;;AARpB,IAAA,KAAK,EAAA,iBAAA;AACJ,IAAA,KAAK,iBAAE,QAAA,CAAA,YAAY;;MACR,QAAA,CAAA,SAAS;yCAGlB,iBAAA,EAAA;UAFFA,WAAA,CAAsD,oBAAA,EAAA;AAA1C,YAAA,IAAI,EAAE,EAAE;AAAG,YAAA,SAAS,EAAE,QAAA,CAAA;;UAClCC,kBAAA,CAAI,MAAA,EAAJ,UAAI,EAAAC,eAAA,CAAA,IAAA,CAAA,CAAA,CAAA,eAAA,EAAA,yBAAA,CAAA,CAAA,EAAA,CAAA;;SAEC,QAAA,CAAA,QAAA;2CAGA,iBAAA,EAAA;YAFLF,WAAA,CAA6B,oBAAA,EAAA;AAAjB,cAAA,IAAI,EAAE,EAAE;AAAG,cAAA,SAAM,EAAA,QAAA,CAAA;;YAC7BC,kBAAA,CAAmB,MAAA,EAAnB,UAAmB,EAAAC,eAAA,CAAA,QAAA,CAAA,YAAA,CAAA,EAAA,CAAA;;wBAElBC,kBAAA;;AAEA,YAAA,KAAI,EAAC,wBAAS;AACd,YAAA,KAAK,iBAAE,QAAA,CAAA,UAAU;;aAEX,QAAA,CAAA,cAAQ;iDAMG,QAAA,EAAA;;AALjB,kBAAA,KAAK,EAAC,yBAAW;AAChB,kBAAA,GAAG,EAAA,QAAA,CAAA,QAAA;AACJ,kBAAA,OAAO,EAAC,oDAAe;AACvB,kBAAA,cAAc,EAAC,iCAAc;AAC7B,kBAAA,eAAe,EAAf,EAAe;AACf,kBAAA,WAAW,EAAC;;iBAED,QAAA,CAAA,YAAW;;;AACtB,oBAAA,KAAK,EAAC,wBAAK;AACV,oBAAA,GAAG,EAAE,QAAA,CAAA,gBAAa;AAClB,oBAAA,MAAM,EAAE,QAAA,CAAA,SAAS,IAAA,IAAA;AACjB,oBAAA,QAAE,EAAA,QAAA,CAAA,iBAAA;AACF,oBAAA,KAAC,EAAA,QAAA,CAAA,cAAA;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"CnVideoWidget3.vue.js","sources":["../../../../src/components/CnVideoWidget/CnVideoWidget.vue?vue&type=template&id=e01017fa&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div\n\t\tclass=\"cn-video-widget\"\n\t\t:style=\"wrapperStyle\">\n\t\t<div v-if=\"!hasSource\" class=\"cn-video-widget__placeholder\">\n\t\t\t<VideoIcon :size=\"48\" :fillColor=\"placeholderColor\" />\n\t\t\t<span class=\"cn-video-widget__placeholder-label\">{{ t('nextcloud-vue', 'No video URL configured') }}</span>\n\t\t\t<span class=\"cn-video-widget__placeholder-help\">{{ t('nextcloud-vue', 'Edit the widget to add a video') }}</span>\n\t\t\t<button\n\t\t\t\tv-if=\"canEdit\"\n\t\t\t\ttype=\"button\"\n\t\t\t\tclass=\"cn-video-widget__configure\"\n\t\t\t\t@click=\"$emit('edit')\">\n\t\t\t\t{{ t('nextcloud-vue', 'Configure now') }}\n\t\t\t</button>\n\t\t</div>\n\t\t<div v-else-if=\"hasError\" class=\"cn-video-widget__placeholder\">\n\t\t\t<VideoIcon :size=\"48\" :fillColor=\"placeholderColor\" />\n\t\t\t<span class=\"cn-video-widget__placeholder-label\">{{ errorMessage }}</span>\n\t\t</div>\n\t\t<div\n\t\t\tv-else\n\t\t\tclass=\"cn-video-widget__media\"\n\t\t\t:style=\"mediaStyle\">\n\t\t\t<iframe\n\t\t\t\tv-if=\"isIframeSource\"\n\t\t\t\tclass=\"cn-video-widget__iframe\"\n\t\t\t\t:src=\"embedUrl\"\n\t\t\t\tsandbox=\"allow-scripts allow-same-origin allow-presentation\"\n\t\t\t\treferrerpolicy=\"strict-origin-when-cross-origin\"\n\t\t\t\tallowfullscreen\n\t\t\t\tframeborder=\"0\" />\n\t\t\t<video\n\t\t\t\tv-else-if=\"isFileSource\"\n\t\t\t\tclass=\"cn-video-widget__video\"\n\t\t\t\t:src=\"fileStreamingUrl\"\n\t\t\t\t:poster=\"posterUrl || null\"\n\t\t\t\t:autoplay=\"effectiveAutoplay\"\n\t\t\t\t:muted=\"effectiveMuted\"\n\t\t\t\t:loop=\"loop\"\n\t\t\t\t:controls=\"controls\"\n\t\t\t\t@error=\"onVideoError\" />\n\t\t</div>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport VideoIcon from 'vue-material-design-icons/Video.vue'\n\nconst VALID_SOURCE_TYPES = ['youtube', 'vimeo', 'peertube', 'nc-file']\nconst VALID_ASPECT_RATIOS = ['16:9', '4:3', '1:1', '9:16']\nconst DEFAULT_ASPECT_RATIO = '16:9'\n\n/**\n * CnVideoWidget renders an embedded video inside a dashboard cell. It\n * dispatches on `content.sourceType` to one of three render branches:\n *\n * - `youtube` / `vimeo` / `peertube` → sandboxed `<iframe>` whose `src` is\n * the canonical embed URL stored in `content.videoUrl`.\n * - `nc-file` → HTML5 `<video>` whose `src` is `content.fileStreamingUrl`\n * (resolved upstream).\n * - anything else / missing source / render error → a centered placeholder.\n *\n * Autoplay forces muted=true because browsers block autoplay of unmuted media.\n * Aspect ratio uses the CSS `aspect-ratio` property; `16:9`, `4:3`, `1:1`, and\n * `9:16` are supported and unknown values fall back to `16:9`.\n *\n * The iframe sets `referrerpolicy=\"strict-origin-when-cross-origin\"` because\n * Nextcloud's own default security headers send `Referrer-Policy: no-referrer`\n * — without an explicit override the iframe inherits that and YouTube's\n * player rejects the request with \"Error 153: Video player configuration\n * error\" (it requires a referrer to validate the embed).\n *\n * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n */\nexport default {\n\tname: 'CnVideoWidget',\n\n\tcomponents: {\n\t\tVideoIcon,\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * Persisted content blob `{sourceType, videoUrl, fileId,\n\t\t * fileStreamingUrl, autoplay, muted, loop, controls, aspectRatio,\n\t\t * posterUrl, error}`. `videoUrl` is the canonical embed URL;\n\t\t * `error` (when set) triggers the error placeholder.\n\t\t *\n\t\t * @type {object}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/**\n\t\t * Whether the viewer may edit this placement (the host's edit mode).\n\t\t * The empty state then offers \"Configure now\", which emits `edit`.\n\t\t *\n\t\t * @type {boolean}\n\t\t */\n\t\tcanEdit: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/* eslint-disable vue/no-unused-properties -- part of the widget contract: CnContainerChild and the dashboard pages bind :placement on every widget, so declaring it keeps it out of $attrs */\n\t\t/** The placement record (reserved — kept to match the renderer contract). */\n\t\tplacement: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t\t/* eslint-enable vue/no-unused-properties */\n\t},\n\n\temits: [\n\t\t/**\n\t\t * \"Configure now\" was chosen in the empty state, so the host can open\n\t\t * the widget settings.\n\t\t *\n\t\t * @event edit\n\t\t */\n\t\t'edit',\n\t],\n\n\tdata() {\n\t\treturn {\n\t\t\t// Set when the HTML5 <video> fires an error so subsequent renders\n\t\t\t// show the error placeholder rather than a broken element.\n\t\t\tvideoLoadFailed: false,\n\t\t\t// The widget's own size, so a portrait ratio in a landscape cell\n\t\t\t// is fitted by its height instead of overflowing it.\n\t\t\tbox: { width: 0, height: 0 },\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The validated source type, or `null` when unrecognised.\n\t\t *\n\t\t * @return {string|null} one of the supported source types.\n\t\t */\n\t\tsourceType() {\n\t\t\tconst raw = this.content && this.content.sourceType\n\t\t\treturn VALID_SOURCE_TYPES.includes(raw) ? raw : null\n\t\t},\n\n\t\t/**\n\t\t * The canonical embed URL string.\n\t\t *\n\t\t * @return {string} the embed URL, or `''`.\n\t\t */\n\t\tvideoUrl() {\n\t\t\tconst value = this.content && this.content.videoUrl\n\t\t\treturn typeof value === 'string' ? value : ''\n\t\t},\n\n\t\t/**\n\t\t * The resolved streaming URL for `nc-file` sources.\n\t\t *\n\t\t * @return {string} the streaming URL, or `''`.\n\t\t */\n\t\tfileStreamingUrl() {\n\t\t\tconst value = this.content && this.content.fileStreamingUrl\n\t\t\treturn typeof value === 'string' ? value : ''\n\t\t},\n\n\t\t/**\n\t\t * The Nextcloud file id for `nc-file` sources.\n\t\t *\n\t\t * @return {number|null} the file id, or `null`.\n\t\t */\n\t\tfileId() {\n\t\t\tconst value = this.content && this.content.fileId\n\t\t\treturn typeof value === 'number' && Number.isFinite(value) ? value : null\n\t\t},\n\n\t\t/**\n\t\t * Whether autoplay is requested.\n\t\t *\n\t\t * @return {boolean} the autoplay flag.\n\t\t */\n\t\tautoplay() {\n\t\t\treturn Boolean(this.content && this.content.autoplay)\n\t\t},\n\n\t\t/**\n\t\t * Whether the video is muted (defaults to true).\n\t\t *\n\t\t * @return {boolean} the muted flag.\n\t\t */\n\t\tmuted() {\n\t\t\tif (this.content && typeof this.content.muted === 'boolean') {\n\t\t\t\treturn this.content.muted\n\t\t\t}\n\t\t\treturn true\n\t\t},\n\n\t\t/**\n\t\t * Whether the video loops.\n\t\t *\n\t\t * @return {boolean} the loop flag.\n\t\t */\n\t\tloop() {\n\t\t\treturn Boolean(this.content && this.content.loop)\n\t\t},\n\n\t\t/**\n\t\t * Whether native controls are shown (defaults to true).\n\t\t *\n\t\t * @return {boolean} the controls flag.\n\t\t */\n\t\tcontrols() {\n\t\t\tif (this.content && typeof this.content.controls === 'boolean') {\n\t\t\t\treturn this.content.controls\n\t\t\t}\n\t\t\treturn true\n\t\t},\n\n\t\t/**\n\t\t * The validated aspect ratio (defaults to `16:9`).\n\t\t *\n\t\t * @return {string} one of the supported aspect ratios.\n\t\t */\n\t\taspectRatio() {\n\t\t\tconst raw = this.content && this.content.aspectRatio\n\t\t\tif (typeof raw === 'string' && VALID_ASPECT_RATIOS.includes(raw)) {\n\t\t\t\treturn raw\n\t\t\t}\n\t\t\treturn DEFAULT_ASPECT_RATIO\n\t\t},\n\n\t\t/**\n\t\t * The poster image URL for HTML5 video.\n\t\t *\n\t\t * @return {string} the poster URL, or `''`.\n\t\t */\n\t\tposterUrl() {\n\t\t\tconst value = this.content && this.content.posterUrl\n\t\t\treturn typeof value === 'string' && value.trim() !== '' ? value : ''\n\t\t},\n\n\t\t/**\n\t\t * Effective muted value — autoplay forces muted=true (browsers block\n\t\t * autoplay of unmuted media).\n\t\t *\n\t\t * @return {boolean} the muted value passed to the media element.\n\t\t */\n\t\teffectiveMuted() {\n\t\t\treturn this.autoplay ? true : this.muted\n\t\t},\n\n\t\t/**\n\t\t * Effective autoplay value — never autoplay when no source resolved.\n\t\t *\n\t\t * @return {boolean} the autoplay value passed to the media element.\n\t\t */\n\t\teffectiveAutoplay() {\n\t\t\treturn this.autoplay && this.hasSource\n\t\t},\n\n\t\t/**\n\t\t * Whether a usable source is configured.\n\t\t *\n\t\t * @return {boolean} true when the widget has something to render.\n\t\t */\n\t\thasSource() {\n\t\t\tif (this.sourceType === null) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif (this.sourceType === 'nc-file') {\n\t\t\t\treturn this.fileId !== null\n\t\t\t}\n\t\t\treturn this.videoUrl.trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * Whether the current source renders in an iframe.\n\t\t *\n\t\t * @return {boolean} true for youtube/vimeo/peertube.\n\t\t */\n\t\tisIframeSource() {\n\t\t\treturn ['youtube', 'vimeo', 'peertube'].includes(this.sourceType)\n\t\t},\n\n\t\t/**\n\t\t * Whether the current source renders in an HTML5 video element.\n\t\t *\n\t\t * @return {boolean} true for nc-file.\n\t\t */\n\t\tisFileSource() {\n\t\t\treturn this.sourceType === 'nc-file'\n\t\t},\n\n\t\t/**\n\t\t * Whether the widget is in an error state.\n\t\t *\n\t\t * @return {boolean} true when an error placeholder should show.\n\t\t */\n\t\thasError() {\n\t\t\tif (this.content && typeof this.content.error === 'string' && this.content.error.trim() !== '') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (this.isFileSource && this.fileId !== null && this.fileStreamingUrl === '') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn this.videoLoadFailed\n\t\t},\n\n\t\t/**\n\t\t * The localised error message for the error placeholder.\n\t\t *\n\t\t * @return {string} the error message.\n\t\t */\n\t\terrorMessage() {\n\t\t\tconst raw = this.content && this.content.error\n\t\t\tif (typeof raw === 'string' && raw.trim() !== '') {\n\t\t\t\treturn raw\n\t\t\t}\n\t\t\tif (this.isFileSource && this.fileId !== null && this.fileStreamingUrl === '') {\n\t\t\t\treturn t('nextcloud-vue', 'Video not accessible')\n\t\t\t}\n\t\t\tif (this.videoLoadFailed) {\n\t\t\t\treturn t('nextcloud-vue', 'Video failed to load')\n\t\t\t}\n\t\t\treturn t('nextcloud-vue', 'Invalid video URL or domain not allowed.')\n\t\t},\n\n\t\t/**\n\t\t * The iframe `src` with playback query params appended.\n\t\t *\n\t\t * @return {string} the iframe URL, or `''`.\n\t\t */\n\t\tembedUrl() {\n\t\t\tif (!this.isIframeSource || this.videoUrl === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst params = []\n\t\t\tif (this.autoplay) {\n\t\t\t\tparams.push('autoplay=1')\n\t\t\t\tparams.push('mute=1')\n\t\t\t} else if (this.muted) {\n\t\t\t\tparams.push('mute=1')\n\t\t\t}\n\t\t\tif (this.loop) {\n\t\t\t\tparams.push('loop=1')\n\t\t\t\t// YouTube loops a single video only as a one-item playlist.\n\t\t\t\tconst id = this.sourceType === 'youtube' ? this.youtubeVideoId : ''\n\t\t\t\tif (id) {\n\t\t\t\t\tparams.push(`playlist=${encodeURIComponent(id)}`)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (params.length === 0) {\n\t\t\t\treturn this.videoUrl\n\t\t\t}\n\t\t\tconst separator = this.videoUrl.includes('?') ? '&' : '?'\n\t\t\treturn this.videoUrl + separator + params.join('&')\n\t\t},\n\n\t\t/**\n\t\t * The video id in a canonical YouTube embed URL (`/embed/<id>`).\n\t\t *\n\t\t * @return {string} the id, or `''`.\n\t\t */\n\t\tyoutubeVideoId() {\n\t\t\tconst match = this.videoUrl.match(/\\/embed\\/([^/?#&]+)/)\n\t\t\treturn match ? decodeURIComponent(match[1]) : ''\n\t\t},\n\n\t\t/**\n\t\t * The placeholder icon colour (a theme variable).\n\t\t *\n\t\t * @return {string} the CSS colour.\n\t\t */\n\t\tplaceholderColor() {\n\t\t\treturn 'var(--color-text-maxcontrast)'\n\t\t},\n\n\t\t/**\n\t\t * Inline style for the widget wrapper.\n\t\t *\n\t\t * @return {object} the wrapper style.\n\t\t */\n\t\twrapperStyle() {\n\t\t\treturn {\n\t\t\t\twidth: '100%',\n\t\t\t\theight: '100%',\n\t\t\t\toverflow: 'hidden',\n\t\t\t\tposition: 'relative',\n\t\t\t\tdisplay: 'flex',\n\t\t\t\t'align-items': 'center',\n\t\t\t\t'justify-content': 'center',\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Inline style for the media wrapper, enforcing the aspect ratio.\n\t\t *\n\t\t * @return {object} the media style.\n\t\t */\n\t\tmediaStyle() {\n\t\t\tconst [w, h] = this.aspectRatio.split(':')\n\t\t\tconst ratio = Number(w) / Number(h)\n\t\t\t// A cell wider than the ratio fits the video by its height.\n\t\t\tconst { width, height } = this.box\n\t\t\tconst fitsByHeight = height > 0 && width / height > ratio\n\t\t\treturn {\n\t\t\t\twidth: fitsByHeight ? `${Math.floor(height * ratio)}px` : '100%',\n\t\t\t\t'max-width': '100%',\n\t\t\t\t'aspect-ratio': `${w} / ${h}`,\n\t\t\t\tdisplay: 'flex',\n\t\t\t\t'align-items': 'center',\n\t\t\t\t'justify-content': 'center',\n\t\t\t\tbackground: 'var(--color-background-dark)',\n\t\t\t}\n\t\t},\n\t},\n\n\twatch: {\n\t\t// Re-arm the failure flag when the source changes so a previously\n\t\t// failed file does not permanently lock the cell.\n\t\tfileStreamingUrl() {\n\t\t\tthis.videoLoadFailed = false\n\t\t},\n\n\t\tvideoUrl() {\n\t\t\tthis.videoLoadFailed = false\n\t\t},\n\t},\n\n\tmounted() {\n\t\tif (typeof ResizeObserver === 'undefined') {\n\t\t\treturn\n\t\t}\n\t\tthis.resizeObserver = new ResizeObserver((entries) => {\n\t\t\tconst rect = entries[0] && entries[0].contentRect\n\t\t\tif (rect) {\n\t\t\t\tthis.box = { width: rect.width, height: rect.height }\n\t\t\t}\n\t\t})\n\t\tthis.resizeObserver.observe(this.$el)\n\t},\n\n\tbeforeUnmount() {\n\t\tif (this.resizeObserver) {\n\t\t\tthis.resizeObserver.disconnect()\n\t\t}\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * HTML5 `<video>` error handler — swaps to the error placeholder. The\n\t\t * event is swallowed so no exception bubbles into the grid layer.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\tonVideoError() {\n\t\t\tthis.videoLoadFailed = true\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-video-widget {\n\twidth: 100%;\n\theight: 100%;\n\toverflow: hidden;\n}\n\n.cn-video-widget__media {\n\tposition: relative;\n}\n\n.cn-video-widget__iframe,\n.cn-video-widget__video {\n\twidth: 100%;\n\theight: 100%;\n\tborder: 0;\n\tdisplay: block;\n\tbackground: var(--color-background-dark);\n}\n\n.cn-video-widget__placeholder {\n\twidth: 100%;\n\theight: 100%;\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: center;\n\tjustify-content: center;\n\tgap: 8px;\n\tcolor: var(--color-text-maxcontrast);\n\tpadding: 16px;\n\ttext-align: center;\n}\n\n.cn-video-widget__placeholder-label {\n\tfont-size: 13px;\n}\n\n.cn-video-widget__placeholder-help {\n\tfont-size: 12px;\n}\n\n.cn-video-widget__configure {\n\tpadding: 4px 12px;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n\tbackground: transparent;\n\tcolor: var(--color-main-text);\n\tcursor: pointer;\n}\n</style>\n"],"names":["_createElementVNode","_toDisplayString","_createElementBlock","_createVNode"],"mappings":";;;;AAciB,EAAA,KAAA,EAAA;;AAER,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,oCAAsB;AAC5B,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,mCAAW;;;AASlB,EAAA,KAAA,EAAA;;AAEC,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,oCAAO;;;;;;;;SAhBf,EAAA,iBAAkB;AACtB,IAAA,KAAK,iBAAC,QAAA,CAAA,YAAA;;MACK,QAAA,CAAA,SAAG;yCAWZ,iBAAA,EAAA;sBAVW,oBAAA,EAAA;AAAD,YAAA,IAAC,EAAA,EAAA;AAAA,YAAA,SAAA,EAAA,QAAA,CAAA;;UACZA,kBAAA,CAAiC,MAAA,EAAjC,UAAiC,EAAAC,eAAA,CAAA,IAAA,CAAA,CAAA,CAAA,eAAA,EAAA,yBAAA,CAAA,CAAA,EAAA,CAAA,YAAA;6BACX,MAAA,YAAA,EAAAA,eAAA,CAAA,IAAA,CAAA,CAAA,CAAA,eAAA,EAAA,gCAAA,CAAA,CAAA,EAAA,CAAA,YAAA;WAEhB,MAAA,CAAA,OAAC;4BADPC,kBAAA,CAMG,QAAA,EAAA;;AAJH,gBAAA,IAAG,EAAA,QAAA;AACH,gBAAA,KAAK,EAAC,4BAA4B;AACjC,gBAAA,OAAK,uCAAE,IAAA,CAAA,KAAK,CAAA,MAAA,CAAA,CAAA;iCACV,IAAA,CAAA,CAAA,CAAA,eAAA,EAAA,eAAA,CAAA,CAAA,EAAA,CAAA,YAAA;;;SAGC,QAAA,CAAA,QAAA;2CAGA,iBAAA,EAAA;YAFLC,WAAA,CAA6B,oBAAA,EAAA;AAAjB,cAAA,IAAI,EAAE,EAAE;AAAG,cAAA,SAAM,EAAA,QAAA,CAAA;;YAC7BH,kBAAA,CAAmB,MAAA,EAAnB,UAAmB,EAAAC,eAAA,CAAA,QAAA,CAAA,YAAA,CAAA,EAAA,CAAA;;wBAElBC,kBAAA;;AAEA,YAAA,KAAI,EAAC,wBAAS;AACd,YAAA,KAAK,iBAAE,QAAA,CAAA,UAAU;;aAEX,QAAA,CAAA,cAAQ;iDAMG,QAAA,EAAA;;AALjB,kBAAA,KAAK,EAAC,yBAAW;AAChB,kBAAA,GAAG,EAAA,QAAA,CAAA,QAAA;AACJ,kBAAA,OAAO,EAAC,oDAAe;AACvB,kBAAA,cAAc,EAAC,iCAAc;AAC7B,kBAAA,eAAe,EAAf,EAAe;AACf,kBAAA,WAAW,EAAC;;iBAED,QAAA,CAAA,YAAW;;;AACtB,oBAAA,KAAK,EAAC,wBAAK;AACV,oBAAA,GAAG,EAAE,QAAA,CAAA,gBAAa;AAClB,oBAAA,MAAM,EAAE,QAAA,CAAA,SAAS,IAAA,IAAA;AACjB,oBAAA,QAAE,EAAA,QAAA,CAAA,iBAAA;AACF,oBAAA,KAAC,EAAA,QAAA,CAAA,cAAA;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import script from './CnVideoWidgetForm2.vue.js';
|
|
|
2
2
|
import { render } from './CnVideoWidgetForm3.vue.js';
|
|
3
3
|
|
|
4
4
|
script.render = render;
|
|
5
|
-
script.__scopeId = "data-v-
|
|
5
|
+
script.__scopeId = "data-v-629b8baa";
|
|
6
6
|
const __sfc_main = script;
|
|
7
7
|
|
|
8
8
|
export { __sfc_main as default };
|
|
@@ -47,6 +47,17 @@ var script = {
|
|
|
47
47
|
type: Object,
|
|
48
48
|
default: () => ({ ...DEFAULT_CONTENT }),
|
|
49
49
|
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* An error the host found for the current URL (its server-side parse,
|
|
53
|
+
* say). Shown under the URL field in place of the form's own message,
|
|
54
|
+
* and returned by `validate()`, so the dialog cannot save. Empty when
|
|
55
|
+
* the host has no objection.
|
|
56
|
+
*/
|
|
57
|
+
urlError: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: '',
|
|
60
|
+
},
|
|
50
61
|
},
|
|
51
62
|
|
|
52
63
|
emits: [
|
|
@@ -228,6 +239,10 @@ var script = {
|
|
|
228
239
|
errors.push(translate('nextcloud-vue', 'Video URL is required'));
|
|
229
240
|
return errors
|
|
230
241
|
}
|
|
242
|
+
if (this.urlError) {
|
|
243
|
+
errors.push(this.urlError);
|
|
244
|
+
return errors
|
|
245
|
+
}
|
|
231
246
|
if (this.detectedSource === null) {
|
|
232
247
|
errors.push(translate('nextcloud-vue', 'Invalid video URL or domain not allowed.'));
|
|
233
248
|
return errors
|