@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.
Files changed (69) hide show
  1. package/dist/esm/components/CnCalendarWidget/CnCalendarWidget.vue.js +1 -1
  2. package/dist/esm/components/CnCalendarWidget/CnCalendarWidget2.vue.js +83 -2
  3. package/dist/esm/components/CnCalendarWidget/CnCalendarWidget2.vue.js.map +1 -1
  4. package/dist/esm/components/CnCalendarWidget/CnCalendarWidget3.vue.js +147 -104
  5. package/dist/esm/components/CnCalendarWidget/CnCalendarWidget3.vue.js.map +1 -1
  6. package/dist/esm/components/CnChartWidget/CnChartWidget.vue.js +1 -1
  7. package/dist/esm/components/CnChartWidget/CnChartWidget2.vue.js +58 -0
  8. package/dist/esm/components/CnChartWidget/CnChartWidget2.vue.js.map +1 -1
  9. package/dist/esm/components/CnChartWidget/CnChartWidget3.vue.js +2 -2
  10. package/dist/esm/components/CnChartWidget/CnChartWidget3.vue.js.map +1 -1
  11. package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue.js +1 -1
  12. package/dist/esm/components/CnDashboardGrid/CnDashboardGrid2.vue.js +41 -16
  13. package/dist/esm/components/CnDashboardGrid/CnDashboardGrid2.vue.js.map +1 -1
  14. package/dist/esm/components/CnDashboardGrid/CnDashboardGrid3.vue.js.map +1 -1
  15. package/dist/esm/components/CnDividerWidget/index.js +1 -0
  16. package/dist/esm/components/CnDividerWidget/index.js.map +1 -1
  17. package/dist/esm/components/CnFilesWidget/CnFilesWidget.vue.js +1 -1
  18. package/dist/esm/components/CnFilesWidget/CnFilesWidget2.vue.js +158 -5
  19. package/dist/esm/components/CnFilesWidget/CnFilesWidget2.vue.js.map +1 -1
  20. package/dist/esm/components/CnFilesWidget/CnFilesWidget3.vue.js +109 -45
  21. package/dist/esm/components/CnFilesWidget/CnFilesWidget3.vue.js.map +1 -1
  22. package/dist/esm/components/CnHeaderWidget/index.js +0 -1
  23. package/dist/esm/components/CnHeaderWidget/index.js.map +1 -1
  24. package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm.vue.js +1 -1
  25. package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm2.vue.js +17 -3
  26. package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm2.vue.js.map +1 -1
  27. package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm3.vue.js +3 -3
  28. package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm3.vue.js.map +1 -1
  29. package/dist/esm/components/CnVideoWidget/CnVideoWidget.vue.js +1 -1
  30. package/dist/esm/components/CnVideoWidget/CnVideoWidget2.vue.js +63 -1
  31. package/dist/esm/components/CnVideoWidget/CnVideoWidget2.vue.js.map +1 -1
  32. package/dist/esm/components/CnVideoWidget/CnVideoWidget3.vue.js +20 -10
  33. package/dist/esm/components/CnVideoWidget/CnVideoWidget3.vue.js.map +1 -1
  34. package/dist/esm/components/CnVideoWidgetForm/CnVideoWidgetForm.vue.js +1 -1
  35. package/dist/esm/components/CnVideoWidgetForm/CnVideoWidgetForm2.vue.js +15 -0
  36. package/dist/esm/components/CnVideoWidgetForm/CnVideoWidgetForm2.vue.js.map +1 -1
  37. package/dist/esm/components/CnVideoWidgetForm/CnVideoWidgetForm3.vue.js +17 -10
  38. package/dist/esm/components/CnVideoWidgetForm/CnVideoWidgetForm3.vue.js.map +1 -1
  39. package/dist/esm/components/CnWidgetGrid/dashboardWidgetRegistry.js +1 -0
  40. package/dist/esm/components/CnWidgetGrid/dashboardWidgetRegistry.js.map +1 -1
  41. package/dist/esm/dialogs/CnAddWidgetModal.vue.js +1 -1
  42. package/dist/esm/dialogs/CnAddWidgetModal2.vue.js +18 -4
  43. package/dist/esm/dialogs/CnAddWidgetModal2.vue.js.map +1 -1
  44. package/dist/esm/dialogs/CnAddWidgetModal3.vue.js +57 -39
  45. package/dist/esm/dialogs/CnAddWidgetModal3.vue.js.map +1 -1
  46. package/dist/esm/l10n/en.json.js +96 -1
  47. package/dist/esm/l10n/en.json.js.map +1 -1
  48. package/dist/esm/l10n/nl.json.js +96 -1
  49. package/dist/esm/l10n/nl.json.js.map +1 -1
  50. package/dist/esm/library-style.js +1 -1
  51. package/dist/esm/nextcloud-vue.css +309 -192
  52. package/dist/nextcloud-vue.cjs.js +2359 -1605
  53. package/dist/nextcloud-vue.cjs.js.map +2 -2
  54. package/dist/nextcloud-vue.css +309 -192
  55. package/l10n/en.json +96 -1
  56. package/l10n/nl.json +96 -1
  57. package/package.json +1 -1
  58. package/src/components/CnCalendarWidget/CnCalendarWidget.vue +217 -75
  59. package/src/components/CnChartWidget/CnChartWidget.vue +60 -2
  60. package/src/components/CnDashboardGrid/CnDashboardGrid.md +1 -1
  61. package/src/components/CnDashboardGrid/CnDashboardGrid.vue +41 -16
  62. package/src/components/CnDividerWidget/index.js +1 -0
  63. package/src/components/CnFilesWidget/CnFilesWidget.vue +278 -5
  64. package/src/components/CnHeaderWidget/index.js +0 -1
  65. package/src/components/CnHeaderWidgetForm/CnHeaderWidgetForm.vue +20 -6
  66. package/src/components/CnVideoWidget/CnVideoWidget.vue +84 -1
  67. package/src/components/CnVideoWidgetForm/CnVideoWidgetForm.vue +19 -1
  68. package/src/components/CnWidgetGrid/dashboardWidgetRegistry.js +1 -0
  69. package/src/dialogs/CnAddWidgetModal.vue +53 -14
@@ -1 +1 @@
1
- {"version":3,"file":"CnVideoWidgetForm2.vue.js","sources":["../../../../src/components/CnVideoWidgetForm/CnVideoWidgetForm.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-video-form\">\n\t\t<NcTextField\n\t\t\t:modelValue=\"videoUrl\"\n\t\t\t:label=\"t('nextcloud-vue', 'Video URL')\"\n\t\t\tplaceholder=\"https://www.youtube.com/watch?v=...\"\n\t\t\trequired\n\t\t\t@update:modelValue=\"onUrlInput\" />\n\n\t\t<div v-if=\"detectedSource\" class=\"cn-video-form__hint\">\n\t\t\t{{ detectedSourceLabel }}\n\t\t</div>\n\t\t<div v-else-if=\"hasUrl\" class=\"cn-video-form__error\" role=\"alert\">\n\t\t\t{{ t('nextcloud-vue', 'Invalid video URL or domain not allowed.') }}\n\t\t</div>\n\n\t\t<NcTextField\n\t\t\tv-if=\"sourceType === 'nc-file'\"\n\t\t\t:modelValue=\"String(fileId || '')\"\n\t\t\t:label=\"t('nextcloud-vue', 'Nextcloud File ID')\"\n\t\t\tplaceholder=\"12345\"\n\t\t\t@update:modelValue=\"onFileIdInput\" />\n\n\t\t<NcSelect\n\t\t\t:modelValue=\"aspectRatio\"\n\t\t\t:options=\"aspectRatioOptions\"\n\t\t\t:inputLabel=\"t('nextcloud-vue', 'Aspect Ratio')\"\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('aspectRatio', $event)\" />\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"autoplay\"\n\t\t\t@update:modelValue=\"onAutoplayToggle\">\n\t\t\t{{ t('nextcloud-vue', 'Autoplay') }}\n\t\t</NcCheckboxRadioSwitch>\n\t\t<div v-if=\"autoplay\" class=\"cn-video-form__hint\">\n\t\t\t{{ t('nextcloud-vue', 'Autoplay requires muting') }}\n\t\t</div>\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"muted\"\n\t\t\t:disabled=\"autoplay\"\n\t\t\t@update:modelValue=\"updateField('muted', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Muted') }}\n\t\t</NcCheckboxRadioSwitch>\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"loop\"\n\t\t\t@update:modelValue=\"updateField('loop', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Loop') }}\n\t\t</NcCheckboxRadioSwitch>\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"controls\"\n\t\t\t@update:modelValue=\"updateField('controls', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Show controls') }}\n\t\t</NcCheckboxRadioSwitch>\n\n\t\t<NcTextField\n\t\t\t:modelValue=\"posterUrl\"\n\t\t\t:label=\"t('nextcloud-vue', 'Poster Image URL (optional)')\"\n\t\t\tplaceholder=\"https://example.com/poster.jpg\"\n\t\t\t@update:modelValue=\"updateField('posterUrl', $event)\" />\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcCheckboxRadioSwitch, NcSelect, NcTextField } from '@nextcloud/vue'\nimport { detectVideoSource, normalizeEmbedUrl } from '../CnVideoWidget/videoUrlParser.js'\n\nconst VALID_ASPECT_RATIOS = ['16:9', '4:3', '1:1', '9:16']\n\nconst DEFAULT_CONTENT = Object.freeze({\n\tsourceType: null,\n\tvideoUrl: '',\n\tfileId: null,\n\tautoplay: false,\n\tmuted: true,\n\tloop: false,\n\tcontrols: true,\n\taspectRatio: '16:9',\n\tposterUrl: '',\n})\n\n/**\n * CnVideoWidgetForm — sub-form mounted inside the add-widget modal when the\n * user is creating or editing a `video` placement.\n *\n * Detects the platform (YouTube, Vimeo, PeerTube, Nextcloud Files) from the\n * URL and pre-computes the canonical embed URL. `validate()` returns errors\n * when the URL is empty or does not parse to a known source.\n *\n * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n */\nexport default {\n\tname: 'CnVideoWidgetForm',\n\n\tcomponents: {\n\t\tNcTextField,\n\t\tNcSelect,\n\t\tNcCheckboxRadioSwitch,\n\t},\n\n\tprops: {\n\t\t/** The placement being edited, or `null` in create mode. */\n\t\teditingWidget: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** Initial content values (registry defaults when not editing). */\n\t\tvalue: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({ ...DEFAULT_CONTENT }),\n\t\t},\n\t},\n\n\temits: [\n\t\t/**\n\t\t * Emitted on every change with the assembled content payload.\n\t\t *\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\treturn {\n\t\t\tvideoUrl: typeof initial.videoUrl === 'string' ? initial.videoUrl : DEFAULT_CONTENT.videoUrl,\n\t\t\tsourceType: typeof initial.sourceType === 'string' ? initial.sourceType : DEFAULT_CONTENT.sourceType,\n\t\t\tfileId: typeof initial.fileId === 'number' ? initial.fileId : DEFAULT_CONTENT.fileId,\n\t\t\tautoplay: typeof initial.autoplay === 'boolean' ? initial.autoplay : DEFAULT_CONTENT.autoplay,\n\t\t\tmuted: typeof initial.muted === 'boolean' ? initial.muted : DEFAULT_CONTENT.muted,\n\t\t\tloop: typeof initial.loop === 'boolean' ? initial.loop : DEFAULT_CONTENT.loop,\n\t\t\tcontrols: typeof initial.controls === 'boolean' ? initial.controls : DEFAULT_CONTENT.controls,\n\t\t\taspectRatio: VALID_ASPECT_RATIOS.includes(initial.aspectRatio)\n\t\t\t\t? initial.aspectRatio\n\t\t\t\t: DEFAULT_CONTENT.aspectRatio,\n\n\t\t\tposterUrl: typeof initial.posterUrl === 'string' ? initial.posterUrl : DEFAULT_CONTENT.posterUrl,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * Whether a non-empty URL has been entered.\n\t\t *\n\t\t * @return {boolean} true when `videoUrl` is non-empty.\n\t\t */\n\t\thasUrl() {\n\t\t\treturn typeof this.videoUrl === 'string' && this.videoUrl.trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * The detected source type for the current URL.\n\t\t *\n\t\t * @return {string|null} the detected source, or `null`.\n\t\t */\n\t\tdetectedSource() {\n\t\t\tif (!this.hasUrl) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\treturn detectVideoSource(this.videoUrl)\n\t\t},\n\n\t\t/**\n\t\t * The localised \"Detected: X\" hint label.\n\t\t *\n\t\t * @return {string} the detection hint.\n\t\t */\n\t\tdetectedSourceLabel() {\n\t\t\tswitch (this.detectedSource) {\n\t\t\t\tcase 'youtube':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: YouTube')\n\t\t\t\tcase 'vimeo':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: Vimeo')\n\t\t\t\tcase 'peertube':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: PeerTube')\n\t\t\t\tcase 'nc-file':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: Nextcloud File')\n\t\t\t\tdefault:\n\t\t\t\t\treturn ''\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The aspect-ratio dropdown options.\n\t\t *\n\t\t * @return {Array<{value: string, label: string}>} the options.\n\t\t */\n\t\taspectRatioOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: '16:9', label: '16:9' },\n\t\t\t\t{ value: '4:3', label: '4:3' },\n\t\t\t\t{ value: '1:1', label: '1:1' },\n\t\t\t\t{ value: '9:16', label: '9:16' },\n\t\t\t]\n\t\t},\n\n\t\t/**\n\t\t * The assembled `content` payload emitted to the parent.\n\t\t *\n\t\t * @return {object} the content blob.\n\t\t */\n\t\tassembledContent() {\n\t\t\treturn {\n\t\t\t\tsourceType: this.sourceType,\n\t\t\t\tvideoUrl: this.normalizedVideoUrl,\n\t\t\t\tfileId: this.fileId,\n\t\t\t\tautoplay: this.autoplay,\n\t\t\t\t// Autoplay forces muted.\n\t\t\t\tmuted: this.autoplay ? true : this.muted,\n\t\t\t\tloop: this.loop,\n\t\t\t\tcontrols: this.controls,\n\t\t\t\taspectRatio: this.aspectRatio,\n\t\t\t\tposterUrl: this.posterUrl,\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The canonical embed URL emitted upward (raw for nc-file inputs).\n\t\t *\n\t\t * @return {string} the embed URL.\n\t\t */\n\t\tnormalizedVideoUrl() {\n\t\t\tif (!this.detectedSource || this.detectedSource === 'nc-file') {\n\t\t\t\treturn this.videoUrl\n\t\t\t}\n\t\t\treturn normalizeEmbedUrl(this.videoUrl, this.detectedSource) || this.videoUrl\n\t\t},\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Set a field and emit `update:content`.\n\t\t *\n\t\t * @param {string} field the field name.\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 * URL change handler — drives source-type detection and emits.\n\t\t *\n\t\t * @param {string} value the new URL.\n\t\t * @return {void}\n\t\t */\n\t\tonUrlInput(value) {\n\t\t\tthis.videoUrl = value\n\t\t\tconst detected = detectVideoSource(value)\n\t\t\tthis.sourceType = detected\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * File-id change handler for `nc-file` sources.\n\t\t *\n\t\t * @param {string} value the raw input value.\n\t\t * @return {void}\n\t\t */\n\t\tonFileIdInput(value) {\n\t\t\tconst parsed = parseInt(String(value).trim(), 10)\n\t\t\tthis.fileId = Number.isFinite(parsed) ? parsed : null\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * Autoplay toggle handler — coerces muted=true while autoplay is on.\n\t\t *\n\t\t * @param {boolean} checked the autoplay checkbox value.\n\t\t * @return {void}\n\t\t */\n\t\tonAutoplayToggle(checked) {\n\t\t\tthis.autoplay = checked\n\t\t\tif (checked) {\n\t\t\t\tthis.muted = true\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. Requires a URL plus a recognised source.\n\t\t *\n\t\t * @return {string[]} the validation errors (empty when valid).\n\t\t */\n\t\tvalidate() {\n\t\t\tconst errors = []\n\t\t\tif (!this.hasUrl) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Video URL is required'))\n\t\t\t\treturn errors\n\t\t\t}\n\t\t\tif (this.detectedSource === null) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Invalid video URL or domain not allowed.'))\n\t\t\t\treturn errors\n\t\t\t}\n\t\t\tif (this.detectedSource === 'nc-file' && this.fileId === null) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Nextcloud file ID is required'))\n\t\t\t}\n\t\t\treturn errors\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-video-form {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n}\n\n.cn-video-form__hint {\n\tfont-size: 12px;\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-video-form__error {\n\tcolor: var(--color-error);\n\tfont-size: 13px;\n}\n</style>\n"],"names":["t"],"mappings":";;;;AA8EA,MAAM,mBAAkB,GAAI,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM;;AAEzD,MAAM,eAAc,GAAI,MAAM,CAAC,MAAM,CAAC;AACrC,CAAA,UAAU,EAAE,IAAI;CAChB,QAAQ,EAAE,EAAE;CACZ,MAAM,EAAE,IAAI;AACZ,CAAA,QAAQ,EAAE,KAAK;CACf,KAAK,EAAE,IAAI;CACX,IAAI,EAAE,KAAK;CACX,QAAQ,EAAE,IAAI;AACd,CAAA,WAAW,EAAE,MAAM;CACnB,SAAS,EAAE,EAAE;AACd,CAAC;;AAED;AACC;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAED,aAAe;CACd,IAAI,EAAE,mBAAmB;;CAEzB,UAAU,EAAE;EACX,WAAW;AACX,EAAA,QAAQ;AACR,EAAA,qBAAqB;EACrB;;AAED,CAAA,KAAK,EAAE;;AAEN,EAAA,aAAa,EAAE;GACd,IAAI,EAAE,MAAM;GACZ,OAAO,EAAE,IAAI;GACb;;;AAGD,EAAA,KAAK,EAAE;GACN,IAAI,EAAE,MAAM;AACZ,GAAA,OAAO,EAAE,OAAO,EAAE,GAAG,eAAc,EAAG,CAAC;GACvC;EACD;;AAED,CAAA,KAAK,EAAE;AACN;;AAEC;;;AAGD,EA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AI,CAAC,KAAK,CAAC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;EACnD,CAAC;;AAED;;AAEC;;;;EAID,gBAAgB,CAAC,OAAO,EAAE;AACzB,GAAA,IAAI,CAAC,WAAW;GAChB,IAAI,OAAO,EAAE;AACZ,IAAA,IAAI,CAAC,KAAI,GAAI;AACd,GAAA;GACA,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;EACnD,CAAC;;AAED;;AAEC;;;EAGD,QAAQ,GAAG;GACV,MAAM,MAAK,GAAI;AACf,GAAA,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;IACjB,MAAM,CAAC,IAAI,CAACA,SAAC,CAAC,eAAe,EAAE,uBAAuB,CAAC;IACvD,OAAO;AACR,GAAA;AACA,GAAA,IAAI,IAAI,CAAC,cAAa,KAAM,IAAI,EAAE;AACjC,IAAA,MAAM,CAAC,IAAI,CAACA,SAAC,CAAC,eAAe,EAAE,0CAA0C,CAAC;IAC1E,OAAO;AACR,GAAA;GACA,IAAI,IAAI,CAAC,cAAa,KAAM,SAAQ,IAAK,IAAI,CAAC,MAAK,KAAM,IAAI,EAAE;IAC9D,MAAM,CAAC,IAAI,CAACA,SAAC,CAAC,eAAe,EAAE,+BAA+B,CAAC;AAChE,GAAA;GACA,OAAO;EACR,CAAC;EACD;AACF;;"}
1
+ {"version":3,"file":"CnVideoWidgetForm2.vue.js","sources":["../../../../src/components/CnVideoWidgetForm/CnVideoWidgetForm.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-video-form\">\n\t\t<NcTextField\n\t\t\t:modelValue=\"videoUrl\"\n\t\t\t:label=\"t('nextcloud-vue', 'Video URL')\"\n\t\t\tplaceholder=\"https://www.youtube.com/watch?v=...\"\n\t\t\trequired\n\t\t\t@update:modelValue=\"onUrlInput\" />\n\n\t\t<div v-if=\"urlError && hasUrl\" class=\"cn-video-form__error\" role=\"alert\">\n\t\t\t{{ urlError }}\n\t\t</div>\n\t\t<div v-else-if=\"detectedSource\" class=\"cn-video-form__hint\">\n\t\t\t{{ detectedSourceLabel }}\n\t\t</div>\n\t\t<div v-else-if=\"hasUrl\" class=\"cn-video-form__error\" role=\"alert\">\n\t\t\t{{ t('nextcloud-vue', 'Invalid video URL or domain not allowed.') }}\n\t\t</div>\n\n\t\t<NcTextField\n\t\t\tv-if=\"sourceType === 'nc-file'\"\n\t\t\t:modelValue=\"String(fileId || '')\"\n\t\t\t:label=\"t('nextcloud-vue', 'Nextcloud File ID')\"\n\t\t\tplaceholder=\"12345\"\n\t\t\t@update:modelValue=\"onFileIdInput\" />\n\n\t\t<NcSelect\n\t\t\t:modelValue=\"aspectRatio\"\n\t\t\t:options=\"aspectRatioOptions\"\n\t\t\t:inputLabel=\"t('nextcloud-vue', 'Aspect Ratio')\"\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('aspectRatio', $event)\" />\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"autoplay\"\n\t\t\t@update:modelValue=\"onAutoplayToggle\">\n\t\t\t{{ t('nextcloud-vue', 'Autoplay') }}\n\t\t</NcCheckboxRadioSwitch>\n\t\t<div v-if=\"autoplay\" class=\"cn-video-form__hint\">\n\t\t\t{{ t('nextcloud-vue', 'Autoplay requires muting') }}\n\t\t</div>\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"muted\"\n\t\t\t:disabled=\"autoplay\"\n\t\t\t@update:modelValue=\"updateField('muted', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Muted') }}\n\t\t</NcCheckboxRadioSwitch>\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"loop\"\n\t\t\t@update:modelValue=\"updateField('loop', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Loop') }}\n\t\t</NcCheckboxRadioSwitch>\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"controls\"\n\t\t\t@update:modelValue=\"updateField('controls', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Show controls') }}\n\t\t</NcCheckboxRadioSwitch>\n\n\t\t<NcTextField\n\t\t\t:modelValue=\"posterUrl\"\n\t\t\t:label=\"t('nextcloud-vue', 'Poster Image URL (optional)')\"\n\t\t\tplaceholder=\"https://example.com/poster.jpg\"\n\t\t\t@update:modelValue=\"updateField('posterUrl', $event)\" />\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcCheckboxRadioSwitch, NcSelect, NcTextField } from '@nextcloud/vue'\nimport { detectVideoSource, normalizeEmbedUrl } from '../CnVideoWidget/videoUrlParser.js'\n\nconst VALID_ASPECT_RATIOS = ['16:9', '4:3', '1:1', '9:16']\n\nconst DEFAULT_CONTENT = Object.freeze({\n\tsourceType: null,\n\tvideoUrl: '',\n\tfileId: null,\n\tautoplay: false,\n\tmuted: true,\n\tloop: false,\n\tcontrols: true,\n\taspectRatio: '16:9',\n\tposterUrl: '',\n})\n\n/**\n * CnVideoWidgetForm — sub-form mounted inside the add-widget modal when the\n * user is creating or editing a `video` placement.\n *\n * Detects the platform (YouTube, Vimeo, PeerTube, Nextcloud Files) from the\n * URL and pre-computes the canonical embed URL. `validate()` returns errors\n * when the URL is empty or does not parse to a known source.\n *\n * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n */\nexport default {\n\tname: 'CnVideoWidgetForm',\n\n\tcomponents: {\n\t\tNcTextField,\n\t\tNcSelect,\n\t\tNcCheckboxRadioSwitch,\n\t},\n\n\tprops: {\n\t\t/** The placement being edited, or `null` in create mode. */\n\t\teditingWidget: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** Initial content values (registry defaults when not editing). */\n\t\tvalue: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({ ...DEFAULT_CONTENT }),\n\t\t},\n\n\t\t/**\n\t\t * An error the host found for the current URL (its server-side parse,\n\t\t * say). Shown under the URL field in place of the form's own message,\n\t\t * and returned by `validate()`, so the dialog cannot save. Empty when\n\t\t * the host has no objection.\n\t\t */\n\t\turlError: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\t},\n\n\temits: [\n\t\t/**\n\t\t * Emitted on every change with the assembled content payload.\n\t\t *\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\treturn {\n\t\t\tvideoUrl: typeof initial.videoUrl === 'string' ? initial.videoUrl : DEFAULT_CONTENT.videoUrl,\n\t\t\tsourceType: typeof initial.sourceType === 'string' ? initial.sourceType : DEFAULT_CONTENT.sourceType,\n\t\t\tfileId: typeof initial.fileId === 'number' ? initial.fileId : DEFAULT_CONTENT.fileId,\n\t\t\tautoplay: typeof initial.autoplay === 'boolean' ? initial.autoplay : DEFAULT_CONTENT.autoplay,\n\t\t\tmuted: typeof initial.muted === 'boolean' ? initial.muted : DEFAULT_CONTENT.muted,\n\t\t\tloop: typeof initial.loop === 'boolean' ? initial.loop : DEFAULT_CONTENT.loop,\n\t\t\tcontrols: typeof initial.controls === 'boolean' ? initial.controls : DEFAULT_CONTENT.controls,\n\t\t\taspectRatio: VALID_ASPECT_RATIOS.includes(initial.aspectRatio)\n\t\t\t\t? initial.aspectRatio\n\t\t\t\t: DEFAULT_CONTENT.aspectRatio,\n\n\t\t\tposterUrl: typeof initial.posterUrl === 'string' ? initial.posterUrl : DEFAULT_CONTENT.posterUrl,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * Whether a non-empty URL has been entered.\n\t\t *\n\t\t * @return {boolean} true when `videoUrl` is non-empty.\n\t\t */\n\t\thasUrl() {\n\t\t\treturn typeof this.videoUrl === 'string' && this.videoUrl.trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * The detected source type for the current URL.\n\t\t *\n\t\t * @return {string|null} the detected source, or `null`.\n\t\t */\n\t\tdetectedSource() {\n\t\t\tif (!this.hasUrl) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\treturn detectVideoSource(this.videoUrl)\n\t\t},\n\n\t\t/**\n\t\t * The localised \"Detected: X\" hint label.\n\t\t *\n\t\t * @return {string} the detection hint.\n\t\t */\n\t\tdetectedSourceLabel() {\n\t\t\tswitch (this.detectedSource) {\n\t\t\t\tcase 'youtube':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: YouTube')\n\t\t\t\tcase 'vimeo':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: Vimeo')\n\t\t\t\tcase 'peertube':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: PeerTube')\n\t\t\t\tcase 'nc-file':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: Nextcloud File')\n\t\t\t\tdefault:\n\t\t\t\t\treturn ''\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The aspect-ratio dropdown options.\n\t\t *\n\t\t * @return {Array<{value: string, label: string}>} the options.\n\t\t */\n\t\taspectRatioOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: '16:9', label: '16:9' },\n\t\t\t\t{ value: '4:3', label: '4:3' },\n\t\t\t\t{ value: '1:1', label: '1:1' },\n\t\t\t\t{ value: '9:16', label: '9:16' },\n\t\t\t]\n\t\t},\n\n\t\t/**\n\t\t * The assembled `content` payload emitted to the parent.\n\t\t *\n\t\t * @return {object} the content blob.\n\t\t */\n\t\tassembledContent() {\n\t\t\treturn {\n\t\t\t\tsourceType: this.sourceType,\n\t\t\t\tvideoUrl: this.normalizedVideoUrl,\n\t\t\t\tfileId: this.fileId,\n\t\t\t\tautoplay: this.autoplay,\n\t\t\t\t// Autoplay forces muted.\n\t\t\t\tmuted: this.autoplay ? true : this.muted,\n\t\t\t\tloop: this.loop,\n\t\t\t\tcontrols: this.controls,\n\t\t\t\taspectRatio: this.aspectRatio,\n\t\t\t\tposterUrl: this.posterUrl,\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The canonical embed URL emitted upward (raw for nc-file inputs).\n\t\t *\n\t\t * @return {string} the embed URL.\n\t\t */\n\t\tnormalizedVideoUrl() {\n\t\t\tif (!this.detectedSource || this.detectedSource === 'nc-file') {\n\t\t\t\treturn this.videoUrl\n\t\t\t}\n\t\t\treturn normalizeEmbedUrl(this.videoUrl, this.detectedSource) || this.videoUrl\n\t\t},\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Set a field and emit `update:content`.\n\t\t *\n\t\t * @param {string} field the field name.\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 * URL change handler — drives source-type detection and emits.\n\t\t *\n\t\t * @param {string} value the new URL.\n\t\t * @return {void}\n\t\t */\n\t\tonUrlInput(value) {\n\t\t\tthis.videoUrl = value\n\t\t\tconst detected = detectVideoSource(value)\n\t\t\tthis.sourceType = detected\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * File-id change handler for `nc-file` sources.\n\t\t *\n\t\t * @param {string} value the raw input value.\n\t\t * @return {void}\n\t\t */\n\t\tonFileIdInput(value) {\n\t\t\tconst parsed = parseInt(String(value).trim(), 10)\n\t\t\tthis.fileId = Number.isFinite(parsed) ? parsed : null\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * Autoplay toggle handler — coerces muted=true while autoplay is on.\n\t\t *\n\t\t * @param {boolean} checked the autoplay checkbox value.\n\t\t * @return {void}\n\t\t */\n\t\tonAutoplayToggle(checked) {\n\t\t\tthis.autoplay = checked\n\t\t\tif (checked) {\n\t\t\t\tthis.muted = true\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. Requires a URL plus a recognised source.\n\t\t *\n\t\t * @return {string[]} the validation errors (empty when valid).\n\t\t */\n\t\tvalidate() {\n\t\t\tconst errors = []\n\t\t\tif (!this.hasUrl) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Video URL is required'))\n\t\t\t\treturn errors\n\t\t\t}\n\t\t\tif (this.urlError) {\n\t\t\t\terrors.push(this.urlError)\n\t\t\t\treturn errors\n\t\t\t}\n\t\t\tif (this.detectedSource === null) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Invalid video URL or domain not allowed.'))\n\t\t\t\treturn errors\n\t\t\t}\n\t\t\tif (this.detectedSource === 'nc-file' && this.fileId === null) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Nextcloud file ID is required'))\n\t\t\t}\n\t\t\treturn errors\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-video-form {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n}\n\n.cn-video-form__hint {\n\tfont-size: 12px;\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-video-form__error {\n\tcolor: var(--color-error);\n\tfont-size: 13px;\n}\n</style>\n"],"names":["t"],"mappings":";;;;AAiFA,MAAM,mBAAkB,GAAI,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM;;AAEzD,MAAM,eAAc,GAAI,MAAM,CAAC,MAAM,CAAC;AACrC,CAAA,UAAU,EAAE,IAAI;CAChB,QAAQ,EAAE,EAAE;CACZ,MAAM,EAAE,IAAI;AACZ,CAAA,QAAQ,EAAE,KAAK;CACf,KAAK,EAAE,IAAI;CACX,IAAI,EAAE,KAAK;CACX,QAAQ,EAAE,IAAI;AACd,CAAA,WAAW,EAAE,MAAM;CACnB,SAAS,EAAE,EAAE;AACd,CAAC;;AAED;AACC;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAED,aAAe;CACd,IAAI,EAAE,mBAAmB;;CAEzB,UAAU,EAAE;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,KAAM,IAAI,EAAE;IAC9D,MAAM,CAAC,IAAI,CAACA,SAAC,CAAC,eAAe,EAAE,+BAA+B,CAAC;AAChE,GAAA;GACA,OAAO;EACR,CAAC;EACD;AACF;;"}
@@ -3,15 +3,20 @@ import { resolveComponent, openBlock, createElementBlock, createVNode, toDisplay
3
3
  const _hoisted_1 = { class: "cn-video-form" };
4
4
  const _hoisted_2 = {
5
5
  key: 0,
6
- class: "cn-video-form__hint"
6
+ class: "cn-video-form__error",
7
+ role: "alert"
7
8
  };
8
9
  const _hoisted_3 = {
9
10
  key: 1,
11
+ class: "cn-video-form__hint"
12
+ };
13
+ const _hoisted_4 = {
14
+ key: 2,
10
15
  class: "cn-video-form__error",
11
16
  role: "alert"
12
17
  };
13
- const _hoisted_4 = {
14
- key: 3,
18
+ const _hoisted_5 = {
19
+ key: 4,
15
20
  class: "cn-video-form__hint"
16
21
  };
17
22
 
@@ -28,14 +33,16 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
28
33
  required: "",
29
34
  "onUpdate:modelValue": $options.onUrlInput
30
35
  }, null, 8 /* PROPS */, ["modelValue", "label", "onUpdate:modelValue"]),
31
- ($options.detectedSource)
32
- ? (openBlock(), createElementBlock("div", _hoisted_2, toDisplayString($options.detectedSourceLabel), 1 /* TEXT */))
33
- : ($options.hasUrl)
34
- ? (openBlock(), createElementBlock("div", _hoisted_3, toDisplayString(_ctx.t('nextcloud-vue', 'Invalid video URL or domain not allowed.')), 1 /* TEXT */))
35
- : createCommentVNode("v-if", true),
36
+ ($props.urlError && $options.hasUrl)
37
+ ? (openBlock(), createElementBlock("div", _hoisted_2, toDisplayString($props.urlError), 1 /* TEXT */))
38
+ : ($options.detectedSource)
39
+ ? (openBlock(), createElementBlock("div", _hoisted_3, toDisplayString($options.detectedSourceLabel), 1 /* TEXT */))
40
+ : ($options.hasUrl)
41
+ ? (openBlock(), createElementBlock("div", _hoisted_4, toDisplayString(_ctx.t('nextcloud-vue', 'Invalid video URL or domain not allowed.')), 1 /* TEXT */))
42
+ : createCommentVNode("v-if", true),
36
43
  ($data.sourceType === 'nc-file')
37
44
  ? (openBlock(), createBlock(_component_NcTextField, {
38
- key: 2,
45
+ key: 3,
39
46
  modelValue: String($data.fileId || ''),
40
47
  label: _ctx.t('nextcloud-vue', 'Nextcloud File ID'),
41
48
  placeholder: "12345",
@@ -61,7 +68,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
61
68
  _: 1 /* STABLE */
62
69
  }, 8 /* PROPS */, ["modelValue", "onUpdate:modelValue"]),
63
70
  ($data.autoplay)
64
- ? (openBlock(), createElementBlock("div", _hoisted_4, toDisplayString(_ctx.t('nextcloud-vue', 'Autoplay requires muting')), 1 /* TEXT */))
71
+ ? (openBlock(), createElementBlock("div", _hoisted_5, toDisplayString(_ctx.t('nextcloud-vue', 'Autoplay requires muting')), 1 /* TEXT */))
65
72
  : createCommentVNode("v-if", true),
66
73
  createVNode(_component_NcCheckboxRadioSwitch, {
67
74
  modelValue: $data.muted,
@@ -1 +1 @@
1
- {"version":3,"file":"CnVideoWidgetForm3.vue.js","sources":["../../../../src/components/CnVideoWidgetForm/CnVideoWidgetForm.vue?vue&type=template&id=64939729&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-video-form\">\n\t\t<NcTextField\n\t\t\t:modelValue=\"videoUrl\"\n\t\t\t:label=\"t('nextcloud-vue', 'Video URL')\"\n\t\t\tplaceholder=\"https://www.youtube.com/watch?v=...\"\n\t\t\trequired\n\t\t\t@update:modelValue=\"onUrlInput\" />\n\n\t\t<div v-if=\"detectedSource\" class=\"cn-video-form__hint\">\n\t\t\t{{ detectedSourceLabel }}\n\t\t</div>\n\t\t<div v-else-if=\"hasUrl\" class=\"cn-video-form__error\" role=\"alert\">\n\t\t\t{{ t('nextcloud-vue', 'Invalid video URL or domain not allowed.') }}\n\t\t</div>\n\n\t\t<NcTextField\n\t\t\tv-if=\"sourceType === 'nc-file'\"\n\t\t\t:modelValue=\"String(fileId || '')\"\n\t\t\t:label=\"t('nextcloud-vue', 'Nextcloud File ID')\"\n\t\t\tplaceholder=\"12345\"\n\t\t\t@update:modelValue=\"onFileIdInput\" />\n\n\t\t<NcSelect\n\t\t\t:modelValue=\"aspectRatio\"\n\t\t\t:options=\"aspectRatioOptions\"\n\t\t\t:inputLabel=\"t('nextcloud-vue', 'Aspect Ratio')\"\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('aspectRatio', $event)\" />\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"autoplay\"\n\t\t\t@update:modelValue=\"onAutoplayToggle\">\n\t\t\t{{ t('nextcloud-vue', 'Autoplay') }}\n\t\t</NcCheckboxRadioSwitch>\n\t\t<div v-if=\"autoplay\" class=\"cn-video-form__hint\">\n\t\t\t{{ t('nextcloud-vue', 'Autoplay requires muting') }}\n\t\t</div>\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"muted\"\n\t\t\t:disabled=\"autoplay\"\n\t\t\t@update:modelValue=\"updateField('muted', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Muted') }}\n\t\t</NcCheckboxRadioSwitch>\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"loop\"\n\t\t\t@update:modelValue=\"updateField('loop', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Loop') }}\n\t\t</NcCheckboxRadioSwitch>\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"controls\"\n\t\t\t@update:modelValue=\"updateField('controls', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Show controls') }}\n\t\t</NcCheckboxRadioSwitch>\n\n\t\t<NcTextField\n\t\t\t:modelValue=\"posterUrl\"\n\t\t\t:label=\"t('nextcloud-vue', 'Poster Image URL (optional)')\"\n\t\t\tplaceholder=\"https://example.com/poster.jpg\"\n\t\t\t@update:modelValue=\"updateField('posterUrl', $event)\" />\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcCheckboxRadioSwitch, NcSelect, NcTextField } from '@nextcloud/vue'\nimport { detectVideoSource, normalizeEmbedUrl } from '../CnVideoWidget/videoUrlParser.js'\n\nconst VALID_ASPECT_RATIOS = ['16:9', '4:3', '1:1', '9:16']\n\nconst DEFAULT_CONTENT = Object.freeze({\n\tsourceType: null,\n\tvideoUrl: '',\n\tfileId: null,\n\tautoplay: false,\n\tmuted: true,\n\tloop: false,\n\tcontrols: true,\n\taspectRatio: '16:9',\n\tposterUrl: '',\n})\n\n/**\n * CnVideoWidgetForm — sub-form mounted inside the add-widget modal when the\n * user is creating or editing a `video` placement.\n *\n * Detects the platform (YouTube, Vimeo, PeerTube, Nextcloud Files) from the\n * URL and pre-computes the canonical embed URL. `validate()` returns errors\n * when the URL is empty or does not parse to a known source.\n *\n * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n */\nexport default {\n\tname: 'CnVideoWidgetForm',\n\n\tcomponents: {\n\t\tNcTextField,\n\t\tNcSelect,\n\t\tNcCheckboxRadioSwitch,\n\t},\n\n\tprops: {\n\t\t/** The placement being edited, or `null` in create mode. */\n\t\teditingWidget: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** Initial content values (registry defaults when not editing). */\n\t\tvalue: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({ ...DEFAULT_CONTENT }),\n\t\t},\n\t},\n\n\temits: [\n\t\t/**\n\t\t * Emitted on every change with the assembled content payload.\n\t\t *\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\treturn {\n\t\t\tvideoUrl: typeof initial.videoUrl === 'string' ? initial.videoUrl : DEFAULT_CONTENT.videoUrl,\n\t\t\tsourceType: typeof initial.sourceType === 'string' ? initial.sourceType : DEFAULT_CONTENT.sourceType,\n\t\t\tfileId: typeof initial.fileId === 'number' ? initial.fileId : DEFAULT_CONTENT.fileId,\n\t\t\tautoplay: typeof initial.autoplay === 'boolean' ? initial.autoplay : DEFAULT_CONTENT.autoplay,\n\t\t\tmuted: typeof initial.muted === 'boolean' ? initial.muted : DEFAULT_CONTENT.muted,\n\t\t\tloop: typeof initial.loop === 'boolean' ? initial.loop : DEFAULT_CONTENT.loop,\n\t\t\tcontrols: typeof initial.controls === 'boolean' ? initial.controls : DEFAULT_CONTENT.controls,\n\t\t\taspectRatio: VALID_ASPECT_RATIOS.includes(initial.aspectRatio)\n\t\t\t\t? initial.aspectRatio\n\t\t\t\t: DEFAULT_CONTENT.aspectRatio,\n\n\t\t\tposterUrl: typeof initial.posterUrl === 'string' ? initial.posterUrl : DEFAULT_CONTENT.posterUrl,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * Whether a non-empty URL has been entered.\n\t\t *\n\t\t * @return {boolean} true when `videoUrl` is non-empty.\n\t\t */\n\t\thasUrl() {\n\t\t\treturn typeof this.videoUrl === 'string' && this.videoUrl.trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * The detected source type for the current URL.\n\t\t *\n\t\t * @return {string|null} the detected source, or `null`.\n\t\t */\n\t\tdetectedSource() {\n\t\t\tif (!this.hasUrl) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\treturn detectVideoSource(this.videoUrl)\n\t\t},\n\n\t\t/**\n\t\t * The localised \"Detected: X\" hint label.\n\t\t *\n\t\t * @return {string} the detection hint.\n\t\t */\n\t\tdetectedSourceLabel() {\n\t\t\tswitch (this.detectedSource) {\n\t\t\t\tcase 'youtube':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: YouTube')\n\t\t\t\tcase 'vimeo':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: Vimeo')\n\t\t\t\tcase 'peertube':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: PeerTube')\n\t\t\t\tcase 'nc-file':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: Nextcloud File')\n\t\t\t\tdefault:\n\t\t\t\t\treturn ''\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The aspect-ratio dropdown options.\n\t\t *\n\t\t * @return {Array<{value: string, label: string}>} the options.\n\t\t */\n\t\taspectRatioOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: '16:9', label: '16:9' },\n\t\t\t\t{ value: '4:3', label: '4:3' },\n\t\t\t\t{ value: '1:1', label: '1:1' },\n\t\t\t\t{ value: '9:16', label: '9:16' },\n\t\t\t]\n\t\t},\n\n\t\t/**\n\t\t * The assembled `content` payload emitted to the parent.\n\t\t *\n\t\t * @return {object} the content blob.\n\t\t */\n\t\tassembledContent() {\n\t\t\treturn {\n\t\t\t\tsourceType: this.sourceType,\n\t\t\t\tvideoUrl: this.normalizedVideoUrl,\n\t\t\t\tfileId: this.fileId,\n\t\t\t\tautoplay: this.autoplay,\n\t\t\t\t// Autoplay forces muted.\n\t\t\t\tmuted: this.autoplay ? true : this.muted,\n\t\t\t\tloop: this.loop,\n\t\t\t\tcontrols: this.controls,\n\t\t\t\taspectRatio: this.aspectRatio,\n\t\t\t\tposterUrl: this.posterUrl,\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The canonical embed URL emitted upward (raw for nc-file inputs).\n\t\t *\n\t\t * @return {string} the embed URL.\n\t\t */\n\t\tnormalizedVideoUrl() {\n\t\t\tif (!this.detectedSource || this.detectedSource === 'nc-file') {\n\t\t\t\treturn this.videoUrl\n\t\t\t}\n\t\t\treturn normalizeEmbedUrl(this.videoUrl, this.detectedSource) || this.videoUrl\n\t\t},\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Set a field and emit `update:content`.\n\t\t *\n\t\t * @param {string} field the field name.\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 * URL change handler — drives source-type detection and emits.\n\t\t *\n\t\t * @param {string} value the new URL.\n\t\t * @return {void}\n\t\t */\n\t\tonUrlInput(value) {\n\t\t\tthis.videoUrl = value\n\t\t\tconst detected = detectVideoSource(value)\n\t\t\tthis.sourceType = detected\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * File-id change handler for `nc-file` sources.\n\t\t *\n\t\t * @param {string} value the raw input value.\n\t\t * @return {void}\n\t\t */\n\t\tonFileIdInput(value) {\n\t\t\tconst parsed = parseInt(String(value).trim(), 10)\n\t\t\tthis.fileId = Number.isFinite(parsed) ? parsed : null\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * Autoplay toggle handler — coerces muted=true while autoplay is on.\n\t\t *\n\t\t * @param {boolean} checked the autoplay checkbox value.\n\t\t * @return {void}\n\t\t */\n\t\tonAutoplayToggle(checked) {\n\t\t\tthis.autoplay = checked\n\t\t\tif (checked) {\n\t\t\t\tthis.muted = true\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. Requires a URL plus a recognised source.\n\t\t *\n\t\t * @return {string[]} the validation errors (empty when valid).\n\t\t */\n\t\tvalidate() {\n\t\t\tconst errors = []\n\t\t\tif (!this.hasUrl) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Video URL is required'))\n\t\t\t\treturn errors\n\t\t\t}\n\t\t\tif (this.detectedSource === null) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Invalid video URL or domain not allowed.'))\n\t\t\t\treturn errors\n\t\t\t}\n\t\t\tif (this.detectedSource === 'nc-file' && this.fileId === null) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Nextcloud file ID is required'))\n\t\t\t}\n\t\t\treturn errors\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-video-form {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n}\n\n.cn-video-form__hint {\n\tfont-size: 12px;\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-video-form__error {\n\tcolor: var(--color-error);\n\tfont-size: 13px;\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_createVNode","_toDisplayString","_createBlock"],"mappings":";;AAWM,MAAA,UAAA,GAAA,EAAA,KAAI,EAAA,eAAA;;;AAQH,EAAA,KAAA,EAAA;;;;AAGmB,EAAA,KAAK,EAAC,sBAAC;AAAA,EAAA,IAAA,EAAA;;;;AAyBZ,EAAA,KAAA,EAAA;;;;;;;;AApClB,EAAA,QAAAA,SAAA,EAAA,EAAAC,kBAAA,QAAA;IACAC,WAAA,CAKkC,sBAAA,EAAA;;AAHjC,MAAA,KAAK,EAAE,IAAA,CAAA,CAAC,CAAA,eAAA,EAAA,WAAA,CAAA;AACT,MAAA,WAAW,EAAC,qCAAY;AACxB,MAAA,QAAI,EAAJ,EAAI;AACH,MAAA,qBAAiB,EAAE,QAAA,CAAA;;KAEhB,QAAA,CAAA,cAAA;sBAALD,kBAAA,CAEM,KAAA,EAFN,UAEM,EAAAE,eAAA;SACU,QAAA,CAAA,MAAM;2CAEhB,KAAA,YAAA,EAAAA,eAAA,CADF,IAAA,CAAA,CAAC,CAAA,eAAA,EAAA,0CAAA,CAAA,CAAA,EAAA,CAAA,YAAA;;;sBAGJC,WAAA,CAKqC,sBAAA,EAAA;;UAHpC,UAAM,EAAA,MAAA,CAAA,KAAA,CAAA,MAAA,IAAA,EAAA,CAAA;AACN,UAAA,KAAK,EAAE,IAAA,CAAA,CAAC,CAAA,eAAA,EAAA,mBAAA,CAAA;AACT,UAAA,WAAW,EAAC,OAAO;AAClB,UAAA,qBAAiB,EAAE,QAAA,CAAA;;;gBASe,mBAAA,EAAA;AANlC,MAAA,UAAU,EAAE,KAAA,CAAA,WAAI;AAChB,MAAA,OAAO,E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,MAAA,UAAS,EAAA,KAAA,CAAA,QAAA;MACT,qBAAiB,EAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,MAAA,KAAE,QAAA,CAAA,WAAE,CAAA,UAAA,EAAA,MAAA,CAAA,CAAA;;uBACtB,MAAyC;wCAAtC,IAAA,CAAA,CAAC,CAAA,eAAA,EAAA,eAAA,CAAA,CAAA,EAAA,CAAA;;;;IAGLA,WAAA;;;;;;;;;"}
1
+ {"version":3,"file":"CnVideoWidgetForm3.vue.js","sources":["../../../../src/components/CnVideoWidgetForm/CnVideoWidgetForm.vue?vue&type=template&id=629b8baa&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-video-form\">\n\t\t<NcTextField\n\t\t\t:modelValue=\"videoUrl\"\n\t\t\t:label=\"t('nextcloud-vue', 'Video URL')\"\n\t\t\tplaceholder=\"https://www.youtube.com/watch?v=...\"\n\t\t\trequired\n\t\t\t@update:modelValue=\"onUrlInput\" />\n\n\t\t<div v-if=\"urlError && hasUrl\" class=\"cn-video-form__error\" role=\"alert\">\n\t\t\t{{ urlError }}\n\t\t</div>\n\t\t<div v-else-if=\"detectedSource\" class=\"cn-video-form__hint\">\n\t\t\t{{ detectedSourceLabel }}\n\t\t</div>\n\t\t<div v-else-if=\"hasUrl\" class=\"cn-video-form__error\" role=\"alert\">\n\t\t\t{{ t('nextcloud-vue', 'Invalid video URL or domain not allowed.') }}\n\t\t</div>\n\n\t\t<NcTextField\n\t\t\tv-if=\"sourceType === 'nc-file'\"\n\t\t\t:modelValue=\"String(fileId || '')\"\n\t\t\t:label=\"t('nextcloud-vue', 'Nextcloud File ID')\"\n\t\t\tplaceholder=\"12345\"\n\t\t\t@update:modelValue=\"onFileIdInput\" />\n\n\t\t<NcSelect\n\t\t\t:modelValue=\"aspectRatio\"\n\t\t\t:options=\"aspectRatioOptions\"\n\t\t\t:inputLabel=\"t('nextcloud-vue', 'Aspect Ratio')\"\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('aspectRatio', $event)\" />\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"autoplay\"\n\t\t\t@update:modelValue=\"onAutoplayToggle\">\n\t\t\t{{ t('nextcloud-vue', 'Autoplay') }}\n\t\t</NcCheckboxRadioSwitch>\n\t\t<div v-if=\"autoplay\" class=\"cn-video-form__hint\">\n\t\t\t{{ t('nextcloud-vue', 'Autoplay requires muting') }}\n\t\t</div>\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"muted\"\n\t\t\t:disabled=\"autoplay\"\n\t\t\t@update:modelValue=\"updateField('muted', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Muted') }}\n\t\t</NcCheckboxRadioSwitch>\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"loop\"\n\t\t\t@update:modelValue=\"updateField('loop', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Loop') }}\n\t\t</NcCheckboxRadioSwitch>\n\n\t\t<NcCheckboxRadioSwitch\n\t\t\t:modelValue=\"controls\"\n\t\t\t@update:modelValue=\"updateField('controls', $event)\">\n\t\t\t{{ t('nextcloud-vue', 'Show controls') }}\n\t\t</NcCheckboxRadioSwitch>\n\n\t\t<NcTextField\n\t\t\t:modelValue=\"posterUrl\"\n\t\t\t:label=\"t('nextcloud-vue', 'Poster Image URL (optional)')\"\n\t\t\tplaceholder=\"https://example.com/poster.jpg\"\n\t\t\t@update:modelValue=\"updateField('posterUrl', $event)\" />\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcCheckboxRadioSwitch, NcSelect, NcTextField } from '@nextcloud/vue'\nimport { detectVideoSource, normalizeEmbedUrl } from '../CnVideoWidget/videoUrlParser.js'\n\nconst VALID_ASPECT_RATIOS = ['16:9', '4:3', '1:1', '9:16']\n\nconst DEFAULT_CONTENT = Object.freeze({\n\tsourceType: null,\n\tvideoUrl: '',\n\tfileId: null,\n\tautoplay: false,\n\tmuted: true,\n\tloop: false,\n\tcontrols: true,\n\taspectRatio: '16:9',\n\tposterUrl: '',\n})\n\n/**\n * CnVideoWidgetForm — sub-form mounted inside the add-widget modal when the\n * user is creating or editing a `video` placement.\n *\n * Detects the platform (YouTube, Vimeo, PeerTube, Nextcloud Files) from the\n * URL and pre-computes the canonical embed URL. `validate()` returns errors\n * when the URL is empty or does not parse to a known source.\n *\n * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n */\nexport default {\n\tname: 'CnVideoWidgetForm',\n\n\tcomponents: {\n\t\tNcTextField,\n\t\tNcSelect,\n\t\tNcCheckboxRadioSwitch,\n\t},\n\n\tprops: {\n\t\t/** The placement being edited, or `null` in create mode. */\n\t\teditingWidget: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** Initial content values (registry defaults when not editing). */\n\t\tvalue: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({ ...DEFAULT_CONTENT }),\n\t\t},\n\n\t\t/**\n\t\t * An error the host found for the current URL (its server-side parse,\n\t\t * say). Shown under the URL field in place of the form's own message,\n\t\t * and returned by `validate()`, so the dialog cannot save. Empty when\n\t\t * the host has no objection.\n\t\t */\n\t\turlError: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\t},\n\n\temits: [\n\t\t/**\n\t\t * Emitted on every change with the assembled content payload.\n\t\t *\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\treturn {\n\t\t\tvideoUrl: typeof initial.videoUrl === 'string' ? initial.videoUrl : DEFAULT_CONTENT.videoUrl,\n\t\t\tsourceType: typeof initial.sourceType === 'string' ? initial.sourceType : DEFAULT_CONTENT.sourceType,\n\t\t\tfileId: typeof initial.fileId === 'number' ? initial.fileId : DEFAULT_CONTENT.fileId,\n\t\t\tautoplay: typeof initial.autoplay === 'boolean' ? initial.autoplay : DEFAULT_CONTENT.autoplay,\n\t\t\tmuted: typeof initial.muted === 'boolean' ? initial.muted : DEFAULT_CONTENT.muted,\n\t\t\tloop: typeof initial.loop === 'boolean' ? initial.loop : DEFAULT_CONTENT.loop,\n\t\t\tcontrols: typeof initial.controls === 'boolean' ? initial.controls : DEFAULT_CONTENT.controls,\n\t\t\taspectRatio: VALID_ASPECT_RATIOS.includes(initial.aspectRatio)\n\t\t\t\t? initial.aspectRatio\n\t\t\t\t: DEFAULT_CONTENT.aspectRatio,\n\n\t\t\tposterUrl: typeof initial.posterUrl === 'string' ? initial.posterUrl : DEFAULT_CONTENT.posterUrl,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * Whether a non-empty URL has been entered.\n\t\t *\n\t\t * @return {boolean} true when `videoUrl` is non-empty.\n\t\t */\n\t\thasUrl() {\n\t\t\treturn typeof this.videoUrl === 'string' && this.videoUrl.trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * The detected source type for the current URL.\n\t\t *\n\t\t * @return {string|null} the detected source, or `null`.\n\t\t */\n\t\tdetectedSource() {\n\t\t\tif (!this.hasUrl) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\treturn detectVideoSource(this.videoUrl)\n\t\t},\n\n\t\t/**\n\t\t * The localised \"Detected: X\" hint label.\n\t\t *\n\t\t * @return {string} the detection hint.\n\t\t */\n\t\tdetectedSourceLabel() {\n\t\t\tswitch (this.detectedSource) {\n\t\t\t\tcase 'youtube':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: YouTube')\n\t\t\t\tcase 'vimeo':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: Vimeo')\n\t\t\t\tcase 'peertube':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: PeerTube')\n\t\t\t\tcase 'nc-file':\n\t\t\t\t\treturn t('nextcloud-vue', 'Detected: Nextcloud File')\n\t\t\t\tdefault:\n\t\t\t\t\treturn ''\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The aspect-ratio dropdown options.\n\t\t *\n\t\t * @return {Array<{value: string, label: string}>} the options.\n\t\t */\n\t\taspectRatioOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: '16:9', label: '16:9' },\n\t\t\t\t{ value: '4:3', label: '4:3' },\n\t\t\t\t{ value: '1:1', label: '1:1' },\n\t\t\t\t{ value: '9:16', label: '9:16' },\n\t\t\t]\n\t\t},\n\n\t\t/**\n\t\t * The assembled `content` payload emitted to the parent.\n\t\t *\n\t\t * @return {object} the content blob.\n\t\t */\n\t\tassembledContent() {\n\t\t\treturn {\n\t\t\t\tsourceType: this.sourceType,\n\t\t\t\tvideoUrl: this.normalizedVideoUrl,\n\t\t\t\tfileId: this.fileId,\n\t\t\t\tautoplay: this.autoplay,\n\t\t\t\t// Autoplay forces muted.\n\t\t\t\tmuted: this.autoplay ? true : this.muted,\n\t\t\t\tloop: this.loop,\n\t\t\t\tcontrols: this.controls,\n\t\t\t\taspectRatio: this.aspectRatio,\n\t\t\t\tposterUrl: this.posterUrl,\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The canonical embed URL emitted upward (raw for nc-file inputs).\n\t\t *\n\t\t * @return {string} the embed URL.\n\t\t */\n\t\tnormalizedVideoUrl() {\n\t\t\tif (!this.detectedSource || this.detectedSource === 'nc-file') {\n\t\t\t\treturn this.videoUrl\n\t\t\t}\n\t\t\treturn normalizeEmbedUrl(this.videoUrl, this.detectedSource) || this.videoUrl\n\t\t},\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * Set a field and emit `update:content`.\n\t\t *\n\t\t * @param {string} field the field name.\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 * URL change handler — drives source-type detection and emits.\n\t\t *\n\t\t * @param {string} value the new URL.\n\t\t * @return {void}\n\t\t */\n\t\tonUrlInput(value) {\n\t\t\tthis.videoUrl = value\n\t\t\tconst detected = detectVideoSource(value)\n\t\t\tthis.sourceType = detected\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * File-id change handler for `nc-file` sources.\n\t\t *\n\t\t * @param {string} value the raw input value.\n\t\t * @return {void}\n\t\t */\n\t\tonFileIdInput(value) {\n\t\t\tconst parsed = parseInt(String(value).trim(), 10)\n\t\t\tthis.fileId = Number.isFinite(parsed) ? parsed : null\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * Autoplay toggle handler — coerces muted=true while autoplay is on.\n\t\t *\n\t\t * @param {boolean} checked the autoplay checkbox value.\n\t\t * @return {void}\n\t\t */\n\t\tonAutoplayToggle(checked) {\n\t\t\tthis.autoplay = checked\n\t\t\tif (checked) {\n\t\t\t\tthis.muted = true\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. Requires a URL plus a recognised source.\n\t\t *\n\t\t * @return {string[]} the validation errors (empty when valid).\n\t\t */\n\t\tvalidate() {\n\t\t\tconst errors = []\n\t\t\tif (!this.hasUrl) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Video URL is required'))\n\t\t\t\treturn errors\n\t\t\t}\n\t\t\tif (this.urlError) {\n\t\t\t\terrors.push(this.urlError)\n\t\t\t\treturn errors\n\t\t\t}\n\t\t\tif (this.detectedSource === null) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Invalid video URL or domain not allowed.'))\n\t\t\t\treturn errors\n\t\t\t}\n\t\t\tif (this.detectedSource === 'nc-file' && this.fileId === null) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Nextcloud file ID is required'))\n\t\t\t}\n\t\t\treturn errors\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-video-form {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n}\n\n.cn-video-form__hint {\n\tfont-size: 12px;\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-video-form__error {\n\tcolor: var(--color-error);\n\tfont-size: 13px;\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_createVNode","_toDisplayString","_createBlock"],"mappings":";;AAWM,MAAA,UAAA,GAAA,EAAA,KAAI,EAAA,eAAA;;;AAQH,EAAA,KAAA,EAAA,sBAAA;AAAA,EAAA,IAAA,EAAA;;;;AAGA,EAAA,KAAA,EAAA;;;;AAGmB,EAAA,KAAK,EAAC,sBAAC;AAAA,EAAA,IAAA,EAAA;;;;AAyBZ,EAAA,KAAA,EAAA;;;;;;;;AAvClB,EAAA,QAAAA,SAAA,EAAA,EAAAC,kBAAA,QAAA;IACAC,WAAA,CAKkC,sBAAA,EAAA;;AAHjC,MAAA,KAAK,EAAE,IAAA,CAAA,CAAC,CAAA,eAAA,EAAA,WAAA,CAAA;AACT,MAAA,WAAU,EAAE,qCAAC;AACb,MAAA,QAAI,EAAJ,EAAI;AACH,MAAA,qBAAiB,EAAE,QAAA,CAAA;;AAEhB,IAAA,CAAA,MAAA,CAAA,QAAA,IAAA,QAAA,CAAA,MAAA;sBAALD,kBAAA,CAEM,KAAA,EAFN,UAEM,EAAAE,eAAA,CADH,MAAA,CAAA,QAAS,CAAA,EAAA,CAAA,YAAA;SAEP,QAAA,CAAA,cAAA;wBAALF,kBAAA,CAEM,KAAA,EAFN,UAEM,EAAAE,eAAA;WACU,QAAA,CAAA,MAAM;6CAEhB,KAAA,YAAA,EAAAA,eAAA,CADF,IAAA,CAAA,CAAC,CAAA,eAAA,EAAA,0CAAA,CAAA,CAAA,EAAA,CAAA,YAAA;;;sBAGJC,WAAA,CAKqC,sBAAA,EAAA;;UAHpC,UAAM,EAAA,MAAA,CAAA,KAAA,CAAA,MAAA,I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AA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,MAAA,KAAE,QAAA,CAAA,WAAC,CAAA,MAAA,EAAA,MAAA,CAAA,CAAA;;uBACrB,MAAgC;wCAA7B,IAAA,CAAA,CAAC,CAAA,eAAA,EAAA,MAAA,CAAA,CAAA,EAAA,CAAA;;;;gBAOmB,gCAAA,EAAA;AAHtB,MAAA,UAAS,EAAA,KAAA,CAAA,QAAA;MACT,qBAAiB,EAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,MAAA,KAAE,QAAA,CAAA,WAAE,CAAA,UAAA,EAAA,MAAA,CAAA,CAAA;;uBACtB,MAAyC;wCAAtC,IAAA,CAAA,CAAC,CAAA,eAAA,EAAA,eAAA,CAAA,CAAA,EAAA,CAAA;;;;IAGLA,WAAA;;;;;;;;;"}
@@ -37,6 +37,7 @@
37
37
  * @property {object} defaultContent Initial `content` payload seeded into new placements.
38
38
  * @property {string} displayName Human-readable type name shown in the type picker.
39
39
  * @property {string} icon Material Design icon name used in the type picker.
40
+ * @property {number} [minHeight] The fewest grid rows a placement of this type may take, below the grid's own minimum (a divider: 1). A host copies it onto the layout item as `minHeight`.
40
41
  * @property {string[]} [surfaces] Surfaces this type may be added on (e.g. `['app-dashboard']`, `['detail-page']`). Omitted means the default dashboard surfaces. A detail-only widget (like `data`) sets `['detail-page']` so it never appears in the dashboard Add-widget picker.
41
42
  * @property {boolean} [public] Whether a PUBLIC host (an anonymous visitor at a public origin, such as the portal) may mount this widget. Default `false`, and `registerDashboardWidget()` records it: a widget author opts in deliberately. A non-boolean value is refused.
42
43
  * @property {{graphql?: string[]}} [requires] Soft runtime-source hint for cross-app widgets — names the sibling-app schemas the widget reads. NEVER a `manifest.dependencies` entry.
@@ -1 +1 @@
1
- {"version":3,"file":"dashboardWidgetRegistry.js","sources":["../../../../src/components/CnWidgetGrid/dashboardWidgetRegistry.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * dashboardWidgetRegistry — the shared, mutable single source of truth for the\n * dashboard widget catalog (cn-widget-library, design D1).\n *\n * This registry is intentionally SEPARATE from `BUILT_IN_WIDGETS` (the v2\n * manifest widget set in `builtInWidgets.js`). The two systems compose at the\n * `CnWidgetGrid` resolution boundary — `BUILT_IN_WIDGETS` → this registry →\n * consumer `cnRegistry` inject (override wins last) — but their cores stay\n * independent: `BUILT_IN_WIDGETS` keys are object-detail widgets that need a\n * loaded OpenRegister object, whereas catalog widgets are content/config-driven.\n *\n * Each entry maps a widget `type` string (the value persisted in a placement)\n * to a `{renderer, form, defaultContent, displayName, icon, requires?}`\n * descriptor. The catalog widgets self-register into this registry at import\n * time via `registerDashboardWidget()` (each widget capability owns its own\n * registration; this module ships EMPTY and gains entries as widgets land —\n * Wave 0 has none yet). The `CnAddWidgetModal` consults `listWidgetTypes()` /\n * `getWidgetTypeEntry()` to render the type picker and the per-type sub-form.\n *\n * Registration policy (design D2): last-registration-wins. Registering an\n * existing `type` overwrites the prior entry and emits a development\n * `console.warn` naming the overwritten type so accidental double-registration\n * is visible. Consumer `cnRegistry` overrides still win over this registry at\n * `CnWidgetGrid` resolution time, so an app never has to mutate this shared\n * object to skin a single widget.\n *\n * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n */\n\n/**\n * @typedef {object} DashboardWidgetEntry\n * @property {object} renderer Vue component reference for the dashboard grid (may be a lazy/async component definition).\n * @property {object|null} form Vue component reference for the `CnAddWidgetModal` sub-form, or `null`/`undefined` for a renderer-only type (excluded from the picker).\n * @property {object} defaultContent Initial `content` payload seeded into new placements.\n * @property {string} displayName Human-readable type name shown in the type picker.\n * @property {string} icon Material Design icon name used in the type picker.\n * @property {string[]} [surfaces] Surfaces this type may be added on (e.g. `['app-dashboard']`, `['detail-page']`). Omitted means the default dashboard surfaces. A detail-only widget (like `data`) sets `['detail-page']` so it never appears in the dashboard Add-widget picker.\n * @property {boolean} [public] Whether a PUBLIC host (an anonymous visitor at a public origin, such as the portal) may mount this widget. Default `false`, and `registerDashboardWidget()` records it: a widget author opts in deliberately. A non-boolean value is refused.\n * @property {{graphql?: string[]}} [requires] Soft runtime-source hint for cross-app widgets — names the sibling-app schemas the widget reads. NEVER a `manifest.dependencies` entry.\n */\n\n/**\n * The shared dashboard widget registry. A mutable object map keyed by widget\n * `type` string. Catalog widgets self-register into it; consumer apps may\n * extend or override it via {@link registerDashboardWidget}.\n *\n * @type {Record<string, DashboardWidgetEntry>}\n */\nexport const dashboardWidgetRegistry = {}\n\n/**\n * Register (or override) a widget type in the shared registry.\n *\n * Last-registration-wins (design D2): registering an existing `type`\n * overwrites the prior entry. When an override occurs and `NODE_ENV` is not\n * `'production'`, a `console.warn` naming the overwritten type is emitted so\n * accidental double-registration surfaces in development.\n *\n * @param {string} type the widget type key (the persisted placement type).\n * @param {DashboardWidgetEntry} entry the descriptor to register.\n * @return {void}\n */\nexport function registerDashboardWidget(type, entry) {\n\tif (typeof type !== 'string' || type === '') {\n\t\treturn\n\t}\n\t// Default closed: an anonymous visitor may only ever see a widget whose\n\t// author said so. Refuse, rather than coerce, a value that is not a boolean:\n\t// \"yes\" must not quietly become true, or false.\n\tif (entry && entry.public !== undefined && typeof entry.public !== 'boolean') {\n\t\tthrow new TypeError(`[dashboardWidgetRegistry] widget type \"${type}\": \\`public\\` must be a boolean, got ${typeof entry.public}.`)\n\t}\n\tif (entry && entry.public === undefined) {\n\t\tif (Object.isExtensible(entry)) {\n\t\t\tentry.public = false\n\t\t} else {\n\t\t\tentry = { ...entry, public: false }\n\t\t}\n\t}\n\tconst isOverride = Object.hasOwn(dashboardWidgetRegistry, type)\n\t// Read through `globalThis` rather than a bare `process`: this module is\n\t// bundled for the browser, where `process` is simply absent, and the\n\t// optional chain states that as plainly as the old `typeof` guard did.\n\tconst env = globalThis.process?.env\n\tif (isOverride && env && env.NODE_ENV !== 'production') {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(`[dashboardWidgetRegistry] widget type \"${type}\" is already registered — overriding the previous entry (last-registration-wins).`)\n\t}\n\tdashboardWidgetRegistry[type] = entry\n}\n\n/**\n * List every registered widget type that has a usable form component. The\n * `CnAddWidgetModal` type picker calls this; renderer-only types (entries with\n * a null/undefined `form`) are excluded so the user is never offered a type\n * they cannot configure.\n *\n * @param {string} [surface] Optional surface key to filter by (default\n * `'app-dashboard'`). Entries whose `surfaces` excludes it are dropped, so a\n * detail-only type (e.g. `data`) never appears in the dashboard picker. Pass\n * the matching surface to list detail-page types.\n * @return {string[]} the registered type keys whose entry has a non-null form.\n */\nexport function listWidgetTypes(surface = 'app-dashboard') {\n\treturn Object.keys(dashboardWidgetRegistry).filter((type) => dashboardWidgetRegistry[type]\n\t\t&& dashboardWidgetRegistry[type].form !== null\n\t\t&& dashboardWidgetRegistry[type].form !== undefined\n\t\t&& widgetTypeAllowsSurface(dashboardWidgetRegistry[type], surface))\n}\n\n/**\n * List the widget types a USER may add to their own dashboard.\n *\n * 🔴 IT IS AN OPT-IN, AND THAT IS THE WHOLE POINT. `listWidgetTypes()` answers\n * what an administrator may put on a page for everybody, which is a much\n * larger set: an admin configures a widget once, with the register and schema\n * in front of them, and a user picking from the same list would be offered\n * types that need configuration they cannot supply and cannot be told about.\n * So a type is offerable to a user only when its registry entry says\n * `userAddable: true`.\n *\n * @param {string} [surface] The surface key, as {@link listWidgetTypes} uses it.\n * @return {string[]} The type keys a user may add themselves.\n */\nexport function listUserAddableWidgetTypes(surface = 'app-dashboard') {\n\treturn listWidgetTypes(surface).filter((type) => dashboardWidgetRegistry[type]?.userAddable === true)\n}\n\n/**\n * The presets a manifest offers a user, from `config.userWidgets[]`.\n *\n * A preset is a widget an app has already configured, offered under a name a\n * user recognises: \"one of my saved views\", \"my tasks\". It exists because the\n * registry types a user may add are deliberately few, and the two lists a user\n * actually wants are both `object-list` widgets that need a query the app\n * knows and the user does not.\n *\n * An entry with no `id` or no `kind` is dropped rather than offered: a preset\n * nobody can identify cannot be added, and one with no kind has nothing to\n * render.\n *\n * @param {object|null} config The page config.\n * @return {Array<{ id: string, kind: string, label: string, widget: object }>} The offerable presets.\n */\nexport function userWidgetPresets(config) {\n\tconst declared = config?.userWidgets\n\tif (!Array.isArray(declared)) {\n\t\treturn []\n\t}\n\n\tconst presets = []\n\tfor (const entry of declared) {\n\t\tconst id = String(entry?.id ?? '').trim()\n\t\tconst kind = String(entry?.kind ?? '').trim()\n\t\tif (id === '' || kind === '') {\n\t\t\tcontinue\n\t\t}\n\n\t\tpresets.push({\n\t\t\tid,\n\t\t\tkind,\n\t\t\tlabel: String(entry?.label ?? id),\n\t\t\t// The widget definition the app configured, copied so a caller\n\t\t\t// adding one twice does not hand the grid the same object twice.\n\t\t\twidget: { ...(entry?.widget || {}) },\n\t\t})\n\t}\n\n\treturn presets\n}\n\n/**\n * Whether a widget type may be mounted by a public host. False for an unknown\n * type: the decision and the lookup are one thing.\n *\n * @param {string} type the widget type key.\n * @return {boolean} true only for a registered entry with `public: true`.\n */\nexport function isPublicWidgetType(type) {\n\tconst entry = dashboardWidgetRegistry[type]\n\treturn Boolean(entry) && entry.public === true\n}\n\n/**\n * Look up a widget type entry; returns `null` when the type is unknown so the\n * caller can fall back gracefully.\n *\n * @param {string} type the widget type key.\n * @return {DashboardWidgetEntry|null} the registry entry or `null`.\n */\nexport function getWidgetTypeEntry(type) {\n\treturn dashboardWidgetRegistry[type] || null\n}\n\n/**\n * Whether a registry entry is offerable on a given surface. An entry with no\n * `surfaces` is offerable everywhere; otherwise the surface must be listed.\n *\n * @param {DashboardWidgetEntry} entry the registry entry.\n * @param {string} surface the surface key (e.g. `'app-dashboard'`, `'detail-page'`).\n * @return {boolean} true when the entry may be added on that surface.\n */\nexport function widgetTypeAllowsSurface(entry, surface) {\n\tif (!entry) {\n\t\treturn false\n\t}\n\tif (!Array.isArray(entry.surfaces) || entry.surfaces.length === 0) {\n\t\treturn true\n\t}\n\treturn entry.surfaces.includes(surface)\n}\n\n/**\n * Return a fresh copy of the `defaultContent` blob for a registered type, or\n * `{}` for unknown types so the caller never has to null-check. A shallow copy\n * is returned so a caller mutating the result does not pollute the registry\n * defaults or another caller's content.\n *\n * @param {string} type the widget type key.\n * @return {object} a fresh copy of the type's `defaultContent`.\n */\nexport function getDefaultContent(type) {\n\tconst entry = dashboardWidgetRegistry[type]\n\tif (!entry) {\n\t\treturn {}\n\t}\n\treturn { ...entry.defaultContent }\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,uBAAuB,GAAG;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,IAAI,EAAE,KAAK,EAAE;AACrD,CAAC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE,EAAE;AAC9C,EAAE;AACF,CAAC;AACD;AACA;AACA;AACA,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE;AAC/E,EAAE,MAAM,IAAI,SAAS,CAAC,CAAC,uCAAuC,EAAE,IAAI,CAAC,qCAAqC,EAAE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AAClI,CAAC;AACD,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE;AAC1C,EAAE,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;AAClC,GAAG,KAAK,CAAC,MAAM,GAAG;AAClB,EAAE,CAAC,MAAM;AACT,GAA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,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,IAAI,EAAE;AACxC,CAAC,MAAM,KAAK,GAAG,uBAAuB,CAAC,IAAI;AAC3C,CAAC,IAAI,CAAC,KAAK,EAAE;AACb,EAAE,OAAO;AACT,CAAC;AACD,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,cAAc;AACjC;;"}
1
+ {"version":3,"file":"dashboardWidgetRegistry.js","sources":["../../../../src/components/CnWidgetGrid/dashboardWidgetRegistry.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * dashboardWidgetRegistry — the shared, mutable single source of truth for the\n * dashboard widget catalog (cn-widget-library, design D1).\n *\n * This registry is intentionally SEPARATE from `BUILT_IN_WIDGETS` (the v2\n * manifest widget set in `builtInWidgets.js`). The two systems compose at the\n * `CnWidgetGrid` resolution boundary — `BUILT_IN_WIDGETS` → this registry →\n * consumer `cnRegistry` inject (override wins last) — but their cores stay\n * independent: `BUILT_IN_WIDGETS` keys are object-detail widgets that need a\n * loaded OpenRegister object, whereas catalog widgets are content/config-driven.\n *\n * Each entry maps a widget `type` string (the value persisted in a placement)\n * to a `{renderer, form, defaultContent, displayName, icon, requires?}`\n * descriptor. The catalog widgets self-register into this registry at import\n * time via `registerDashboardWidget()` (each widget capability owns its own\n * registration; this module ships EMPTY and gains entries as widgets land —\n * Wave 0 has none yet). The `CnAddWidgetModal` consults `listWidgetTypes()` /\n * `getWidgetTypeEntry()` to render the type picker and the per-type sub-form.\n *\n * Registration policy (design D2): last-registration-wins. Registering an\n * existing `type` overwrites the prior entry and emits a development\n * `console.warn` naming the overwritten type so accidental double-registration\n * is visible. Consumer `cnRegistry` overrides still win over this registry at\n * `CnWidgetGrid` resolution time, so an app never has to mutate this shared\n * object to skin a single widget.\n *\n * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n */\n\n/**\n * @typedef {object} DashboardWidgetEntry\n * @property {object} renderer Vue component reference for the dashboard grid (may be a lazy/async component definition).\n * @property {object|null} form Vue component reference for the `CnAddWidgetModal` sub-form, or `null`/`undefined` for a renderer-only type (excluded from the picker).\n * @property {object} defaultContent Initial `content` payload seeded into new placements.\n * @property {string} displayName Human-readable type name shown in the type picker.\n * @property {string} icon Material Design icon name used in the type picker.\n * @property {number} [minHeight] The fewest grid rows a placement of this type may take, below the grid's own minimum (a divider: 1). A host copies it onto the layout item as `minHeight`.\n * @property {string[]} [surfaces] Surfaces this type may be added on (e.g. `['app-dashboard']`, `['detail-page']`). Omitted means the default dashboard surfaces. A detail-only widget (like `data`) sets `['detail-page']` so it never appears in the dashboard Add-widget picker.\n * @property {boolean} [public] Whether a PUBLIC host (an anonymous visitor at a public origin, such as the portal) may mount this widget. Default `false`, and `registerDashboardWidget()` records it: a widget author opts in deliberately. A non-boolean value is refused.\n * @property {{graphql?: string[]}} [requires] Soft runtime-source hint for cross-app widgets — names the sibling-app schemas the widget reads. NEVER a `manifest.dependencies` entry.\n */\n\n/**\n * The shared dashboard widget registry. A mutable object map keyed by widget\n * `type` string. Catalog widgets self-register into it; consumer apps may\n * extend or override it via {@link registerDashboardWidget}.\n *\n * @type {Record<string, DashboardWidgetEntry>}\n */\nexport const dashboardWidgetRegistry = {}\n\n/**\n * Register (or override) a widget type in the shared registry.\n *\n * Last-registration-wins (design D2): registering an existing `type`\n * overwrites the prior entry. When an override occurs and `NODE_ENV` is not\n * `'production'`, a `console.warn` naming the overwritten type is emitted so\n * accidental double-registration surfaces in development.\n *\n * @param {string} type the widget type key (the persisted placement type).\n * @param {DashboardWidgetEntry} entry the descriptor to register.\n * @return {void}\n */\nexport function registerDashboardWidget(type, entry) {\n\tif (typeof type !== 'string' || type === '') {\n\t\treturn\n\t}\n\t// Default closed: an anonymous visitor may only ever see a widget whose\n\t// author said so. Refuse, rather than coerce, a value that is not a boolean:\n\t// \"yes\" must not quietly become true, or false.\n\tif (entry && entry.public !== undefined && typeof entry.public !== 'boolean') {\n\t\tthrow new TypeError(`[dashboardWidgetRegistry] widget type \"${type}\": \\`public\\` must be a boolean, got ${typeof entry.public}.`)\n\t}\n\tif (entry && entry.public === undefined) {\n\t\tif (Object.isExtensible(entry)) {\n\t\t\tentry.public = false\n\t\t} else {\n\t\t\tentry = { ...entry, public: false }\n\t\t}\n\t}\n\tconst isOverride = Object.hasOwn(dashboardWidgetRegistry, type)\n\t// Read through `globalThis` rather than a bare `process`: this module is\n\t// bundled for the browser, where `process` is simply absent, and the\n\t// optional chain states that as plainly as the old `typeof` guard did.\n\tconst env = globalThis.process?.env\n\tif (isOverride && env && env.NODE_ENV !== 'production') {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(`[dashboardWidgetRegistry] widget type \"${type}\" is already registered — overriding the previous entry (last-registration-wins).`)\n\t}\n\tdashboardWidgetRegistry[type] = entry\n}\n\n/**\n * List every registered widget type that has a usable form component. The\n * `CnAddWidgetModal` type picker calls this; renderer-only types (entries with\n * a null/undefined `form`) are excluded so the user is never offered a type\n * they cannot configure.\n *\n * @param {string} [surface] Optional surface key to filter by (default\n * `'app-dashboard'`). Entries whose `surfaces` excludes it are dropped, so a\n * detail-only type (e.g. `data`) never appears in the dashboard picker. Pass\n * the matching surface to list detail-page types.\n * @return {string[]} the registered type keys whose entry has a non-null form.\n */\nexport function listWidgetTypes(surface = 'app-dashboard') {\n\treturn Object.keys(dashboardWidgetRegistry).filter((type) => dashboardWidgetRegistry[type]\n\t\t&& dashboardWidgetRegistry[type].form !== null\n\t\t&& dashboardWidgetRegistry[type].form !== undefined\n\t\t&& widgetTypeAllowsSurface(dashboardWidgetRegistry[type], surface))\n}\n\n/**\n * List the widget types a USER may add to their own dashboard.\n *\n * 🔴 IT IS AN OPT-IN, AND THAT IS THE WHOLE POINT. `listWidgetTypes()` answers\n * what an administrator may put on a page for everybody, which is a much\n * larger set: an admin configures a widget once, with the register and schema\n * in front of them, and a user picking from the same list would be offered\n * types that need configuration they cannot supply and cannot be told about.\n * So a type is offerable to a user only when its registry entry says\n * `userAddable: true`.\n *\n * @param {string} [surface] The surface key, as {@link listWidgetTypes} uses it.\n * @return {string[]} The type keys a user may add themselves.\n */\nexport function listUserAddableWidgetTypes(surface = 'app-dashboard') {\n\treturn listWidgetTypes(surface).filter((type) => dashboardWidgetRegistry[type]?.userAddable === true)\n}\n\n/**\n * The presets a manifest offers a user, from `config.userWidgets[]`.\n *\n * A preset is a widget an app has already configured, offered under a name a\n * user recognises: \"one of my saved views\", \"my tasks\". It exists because the\n * registry types a user may add are deliberately few, and the two lists a user\n * actually wants are both `object-list` widgets that need a query the app\n * knows and the user does not.\n *\n * An entry with no `id` or no `kind` is dropped rather than offered: a preset\n * nobody can identify cannot be added, and one with no kind has nothing to\n * render.\n *\n * @param {object|null} config The page config.\n * @return {Array<{ id: string, kind: string, label: string, widget: object }>} The offerable presets.\n */\nexport function userWidgetPresets(config) {\n\tconst declared = config?.userWidgets\n\tif (!Array.isArray(declared)) {\n\t\treturn []\n\t}\n\n\tconst presets = []\n\tfor (const entry of declared) {\n\t\tconst id = String(entry?.id ?? '').trim()\n\t\tconst kind = String(entry?.kind ?? '').trim()\n\t\tif (id === '' || kind === '') {\n\t\t\tcontinue\n\t\t}\n\n\t\tpresets.push({\n\t\t\tid,\n\t\t\tkind,\n\t\t\tlabel: String(entry?.label ?? id),\n\t\t\t// The widget definition the app configured, copied so a caller\n\t\t\t// adding one twice does not hand the grid the same object twice.\n\t\t\twidget: { ...(entry?.widget || {}) },\n\t\t})\n\t}\n\n\treturn presets\n}\n\n/**\n * Whether a widget type may be mounted by a public host. False for an unknown\n * type: the decision and the lookup are one thing.\n *\n * @param {string} type the widget type key.\n * @return {boolean} true only for a registered entry with `public: true`.\n */\nexport function isPublicWidgetType(type) {\n\tconst entry = dashboardWidgetRegistry[type]\n\treturn Boolean(entry) && entry.public === true\n}\n\n/**\n * Look up a widget type entry; returns `null` when the type is unknown so the\n * caller can fall back gracefully.\n *\n * @param {string} type the widget type key.\n * @return {DashboardWidgetEntry|null} the registry entry or `null`.\n */\nexport function getWidgetTypeEntry(type) {\n\treturn dashboardWidgetRegistry[type] || null\n}\n\n/**\n * Whether a registry entry is offerable on a given surface. An entry with no\n * `surfaces` is offerable everywhere; otherwise the surface must be listed.\n *\n * @param {DashboardWidgetEntry} entry the registry entry.\n * @param {string} surface the surface key (e.g. `'app-dashboard'`, `'detail-page'`).\n * @return {boolean} true when the entry may be added on that surface.\n */\nexport function widgetTypeAllowsSurface(entry, surface) {\n\tif (!entry) {\n\t\treturn false\n\t}\n\tif (!Array.isArray(entry.surfaces) || entry.surfaces.length === 0) {\n\t\treturn true\n\t}\n\treturn entry.surfaces.includes(surface)\n}\n\n/**\n * Return a fresh copy of the `defaultContent` blob for a registered type, or\n * `{}` for unknown types so the caller never has to null-check. A shallow copy\n * is returned so a caller mutating the result does not pollute the registry\n * defaults or another caller's content.\n *\n * @param {string} type the widget type key.\n * @return {object} a fresh copy of the type's `defaultContent`.\n */\nexport function getDefaultContent(type) {\n\tconst entry = dashboardWidgetRegistry[type]\n\tif (!entry) {\n\t\treturn {}\n\t}\n\treturn { ...entry.defaultContent }\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,uBAAuB,GAAG;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,IAAI,EAAE,KAAK,EAAE;AACrD,CAAC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI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E;AACvC,GAAG;AACH,CAAC;;AAED,CAAC,OAAO;AACR;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,IAAI,EAAE;AACzC,CAAC,OAAO,uBAAuB,CAAC,IAAI,CAAC,IAAI;AACzC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE;AACxD,CAAC,IAAI,CAAC,KAAK,EAAE;AACb,EAAE,OAAO;AACT,CAAC;AACD,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;AACpE,EAAE,OAAO;AACT,CAAC;AACD,CAAC,OAAO,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,IAAI,EAAE;AACxC,CAAC,MAAM,KAAK,GAAG,uBAAuB,CAAC,IAAI;AAC3C,CAAC,IAAI,CAAC,KAAK,EAAE;AACb,EAAE,OAAO;AACT,CAAC;AACD,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,cAAc;AACjC;;"}
@@ -2,7 +2,7 @@ import script from './CnAddWidgetModal2.vue.js';
2
2
  import { render } from './CnAddWidgetModal3.vue.js';
3
3
 
4
4
  script.render = render;
5
- script.__scopeId = "data-v-057fc07c";
5
+ script.__scopeId = "data-v-626d5ba2";
6
6
  const __sfc_main = script;
7
7
 
8
8
  export { __sfc_main as default };
@@ -1,8 +1,9 @@
1
1
  import { translate } from '@nextcloud/l10n';
2
2
  import { NcNoteCard, NcCheckboxRadioSwitch, NcTextField, NcButton, NcDialog } from '@nextcloud/vue';
3
3
  import { provide, computed } from 'vue';
4
- import __sfc_main from '../components/CnColorPicker/CnColorPicker.vue.js';
5
- import __sfc_main$1 from '../components/CnIconBrowser/CnIconBrowser.vue.js';
4
+ import __sfc_main$1 from '../components/CnColorPicker/CnColorPicker.vue.js';
5
+ import __sfc_main$2 from '../components/CnIconBrowser/CnIconBrowser.vue.js';
6
+ import __sfc_main from '../components/CnWidgetGrid/CnWidgetIcon.vue.js';
6
7
  import { getWidgetTypeEntry, userWidgetPresets, listUserAddableWidgetTypes, listWidgetTypes } from '../components/CnWidgetGrid/dashboardWidgetRegistry.js';
7
8
  import { useWidgetForm } from '../composables/useWidgetForm.js';
8
9
 
@@ -27,8 +28,9 @@ var script = {
27
28
  NcTextField,
28
29
  NcCheckboxRadioSwitch,
29
30
  NcNoteCard,
30
- CnIconBrowser: __sfc_main$1,
31
- CnColorPicker: __sfc_main,
31
+ CnIconBrowser: __sfc_main$2,
32
+ CnColorPicker: __sfc_main$1,
33
+ CnWidgetIcon: __sfc_main,
32
34
  },
33
35
 
34
36
  props: {
@@ -654,6 +656,18 @@ var script = {
654
656
  const entry = getWidgetTypeEntry(type);
655
657
  return entry?.displayName || type
656
658
  },
659
+
660
+ /**
661
+ * The icon a registry type declares (an MDI name, SVG path or URL), or
662
+ * `null` for the default widget icon.
663
+ *
664
+ * @param {string} type the registry type key.
665
+ * @return {string|null} the icon.
666
+ */
667
+ typeIcon(type) {
668
+ const icon = getWidgetTypeEntry(type)?.icon;
669
+ return typeof icon === 'string' && icon !== '' ? icon : null
670
+ },
657
671
  },
658
672
  };
659
673
 
@@ -1 +1 @@
1
- {"version":3,"file":"CnAddWidgetModal2.vue.js","sources":["../../../src/dialogs/CnAddWidgetModal.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<NcDialog\n\t\tv-if=\"show\"\n\t\tsize=\"normal\"\n\t\t:name=\"modalTitle\"\n\t\t@closing=\"onCancel\">\n\t\t<!-- Type selector: shown only in pure-create mode (no preselected\n\t\t type, no editing widget). -->\n\t\t<div v-if=\"showTypeSelect\" class=\"cn-add-widget-modal__type\">\n\t\t\t<label class=\"cn-add-widget-modal__type-label\" :for=\"typeSelectId\">\n\t\t\t\t{{ t('nextcloud-vue', 'Widget type') }}\n\t\t\t</label>\n\t\t\t<select\n\t\t\t\t:id=\"typeSelectId\"\n\t\t\t\tv-model=\"state.type\"\n\t\t\t\tclass=\"cn-add-widget-modal__type-select\"\n\t\t\t\tdata-testid=\"widget-type-select\"\n\t\t\t\t@change=\"onTypeSwitch\">\n\t\t\t\t<option\n\t\t\t\t\tv-for=\"type in availableTypes\"\n\t\t\t\t\t:key=\"type\"\n\t\t\t\t\t:value=\"type\"\n\t\t\t\t\t:data-testid=\"`widget-type-option-${type}`\">\n\t\t\t\t\t{{ typeDisplayName(type) }}\n\t\t\t\t</option>\n\t\t\t</select>\n\t\t</div>\n\n\t\t<!-- Notices about the widget being edited, from the host: a finding\n\t\t the host made about its configuration (non-fatal), above the form. -->\n\t\t<div\n\t\t\tv-if=\"notices.length > 0 || $slots.notices\"\n\t\t\tclass=\"cn-add-widget-modal__notices\"\n\t\t\tdata-testid=\"cn-add-widget-modal-notices\">\n\t\t\t<!-- @slot Extra notices above the form; replaces nothing, follows the `notices` prop. -->\n\t\t\t<NcNoteCard\n\t\t\t\tv-for=\"(notice, index) in notices\"\n\t\t\t\t:key=\"notice.id || index\"\n\t\t\t\t:type=\"noticeType(notice)\"\n\t\t\t\t:text=\"notice.text\"\n\t\t\t\tdata-testid=\"cn-add-widget-modal-notice\" />\n\t\t\t<slot name=\"notices\" />\n\t\t</div>\n\n\t\t<!-- Active per-type sub-form. Driven by `<component :is>` from the\n\t\t shared registry; sub-forms expose `validate()` and either an\n\t\t `assembledContent` getter or `@update:content` events. -->\n\t\t<div v-if=\"activeSubFormComponent\" class=\"cn-add-widget-modal__form\">\n\t\t\t<component\n\t\t\t\t:is=\"activeSubFormComponent\"\n\t\t\t\tref=\"activeSubForm\"\n\t\t\t\t:key=\"state.type\"\n\t\t\t\t:editingWidget=\"state.editingWidget\"\n\t\t\t\t:value=\"state.content\"\n\t\t\t\t:fileUploadFn=\"fileUploadFn\"\n\t\t\t\t:calendarsFetcher=\"calendarsFetcher\"\n\t\t\t\t@update:content=\"onContentUpdate\" />\n\t\t</div>\n\t\t<div v-else class=\"cn-add-widget-modal__empty\">\n\t\t\t{{ t('nextcloud-vue', 'No widget types available') }}\n\t\t</div>\n\n\t\t<!-- Widget appearance (chrome): title, background, icon. Shared with\n\t\t every consumer so the add/edit experience is identical across apps\n\t\t (the chrome rides alongside `content` in the submit payload). -->\n\t\t<div v-if=\"activeSubFormComponent\" class=\"cn-add-widget-modal__chrome\">\n\t\t\t<h3 class=\"cn-add-widget-modal__chrome-title\">\n\t\t\t\t{{ t('nextcloud-vue', 'Appearance') }}\n\t\t\t</h3>\n\t\t\t<!-- Title chrome is hidden for types whose sub-form owns the title\n\t\t\t (e.g. the data widget's own Title field) so there aren't two\n\t\t\t title inputs. -->\n\t\t\t<template v-if=\"!activeTypeOwnsTitle\">\n\t\t\t\t<NcCheckboxRadioSwitch\n\t\t\t\t\t:modelValue=\"chrome.showTitle\"\n\t\t\t\t\t@update:modelValue=\"chrome.showTitle = $event\">\n\t\t\t\t\t{{ t('nextcloud-vue', 'Show title') }}\n\t\t\t\t</NcCheckboxRadioSwitch>\n\t\t\t\t<NcTextField\n\t\t\t\t\tv-if=\"chrome.showTitle\"\n\t\t\t\t\t:modelValue=\"chrome.customTitle\"\n\t\t\t\t\t:label=\"t('nextcloud-vue', 'Custom title')\"\n\t\t\t\t\t@update:modelValue=\"chrome.customTitle = $event\" />\n\t\t\t</template>\n\t\t\t<div class=\"cn-add-widget-modal__chrome-row\">\n\t\t\t\t<span class=\"cn-add-widget-modal__chrome-label\">{{ t('nextcloud-vue', 'Background') }}</span>\n\t\t\t\t<CnColorPicker\n\t\t\t\t\t:value=\"chrome.backgroundColor\"\n\t\t\t\t\tclearable\n\t\t\t\t\t@input=\"chrome.backgroundColor = $event.hex\"\n\t\t\t\t\t@clear=\"chrome.backgroundColor = ''\" />\n\t\t\t\t<span class=\"cn-add-widget-modal__chrome-value\">\n\t\t\t\t\t{{ chrome.backgroundColor || t('nextcloud-vue', 'Default') }}\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t\t<div class=\"cn-add-widget-modal__chrome-row\">\n\t\t\t\t<span class=\"cn-add-widget-modal__chrome-label\">{{ t('nextcloud-vue', 'Icon') }}</span>\n\t\t\t\t<CnIconBrowser\n\t\t\t\t\t:value=\"chrome.customIcon\"\n\t\t\t\t\t:uploadFn=\"uploadFn\"\n\t\t\t\t\tallowUrl\n\t\t\t\t\tclearable\n\t\t\t\t\t@input=\"chrome.customIcon = $event\" />\n\t\t\t</div>\n\t\t</div>\n\n\t\t<template #actions>\n\t\t\t<NcButton variant=\"tertiary\" :disabled=\"submitting\" @click=\"onCancel\">\n\t\t\t\t{{ t('nextcloud-vue', 'Cancel') }}\n\t\t\t</NcButton>\n\t\t\t<NcButton\n\t\t\t\tvariant=\"primary\"\n\t\t\t\t:disabled=\"!canSubmit || submitting\"\n\t\t\t\t:title=\"firstError || ''\"\n\t\t\t\tdata-testid=\"add-widget-save\"\n\t\t\t\t@click=\"onSubmit\">\n\t\t\t\t{{ submitLabel }}\n\t\t\t</NcButton>\n\t\t</template>\n\t</NcDialog>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcCheckboxRadioSwitch, NcDialog, NcNoteCard, NcTextField } from '@nextcloud/vue'\nimport { computed, provide } from 'vue'\nimport CnColorPicker from '../components/CnColorPicker/CnColorPicker.vue'\nimport CnIconBrowser from '../components/CnIconBrowser/CnIconBrowser.vue'\nimport {\n\tgetWidgetTypeEntry,\n\tlistUserAddableWidgetTypes,\n\tlistWidgetTypes,\n\tuserWidgetPresets,\n} from '../components/CnWidgetGrid/dashboardWidgetRegistry.js'\nimport { useWidgetForm } from '../composables/useWidgetForm.js'\n\nlet titleIdCounter = 0\nlet selectIdCounter = 0\n\n/**\n * CnAddWidgetModal — unified, isolated host (ADR-004) for both the \"add a\n * dashboard widget\" and \"edit a dashboard widget\" flows. The modal does NO API\n * and NO grid work itself; it emits `submit({type, content})` for the parent to\n * persist. Per-type fields live in sub-form components registered in the shared\n * `dashboardWidgetRegistry`.\n *\n * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n */\nexport default {\n\tname: 'CnAddWidgetModal',\n\n\tcomponents: {\n\t\tNcDialog,\n\t\tNcButton,\n\t\tNcTextField,\n\t\tNcCheckboxRadioSwitch,\n\t\tNcNoteCard,\n\t\tCnIconBrowser,\n\t\tCnColorPicker,\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * Toggles visibility. Going `false → true` triggers `resetForm()` (or\n\t\t * `loadEditingWidget()` when `editingWidget` is set).\n\t\t */\n\t\tshow: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * When set, the type `<select>` is hidden and the form opens directly\n\t\t * on this type (toolbar deep-links).\n\t\t */\n\t\tpreselectedType: {\n\t\t\ttype: String,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/**\n\t\t * When set, the modal opens in edit mode: the type select is hidden\n\t\t * (placement type is immutable) and the sub-form is pre-filled from\n\t\t * `editingWidget.content`. Must expose `type` and `content`.\n\t\t *\n\t\t * @type {{type: string, 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 * Optional upload transport for the Appearance icon picker:\n\t\t * `async (dataUrl: string) => ({ url })`. The icon picker reads the chosen\n\t\t * file to a data URL and passes that string here. When null, the upload\n\t\t * control is hidden and the picker still offers its catalogues, NL sets,\n\t\t * and a URL field.\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\n\t\t/**\n\t\t * Optional raw-file upload transport forwarded to the active sub-form as\n\t\t * its `file-upload-fn`: `async (file: File) => ({ url })`. Deliberately a\n\t\t * separate prop from `uploadFn` (which the icon picker calls with a data\n\t\t * URL) so the File-typed transport can never reach a sub-form that expects\n\t\t * a data URL (e.g. `CnHeaderWidgetForm.uploadFn`). Sub-forms such as the\n\t\t * image widget defer the upload to submit and hand over the raw `File`.\n\t\t * When null, sub-forms fall back to their own no-transport behaviour.\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 * Optional async fetcher returning the user's calendars\n\t\t * (`[{key, name, color}]`) for the calendar widget's picker. Provided\n\t\t * by the consuming app (which owns the calendar backend); when null the\n\t\t * calendar form falls back to free-text principal entry.\n\t\t *\n\t\t * @type {(() => Promise<Array<{key: string, name: string, color: string}>>)|null}\n\t\t */\n\t\tcalendarsFetcher: {\n\t\t\ttype: Function,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/**\n\t\t * Non-fatal notices about the widget, shown above its form: what the\n\t\t * host found about its configuration, e.g. a filter dimension the\n\t\t * dashboard does not publish. Each is `{ text, type?, id? }`, `type`\n\t\t * one of `warning` (default), `info`, `error`, `success`.\n\t\t *\n\t\t * @type {Array<{text: string, type?: string, id?: string}>}\n\t\t * @spec openspec/changes/add-widget-modal-notices/specs/add-widget-modal-notices/spec.md#requirement-the-widget-dialog-can-show-the-hosts-notices\n\t\t */\n\t\tnotices: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => [],\n\t\t},\n\n\t\t/**\n\t\t * The surface the picker offers types for. `'detail-page'` surfaces\n\t\t * detail-only types (e.g. a second `data` widget) alongside the universal\n\t\t * widgets; the default `'app-dashboard'` lists the dashboard set. Types\n\t\t * with no declared `surfaces` appear on every surface.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\tsurface: {\n\t\t\ttype: String,\n\t\t\tdefault: 'app-dashboard',\n\t\t},\n\n\t\t/**\n\t\t * Whether this picker is being opened BY A USER for their own\n\t\t * dashboard, rather than by an administrator editing the page for\n\t\t * everybody. It narrows the type list to `userAddable` entries and\n\t\t * turns on the manifest presets.\n\t\t *\n\t\t * @type {boolean}\n\t\t */\n\t\tuserAddableOnly: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * The hosting page's config, read for `userWidgets[]` when\n\t\t * `userAddableOnly` is on.\n\t\t *\n\t\t * @type {object|null}\n\t\t */\n\t\tpageConfig: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/**\n\t\t * Authoritative object context `{ register, schema }` for the page hosting\n\t\t * the picker (supplied by the Buildiq edit button from the ACTIVE page's\n\t\t * config). Provided down as `cnObjectContext` so the data sub-form resolves\n\t\t * the right schema even though the modal teleports out of the page's\n\t\t * ambient provide tree. Null on surfaces without a single object (e.g.\n\t\t * dashboards).\n\t\t *\n\t\t * @type {{register: string, schema: string}|null}\n\t\t */\n\t\tdataContext: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\temits: [\n\t\t/** Fired on cancel button, backdrop click, or Esc key. */\n\t\t'close',\n\t\t/** Fired with the assembled `{type, content}` payload for the parent to persist. */\n\t\t'submit',\n\t],\n\n\tsetup(props) {\n\t\t// One composable instance per modal mount. The composable owns the\n\t\t// type/content/editingWidget reactive state shared with sub-forms.\n\t\tconst form = useWidgetForm()\n\t\t// Publish the page's object context to the (teleported) sub-forms so the\n\t\t// data widget's property editor loads the ACTIVE page's schema, not\n\t\t// whatever ambient context the modal lands next to in the DOM.\n\t\tprovide('cnObjectContext', computed(() => props.dataContext || null))\n\t\treturn { form }\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\t// Re-validation tick: `isValid` must recompute every time the\n\t\t\t// active sub-form's input changes. Sub-forms emit `update:content`\n\t\t\t// on every keystroke; we bump this counter in the handler so the\n\t\t\t// computed re-runs.\n\t\t\tvalidationTick: 0,\n\t\t\t// Snapshot of the assembled content + chrome captured when the modal\n\t\t\t// opens; `isDirty` compares the live values against it so editing an\n\t\t\t// existing widget only enables Save once something actually changed.\n\t\t\tinitialSnapshot: '',\n\t\t\ttitleId: `cn-add-widget-modal-title-${++titleIdCounter}`,\n\t\t\ttypeSelectId: `cn-add-widget-modal-type-${++selectIdCounter}`,\n\t\t\t// Widget chrome (title / background / icon) edited in the same modal\n\t\t\t// as the per-type content and emitted back under `payload.chrome`.\n\t\t\tchrome: { showTitle: true, customTitle: '', backgroundColor: '', customIcon: '' },\n\t\t\t// True while the sub-form's commit() (e.g. an image upload) runs on\n\t\t\t// submit, so both footer buttons disable and the label shows progress.\n\t\t\tsubmitting: false,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The shared form state container ({type, content, editingWidget}).\n\t\t *\n\t\t * @return {{type: string, content: object, editingWidget: (object|null)}} the reactive state.\n\t\t */\n\t\tstate() {\n\t\t\treturn this.form.state\n\t\t},\n\n\t\t/**\n\t\t * Type keys the picker offers — only registry entries that have a form.\n\t\t *\n\t\t * @return {string[]} the form-bearing type keys.\n\t\t */\n\t\tavailableTypes() {\n\t\t\t// A USER PICKING FOR THEMSELVES IS OFFERED A SMALLER LIST. An\n\t\t\t// administrator configures a widget once with the register and\n\t\t\t// schema in front of them; a user has neither and cannot be told\n\t\t\t// about them, so they see only the types whose registry entry\n\t\t\t// declares `userAddable`.\n\t\t\treturn this.userAddableOnly\n\t\t\t\t? listUserAddableWidgetTypes(this.surface)\n\t\t\t\t: listWidgetTypes(this.surface)\n\t\t},\n\n\t\t/**\n\t\t * The presets this page offers a user, from `config.userWidgets[]`.\n\t\t *\n\t\t * @return {Array<object>} The offerable presets.\n\t\t */\n\t\tavailablePresets() {\n\t\t\treturn this.userAddableOnly ? userWidgetPresets(this.pageConfig) : []\n\t\t},\n\n\t\t/**\n\t\t * Whether the active type's sub-form owns the widget title (declares\n\t\t * `ownsTitle` in its registry entry). When true the modal hides its\n\t\t * generic Title chrome so there aren't two title inputs.\n\t\t *\n\t\t * @return {boolean} true when the sub-form provides its own title field.\n\t\t */\n\t\tactiveTypeOwnsTitle() {\n\t\t\tconst entry = getWidgetTypeEntry(this.state.type)\n\t\t\treturn !!(entry && entry.ownsTitle)\n\t\t},\n\n\t\t/**\n\t\t * Whether to show the type select (hidden in edit / preselected mode).\n\t\t *\n\t\t * @return {boolean} true only in pure-create mode.\n\t\t */\n\t\tshowTypeSelect() {\n\t\t\treturn !this.editingWidget && !this.preselectedType\n\t\t},\n\n\t\t/**\n\t\t * The Vue component to mount via `<component :is>` for the active type,\n\t\t * or `null` when the type is unknown or renderer-only.\n\t\t *\n\t\t * @return {object|null} the active sub-form component reference.\n\t\t */\n\t\tactiveSubFormComponent() {\n\t\t\tconst entry = getWidgetTypeEntry(this.state.type)\n\t\t\treturn entry?.form || null\n\t\t},\n\n\t\t/**\n\t\t * Modal heading — flips between Add and Edit based on edit mode.\n\t\t *\n\t\t * @return {string} the localised modal title.\n\t\t */\n\t\tmodalTitle() {\n\t\t\treturn this.editingWidget\n\t\t\t\t? t('nextcloud-vue', 'Edit Widget')\n\t\t\t\t: t('nextcloud-vue', 'Add Widget')\n\t\t},\n\n\t\t/**\n\t\t * Submit button label — flips between Add and Save based on edit mode.\n\t\t *\n\t\t * @return {string} the localised submit label.\n\t\t *\n\t\t * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n\t\t */\n\t\tsubmitLabel() {\n\t\t\tif (this.submitting) {\n\t\t\t\treturn t('nextcloud-vue', 'Uploading…')\n\t\t\t}\n\t\t\treturn this.editingWidget ? t('nextcloud-vue', 'Save') : t('nextcloud-vue', 'Add')\n\t\t},\n\n\t\t/**\n\t\t * The active sub-form's validation errors. `validationTick` keeps Vue's\n\t\t * dependency tracker aware that this computed re-runs on every input.\n\t\t *\n\t\t * @return {string[]} the validation error messages.\n\t\t */\n\t\tvalidationErrors() {\n\t\t\t// Read the tick, discard the value: `$refs` is not reactive, so the\n\t\t\t// tick is what Vue can track as this computed's dependency.\n\t\t\tvoid this.validationTick\n\t\t\treturn this.form.validate(this.$refs.activeSubForm)\n\t\t},\n\n\t\t/**\n\t\t * Whether the submit button is enabled (no validation errors).\n\t\t *\n\t\t * @return {boolean} true when the active sub-form is valid.\n\t\t */\n\t\tisValid() {\n\t\t\treturn this.validationErrors.length === 0\n\t\t},\n\n\t\t/**\n\t\t * Whether the content or chrome differs from the snapshot taken when the\n\t\t * modal opened. Depends on `chrome` (via the snapshot's JSON) and the\n\t\t * `validationTick` (bumped on every sub-form `update:content`) so it\n\t\t * re-runs on both chrome and form-field edits.\n\t\t *\n\t\t * @return {boolean} true when something changed since open.\n\t\t */\n\t\tisDirty() {\n\t\t\t// Read the tick, discard the value, so content edits re-run this.\n\t\t\tvoid this.validationTick\n\t\t\treturn this.currentSnapshot() !== this.initialSnapshot\n\t\t},\n\n\t\t/**\n\t\t * Whether Save is allowed: the form must be valid, and — when editing an\n\t\t * existing widget — something must have changed. Create mode may submit\n\t\t * the (valid) defaults straight away.\n\t\t *\n\t\t * @return {boolean} true when the submit button is enabled.\n\t\t */\n\t\tcanSubmit() {\n\t\t\tif (!this.isValid) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn !this.editingWidget || this.isDirty\n\t\t},\n\n\t\t/**\n\t\t * The first user-visible validation error (hides the internal\n\t\t * `__no-active-form__` sentinel).\n\t\t *\n\t\t * @return {string} the first error message, or an empty string.\n\t\t */\n\t\tfirstError() {\n\t\t\tconst err = this.validationErrors[0]\n\t\t\treturn err && err !== '__no-active-form__' ? err : ''\n\t\t},\n\t},\n\n\twatch: {\n\t\t/**\n\t\t * Re-initialise the form when the modal opens.\n\t\t *\n\t\t * @param {boolean} isOpen the new `show` value.\n\t\t * @return {void}\n\t\t */\n\t\tshow(isOpen) {\n\t\t\tif (isOpen) {\n\t\t\t\tthis.openLifecycle()\n\t\t\t}\n\t\t},\n\n\t\teditingWidget: {\n\t\t\timmediate: false,\n\t\t\t/**\n\t\t\t * Pre-fill from a newly-supplied editing widget while open.\n\t\t\t *\n\t\t\t * @param {object|null} widget the placement being edited.\n\t\t\t * @return {void}\n\t\t\t */\n\t\t\thandler(widget) {\n\t\t\t\tif (this.show && widget) {\n\t\t\t\t\tthis.form.loadEditingWidget(widget)\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\n\t\t/**\n\t\t * Re-seed the form when the preselected type changes while open.\n\t\t *\n\t\t * @param {string|null} type the new preselected type.\n\t\t * @return {void}\n\t\t */\n\t\tpreselectedType(type) {\n\t\t\tif (this.show && type && !this.editingWidget) {\n\t\t\t\tthis.form.resetForm(type)\n\t\t\t}\n\t\t},\n\t},\n\n\tcreated() {\n\t\t// Seed state synchronously before the first render so the\n\t\t// `v-if=\"activeSubFormComponent\"` path resolves to the right sub-form\n\t\t// on initial mount (otherwise the modal flashes the \"No widget types\n\t\t// available\" empty state for one tick).\n\t\tif (this.show) {\n\t\t\tthis.openLifecycle()\n\t\t}\n\t},\n\n\tmounted() {\n\t\tdocument.addEventListener('keydown', this.onKeydown)\n\t\t// The validation gate reads `$refs.activeSubForm`, which is null while\n\t\t// `created()` runs (the sub-form mounts after the first render). Bump\n\t\t// the tick once the ref is bound so `isValid` reflects the freshly\n\t\t// mounted sub-form's `validate()` without waiting for the first input.\n\t\tthis.$nextTick(() => {\n\t\t\tthis.validationTick++\n\t\t})\n\t},\n\n\tbeforeUnmount() {\n\t\tdocument.removeEventListener('keydown', this.onKeydown)\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * The note card type of a notice: its own when known, else `warning`.\n\t\t *\n\t\t * @param {{type?: string}} notice The notice.\n\t\t * @return {string}\n\t\t * @spec openspec/changes/add-widget-modal-notices/specs/add-widget-modal-notices/spec.md#requirement-the-widget-dialog-can-show-the-hosts-notices\n\t\t */\n\t\tnoticeType(notice) {\n\t\t\treturn ['warning', 'info', 'error', 'success'].includes(notice && notice.type) ? notice.type : 'warning'\n\t\t},\n\n\t\tt,\n\n\t\t/**\n\t\t * Initialise form state when the modal opens. Edit mode pre-fills from\n\t\t * `editingWidget`; create mode resets to the preselected type (toolbar\n\t\t * invocation) or to the first available registered type.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\topenLifecycle() {\n\t\t\tif (this.editingWidget) {\n\t\t\t\tthis.form.loadEditingWidget(this.editingWidget)\n\t\t\t\tthis.seedChrome(this.editingWidget)\n\t\t\t} else {\n\t\t\t\tconst initialType = this.preselectedType\n\t\t\t\t\t|| this.availableTypes[0]\n\t\t\t\t\t|| ''\n\t\t\t\tthis.form.resetForm(initialType)\n\t\t\t\tthis.seedChrome(null)\n\t\t\t}\n\t\t\t// Revalidate on every open (the modal instance persists across\n\t\t\t// open/close, so `mounted()`'s one-time bump doesn't fire again).\n\t\t\t// Bump synchronously and again once the sub-form has (re)mounted and\n\t\t\t// its `$refs.activeSubForm` is bound — otherwise the submit gate stays\n\t\t\t// stale in edit mode until the user touches a form field. The nextTick\n\t\t\t// pass also captures the pristine snapshot `isDirty` compares against.\n\t\t\tthis.validationTick++\n\t\t\tthis.$nextTick(() => {\n\t\t\t\tthis.validationTick++\n\t\t\t\tthis.initialSnapshot = this.currentSnapshot()\n\t\t\t})\n\t\t},\n\n\t\t/**\n\t\t * Serialise the current assembled content + chrome for dirty comparison.\n\t\t *\n\t\t * @return {string} a stable JSON snapshot of the editable state.\n\t\t */\n\t\tcurrentSnapshot() {\n\t\t\tconst { content } = this.form.assembleContent(this.$refs.activeSubForm)\n\t\t\treturn JSON.stringify({ content, chrome: this.chrome })\n\t\t},\n\n\t\t/**\n\t\t * Seed the Appearance controls (title / background / icon) from a\n\t\t * placement being edited, or to defaults in create mode. Reads chrome\n\t\t * fields from the placement's top level with a fallback to its `content`\n\t\t * (and `styleConfig.backgroundColor`), so it round-trips whatever shape\n\t\t * the consumer persists.\n\t\t *\n\t\t * @param {object|null} widget The placement being edited, or null.\n\t\t * @return {void}\n\t\t */\n\t\tseedChrome(widget) {\n\t\t\tconst w = widget || {}\n\t\t\tconst c = (w.content && typeof w.content === 'object') ? w.content : {}\n\t\t\tconst pick = (...vals) => vals.find((v) => v !== undefined && v !== null)\n\t\t\tconst showRaw = pick(w.showTitle, c.showTitle)\n\t\t\tthis.chrome = {\n\t\t\t\t// Cards (stat / gauge / delta) headline themselves via `content.label`,\n\t\t\t\t// so they default headerless — otherwise the chrome header just repeats\n\t\t\t\t// the label, or shows the bare type name when no title was ever set.\n\t\t\t\tshowTitle: showRaw === undefined\n\t\t\t\t\t? !this.isCardType(w.type || this.state.type)\n\t\t\t\t\t: Boolean(Number(showRaw) || showRaw === true),\n\n\t\t\t\tcustomTitle: pick(w.customTitle, c.customTitle, c.title) || '',\n\t\t\t\tbackgroundColor: pick(w.backgroundColor, w.styleConfig?.backgroundColor, c.styleConfig?.backgroundColor) || '',\n\t\t\t\tcustomIcon: pick(w.customIcon, c.customIcon, c.icon) || '',\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Handle a `<select>` change: swap the active sub-form and reset its\n\t\t * state to defaults. Switching type discards any in-progress field\n\t\t * input. The sub-form is keyed on `state.type`, so changing the type\n\t\t * tears down the old `<component :is>` and remounts a new one;\n\t\t * `$refs.activeSubForm` is briefly null between teardown and mount, so\n\t\t * we bump the tick again on the next tick once the ref is rebound.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\tonTypeSwitch() {\n\t\t\tthis.form.resetForm(this.state.type)\n\t\t\t// Re-apply the type's chrome default: switching between a card and a\n\t\t\t// full widget flips whether a header makes sense.\n\t\t\tthis.chrome.showTitle = !this.isCardType(this.state.type)\n\t\t\tthis.validationTick++\n\t\t\tthis.$nextTick(() => {\n\t\t\t\tthis.validationTick++\n\t\t\t})\n\t\t},\n\n\t\t/**\n\t\t * Whether a widget type is a self-contained card (stat / gauge / delta),\n\t\t * which renders headerless by default.\n\t\t *\n\t\t * @param {string} type the registry type key.\n\t\t * @return {boolean} true when the registry entry is a card.\n\t\t */\n\t\tisCardType(type) {\n\t\t\tif (!type) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tconst entry = getWidgetTypeEntry(type)\n\t\t\treturn Boolean(entry && entry.card === true)\n\t\t},\n\n\t\t/**\n\t\t * Mirror a sub-form `update:content` payload into the composable state\n\t\t * (so `assembleContent()` can fall back to it) and bump the validation\n\t\t * tick so the submit button enables/disables reactively on input.\n\t\t *\n\t\t * @param {object} content the sub-form's current content payload.\n\t\t * @return {void}\n\t\t */\n\t\tonContentUpdate(content) {\n\t\t\tthis.state.content = { ...content }\n\t\t\tthis.validationTick++\n\t\t},\n\n\t\t/**\n\t\t * Cancel button / backdrop / NcModal `close` event — non-destructive,\n\t\t * never emits submit. Suppressed while a sub-form `commit()` (e.g. an\n\t\t * image upload) is in flight so dismissing the dialog can't unmount the\n\t\t * sub-form mid-upload (which would orphan the upload and write into a\n\t\t * destroyed instance).\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\tonCancel() {\n\t\t\tif (this.submitting) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.$emit('close')\n\t\t},\n\n\t\t/**\n\t\t * Esc-key fallback listener (in case NcModal's own handler is\n\t\t * suppressed by a parent focus-trap). Emits `close`, never `submit`.\n\t\t * Suppressed while a commit() is in flight (see `onCancel`).\n\t\t *\n\t\t * @param {KeyboardEvent} event the keydown 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\tonKeydown(event) {\n\t\t\tif (this.submitting) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (this.show && event.key === 'Escape') {\n\t\t\t\tthis.$emit('close')\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Commit the active sub-form (e.g. upload a pending image), then build\n\t\t * the `{type, content}` payload via the composable's `assembleContent()`\n\t\t * and emit it. The commit is the only step that can hit the network; a\n\t\t * commit failure keeps the modal open and blocks the `submit` emit.\n\t\t *\n\t\t * @return {Promise<void>} resolves once submit is emitted or aborted.\n\t\t *\n\t\t * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n\t\t */\n\t\tasync onSubmit() {\n\t\t\tif (!this.isValid || this.submitting) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst subForm = this.$refs.activeSubForm\n\t\t\tif (subForm && typeof subForm.commit === 'function') {\n\t\t\t\tthis.submitting = true\n\t\t\t\ttry {\n\t\t\t\t\tawait subForm.commit()\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// The sub-form surfaces its own inline error; keep the modal\n\t\t\t\t\t// open so the author can retry or pick another file.\n\t\t\t\t\t// eslint-disable-next-line no-console -- diagnostic for a failure this code already degrades from\n\t\t\t\t\tconsole.error('[CnAddWidgetModal] Widget commit failed:', error)\n\t\t\t\t\treturn\n\t\t\t\t} finally {\n\t\t\t\t\tthis.submitting = false\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst payload = this.form.assembleContent(this.$refs.activeSubForm)\n\t\t\t// Carry the chrome (title / background / icon) alongside the content\n\t\t\t// so the parent persists both from this single modal.\n\t\t\tpayload.chrome = {\n\t\t\t\tshowTitle: this.chrome.showTitle,\n\t\t\t\tcustomTitle: this.chrome.customTitle,\n\t\t\t\tcustomIcon: this.chrome.customIcon,\n\t\t\t\tbackgroundColor: this.chrome.backgroundColor,\n\t\t\t}\n\t\t\tthis.$emit('submit', payload)\n\t\t},\n\n\t\t/**\n\t\t * Look up the human-readable display name for a registry type, falling\n\t\t * back to the type key itself.\n\t\t *\n\t\t * @param {string} type the registry type key.\n\t\t * @return {string} the display name.\n\t\t */\n\t\ttypeDisplayName(type) {\n\t\t\tconst entry = getWidgetTypeEntry(type)\n\t\t\treturn entry?.displayName || type\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-add-widget-modal__type {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 6px;\n}\n\n.cn-add-widget-modal__type-label {\n\tfont-size: 14px;\n\tfont-weight: 500;\n}\n\n.cn-add-widget-modal__type-select {\n\tpadding: 8px 12px;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n\tbackground: var(--color-main-background);\n\tcolor: var(--color-main-text);\n\tfont-size: 14px;\n}\n\n.cn-add-widget-modal__form {\n\toverflow-y: auto;\n\t/* Prefer a roomy ~340px for the type-specific fields (data-driven widgets\n\t carry tall forms — columns, thresholds, data source); still shrinks with\n\t its own scroll on short viewports so the Appearance + actions stay visible. */\n\tflex: 1 1 340px;\n\tmin-height: 0;\n}\n\n.cn-add-widget-modal__empty {\n\tpadding: 16px;\n\ttext-align: center;\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-add-widget-modal__chrome {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 10px;\n\tborder-top: 1px solid var(--color-border);\n\tpadding-top: 12px;\n}\n\n.cn-add-widget-modal__chrome-title {\n\tmargin: 0;\n\tfont-size: 15px;\n\tfont-weight: 600;\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-add-widget-modal__chrome-row {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 12px;\n}\n\n.cn-add-widget-modal__chrome-label {\n\tmin-width: 96px;\n\tfont-size: 14px;\n}\n\n.cn-add-widget-modal__chrome-value {\n\tfont-size: 13px;\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-add-widget-modal__notices {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n\tmargin-block-end: 12px;\n}\n</style>\n"],"names":["CnIconBrowser","CnColorPicker","t"],"mappings":";;;;;;;;AA6IA,IAAI,iBAAiB;AACrB,IAAI,kBAAkB;;AAEtB;;AAEC;AACA;AACA;;AAEA;AACA;;AAED,aAAe;CACd,IAAI,EAAE,kBAAkB;;CAExB,UAAU,EAAE;AACX,EAAA,QAAQ;AACR,EAAA,QAAQ;EACR,WAAW;AACX,EAAA,qBAAqB;EACrB,UAAU;iBACVA,YAAa;iBACbC,UAAa;EACb;;AAED,CA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CAAA,CAAE,OAAO,KAAK,EAAE;;AAEf;AACA;KACA,OAAO,CAAC,KAAK,CAAC,0CAA0C,EAAE,KAAK;KAC/D;AACD,IAAA,CAAA,SAAU;AACT,KAAA,IAAI,CAAC,UAAS,GAAI;AACnB,IAAA;AACD,GAAA;AACA,GAAA,MAAM,OAAM,GAAI,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa;;AAElE;AACA,GAAA,OAAO,CAAC,SAAS;AAChB,IAAA,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;AAChC,IAAA,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;AACpC,IAAA,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;AAClC,IAAA,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe;AAC7C;GACA,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO;EAC7B,CAAC;;AAED;;;AAGC;AACA;AACA;;AAED,EAAA,eAAe,CAAC,IAAI,EAAE;AACrB,GAAA,MAAM,KAAI,GAAI,kBAAkB,CAAC,IAAI;GACrC,OAAO,KAAK,EAAE,WAAU,IAAK;EAC9B,CAAC;EACD;AACF;;"}
1
+ {"version":3,"file":"CnAddWidgetModal2.vue.js","sources":["../../../src/dialogs/CnAddWidgetModal.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<NcDialog\n\t\tv-if=\"show\"\n\t\tsize=\"normal\"\n\t\t:name=\"modalTitle\"\n\t\t@closing=\"onCancel\">\n\t\t<!-- Type selector: shown only in pure-create mode (no preselected\n\t\t type, no editing widget). -->\n\t\t<div v-if=\"showTypeSelect\" class=\"cn-add-widget-modal__type\">\n\t\t\t<label class=\"cn-add-widget-modal__type-label\" :for=\"typeSelectId\">\n\t\t\t\t{{ t('nextcloud-vue', 'Widget type') }}\n\t\t\t</label>\n\t\t\t<!-- A native option cannot draw an icon, so the chosen type's\n\t\t\t icon stands in front of the select. -->\n\t\t\t<div class=\"cn-add-widget-modal__type-row\">\n\t\t\t\t<span\n\t\t\t\t\tv-if=\"state.type\"\n\t\t\t\t\tclass=\"cn-add-widget-modal__type-icon\"\n\t\t\t\t\tdata-testid=\"widget-type-icon\"\n\t\t\t\t\taria-hidden=\"true\">\n\t\t\t\t\t<CnWidgetIcon :name=\"typeIcon(state.type)\" :size=\"20\" />\n\t\t\t\t</span>\n\t\t\t\t<select\n\t\t\t\t\t:id=\"typeSelectId\"\n\t\t\t\t\tv-model=\"state.type\"\n\t\t\t\t\tclass=\"cn-add-widget-modal__type-select\"\n\t\t\t\t\tdata-testid=\"widget-type-select\"\n\t\t\t\t\t@change=\"onTypeSwitch\">\n\t\t\t\t\t<option\n\t\t\t\t\t\tv-for=\"type in availableTypes\"\n\t\t\t\t\t\t:key=\"type\"\n\t\t\t\t\t\t:value=\"type\"\n\t\t\t\t\t\t:data-testid=\"`widget-type-option-${type}`\">\n\t\t\t\t\t\t{{ typeDisplayName(type) }}\n\t\t\t\t\t</option>\n\t\t\t\t</select>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<!-- Notices about the widget being edited, from the host: a finding\n\t\t the host made about its configuration (non-fatal), above the form. -->\n\t\t<div\n\t\t\tv-if=\"notices.length > 0 || $slots.notices\"\n\t\t\tclass=\"cn-add-widget-modal__notices\"\n\t\t\tdata-testid=\"cn-add-widget-modal-notices\">\n\t\t\t<!-- @slot Extra notices above the form; replaces nothing, follows the `notices` prop. -->\n\t\t\t<NcNoteCard\n\t\t\t\tv-for=\"(notice, index) in notices\"\n\t\t\t\t:key=\"notice.id || index\"\n\t\t\t\t:type=\"noticeType(notice)\"\n\t\t\t\t:text=\"notice.text\"\n\t\t\t\tdata-testid=\"cn-add-widget-modal-notice\" />\n\t\t\t<slot name=\"notices\" />\n\t\t</div>\n\n\t\t<!-- Active per-type sub-form. Driven by `<component :is>` from the\n\t\t shared registry; sub-forms expose `validate()` and either an\n\t\t `assembledContent` getter or `@update:content` events. -->\n\t\t<div v-if=\"activeSubFormComponent\" class=\"cn-add-widget-modal__form\">\n\t\t\t<component\n\t\t\t\t:is=\"activeSubFormComponent\"\n\t\t\t\tref=\"activeSubForm\"\n\t\t\t\t:key=\"state.type\"\n\t\t\t\t:editingWidget=\"state.editingWidget\"\n\t\t\t\t:value=\"state.content\"\n\t\t\t\t:fileUploadFn=\"fileUploadFn\"\n\t\t\t\t:calendarsFetcher=\"calendarsFetcher\"\n\t\t\t\t@update:content=\"onContentUpdate\" />\n\t\t</div>\n\t\t<div v-else class=\"cn-add-widget-modal__empty\">\n\t\t\t{{ t('nextcloud-vue', 'No widget types available') }}\n\t\t</div>\n\n\t\t<!-- Widget appearance (chrome): title, background, icon. Shared with\n\t\t every consumer so the add/edit experience is identical across apps\n\t\t (the chrome rides alongside `content` in the submit payload). -->\n\t\t<div v-if=\"activeSubFormComponent\" class=\"cn-add-widget-modal__chrome\">\n\t\t\t<h3 class=\"cn-add-widget-modal__chrome-title\">\n\t\t\t\t{{ t('nextcloud-vue', 'Appearance') }}\n\t\t\t</h3>\n\t\t\t<!-- Title chrome is hidden for types whose sub-form owns the title\n\t\t\t (e.g. the data widget's own Title field) so there aren't two\n\t\t\t title inputs. -->\n\t\t\t<template v-if=\"!activeTypeOwnsTitle\">\n\t\t\t\t<NcCheckboxRadioSwitch\n\t\t\t\t\t:modelValue=\"chrome.showTitle\"\n\t\t\t\t\t@update:modelValue=\"chrome.showTitle = $event\">\n\t\t\t\t\t{{ t('nextcloud-vue', 'Show title') }}\n\t\t\t\t</NcCheckboxRadioSwitch>\n\t\t\t\t<NcTextField\n\t\t\t\t\tv-if=\"chrome.showTitle\"\n\t\t\t\t\t:modelValue=\"chrome.customTitle\"\n\t\t\t\t\t:label=\"t('nextcloud-vue', 'Custom title')\"\n\t\t\t\t\t@update:modelValue=\"chrome.customTitle = $event\" />\n\t\t\t</template>\n\t\t\t<div class=\"cn-add-widget-modal__chrome-row\">\n\t\t\t\t<span class=\"cn-add-widget-modal__chrome-label\">{{ t('nextcloud-vue', 'Background') }}</span>\n\t\t\t\t<CnColorPicker\n\t\t\t\t\t:value=\"chrome.backgroundColor\"\n\t\t\t\t\tclearable\n\t\t\t\t\t@input=\"chrome.backgroundColor = $event.hex\"\n\t\t\t\t\t@clear=\"chrome.backgroundColor = ''\" />\n\t\t\t\t<span class=\"cn-add-widget-modal__chrome-value\">\n\t\t\t\t\t{{ chrome.backgroundColor || t('nextcloud-vue', 'Default') }}\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t\t<div class=\"cn-add-widget-modal__chrome-row\">\n\t\t\t\t<span class=\"cn-add-widget-modal__chrome-label\">{{ t('nextcloud-vue', 'Icon') }}</span>\n\t\t\t\t<CnIconBrowser\n\t\t\t\t\t:value=\"chrome.customIcon\"\n\t\t\t\t\t:uploadFn=\"uploadFn\"\n\t\t\t\t\tallowUrl\n\t\t\t\t\tclearable\n\t\t\t\t\t@input=\"chrome.customIcon = $event\" />\n\t\t\t</div>\n\t\t</div>\n\n\t\t<template #actions>\n\t\t\t<NcButton variant=\"tertiary\" :disabled=\"submitting\" @click=\"onCancel\">\n\t\t\t\t{{ t('nextcloud-vue', 'Cancel') }}\n\t\t\t</NcButton>\n\t\t\t<NcButton\n\t\t\t\tvariant=\"primary\"\n\t\t\t\t:disabled=\"!canSubmit || submitting\"\n\t\t\t\t:title=\"firstError || ''\"\n\t\t\t\tdata-testid=\"add-widget-save\"\n\t\t\t\t@click=\"onSubmit\">\n\t\t\t\t{{ submitLabel }}\n\t\t\t</NcButton>\n\t\t</template>\n\t</NcDialog>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcCheckboxRadioSwitch, NcDialog, NcNoteCard, NcTextField } from '@nextcloud/vue'\nimport { computed, provide } from 'vue'\nimport CnColorPicker from '../components/CnColorPicker/CnColorPicker.vue'\nimport CnIconBrowser from '../components/CnIconBrowser/CnIconBrowser.vue'\nimport CnWidgetIcon from '../components/CnWidgetGrid/CnWidgetIcon.vue'\nimport {\n\tgetWidgetTypeEntry,\n\tlistUserAddableWidgetTypes,\n\tlistWidgetTypes,\n\tuserWidgetPresets,\n} from '../components/CnWidgetGrid/dashboardWidgetRegistry.js'\nimport { useWidgetForm } from '../composables/useWidgetForm.js'\n\nlet titleIdCounter = 0\nlet selectIdCounter = 0\n\n/**\n * CnAddWidgetModal — unified, isolated host (ADR-004) for both the \"add a\n * dashboard widget\" and \"edit a dashboard widget\" flows. The modal does NO API\n * and NO grid work itself; it emits `submit({type, content})` for the parent to\n * persist. Per-type fields live in sub-form components registered in the shared\n * `dashboardWidgetRegistry`.\n *\n * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n */\nexport default {\n\tname: 'CnAddWidgetModal',\n\n\tcomponents: {\n\t\tNcDialog,\n\t\tNcButton,\n\t\tNcTextField,\n\t\tNcCheckboxRadioSwitch,\n\t\tNcNoteCard,\n\t\tCnIconBrowser,\n\t\tCnColorPicker,\n\t\tCnWidgetIcon,\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * Toggles visibility. Going `false → true` triggers `resetForm()` (or\n\t\t * `loadEditingWidget()` when `editingWidget` is set).\n\t\t */\n\t\tshow: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * When set, the type `<select>` is hidden and the form opens directly\n\t\t * on this type (toolbar deep-links).\n\t\t */\n\t\tpreselectedType: {\n\t\t\ttype: String,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/**\n\t\t * When set, the modal opens in edit mode: the type select is hidden\n\t\t * (placement type is immutable) and the sub-form is pre-filled from\n\t\t * `editingWidget.content`. Must expose `type` and `content`.\n\t\t *\n\t\t * @type {{type: string, 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 * Optional upload transport for the Appearance icon picker:\n\t\t * `async (dataUrl: string) => ({ url })`. The icon picker reads the chosen\n\t\t * file to a data URL and passes that string here. When null, the upload\n\t\t * control is hidden and the picker still offers its catalogues, NL sets,\n\t\t * and a URL field.\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\n\t\t/**\n\t\t * Optional raw-file upload transport forwarded to the active sub-form as\n\t\t * its `file-upload-fn`: `async (file: File) => ({ url })`. Deliberately a\n\t\t * separate prop from `uploadFn` (which the icon picker calls with a data\n\t\t * URL) so the File-typed transport can never reach a sub-form that expects\n\t\t * a data URL (e.g. `CnHeaderWidgetForm.uploadFn`). Sub-forms such as the\n\t\t * image widget defer the upload to submit and hand over the raw `File`.\n\t\t * When null, sub-forms fall back to their own no-transport behaviour.\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 * Optional async fetcher returning the user's calendars\n\t\t * (`[{key, name, color}]`) for the calendar widget's picker. Provided\n\t\t * by the consuming app (which owns the calendar backend); when null the\n\t\t * calendar form falls back to free-text principal entry.\n\t\t *\n\t\t * @type {(() => Promise<Array<{key: string, name: string, color: string}>>)|null}\n\t\t */\n\t\tcalendarsFetcher: {\n\t\t\ttype: Function,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/**\n\t\t * Non-fatal notices about the widget, shown above its form: what the\n\t\t * host found about its configuration, e.g. a filter dimension the\n\t\t * dashboard does not publish. Each is `{ text, type?, id? }`, `type`\n\t\t * one of `warning` (default), `info`, `error`, `success`.\n\t\t *\n\t\t * @type {Array<{text: string, type?: string, id?: string}>}\n\t\t * @spec openspec/changes/add-widget-modal-notices/specs/add-widget-modal-notices/spec.md#requirement-the-widget-dialog-can-show-the-hosts-notices\n\t\t */\n\t\tnotices: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => [],\n\t\t},\n\n\t\t/**\n\t\t * The surface the picker offers types for. `'detail-page'` surfaces\n\t\t * detail-only types (e.g. a second `data` widget) alongside the universal\n\t\t * widgets; the default `'app-dashboard'` lists the dashboard set. Types\n\t\t * with no declared `surfaces` appear on every surface.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\tsurface: {\n\t\t\ttype: String,\n\t\t\tdefault: 'app-dashboard',\n\t\t},\n\n\t\t/**\n\t\t * Whether this picker is being opened BY A USER for their own\n\t\t * dashboard, rather than by an administrator editing the page for\n\t\t * everybody. It narrows the type list to `userAddable` entries and\n\t\t * turns on the manifest presets.\n\t\t *\n\t\t * @type {boolean}\n\t\t */\n\t\tuserAddableOnly: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\n\t\t/**\n\t\t * The hosting page's config, read for `userWidgets[]` when\n\t\t * `userAddableOnly` is on.\n\t\t *\n\t\t * @type {object|null}\n\t\t */\n\t\tpageConfig: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/**\n\t\t * Authoritative object context `{ register, schema }` for the page hosting\n\t\t * the picker (supplied by the Buildiq edit button from the ACTIVE page's\n\t\t * config). Provided down as `cnObjectContext` so the data sub-form resolves\n\t\t * the right schema even though the modal teleports out of the page's\n\t\t * ambient provide tree. Null on surfaces without a single object (e.g.\n\t\t * dashboards).\n\t\t *\n\t\t * @type {{register: string, schema: string}|null}\n\t\t */\n\t\tdataContext: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\temits: [\n\t\t/** Fired on cancel button, backdrop click, or Esc key. */\n\t\t'close',\n\t\t/** Fired with the assembled `{type, content}` payload for the parent to persist. */\n\t\t'submit',\n\t],\n\n\tsetup(props) {\n\t\t// One composable instance per modal mount. The composable owns the\n\t\t// type/content/editingWidget reactive state shared with sub-forms.\n\t\tconst form = useWidgetForm()\n\t\t// Publish the page's object context to the (teleported) sub-forms so the\n\t\t// data widget's property editor loads the ACTIVE page's schema, not\n\t\t// whatever ambient context the modal lands next to in the DOM.\n\t\tprovide('cnObjectContext', computed(() => props.dataContext || null))\n\t\treturn { form }\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\t// Re-validation tick: `isValid` must recompute every time the\n\t\t\t// active sub-form's input changes. Sub-forms emit `update:content`\n\t\t\t// on every keystroke; we bump this counter in the handler so the\n\t\t\t// computed re-runs.\n\t\t\tvalidationTick: 0,\n\t\t\t// Snapshot of the assembled content + chrome captured when the modal\n\t\t\t// opens; `isDirty` compares the live values against it so editing an\n\t\t\t// existing widget only enables Save once something actually changed.\n\t\t\tinitialSnapshot: '',\n\t\t\ttitleId: `cn-add-widget-modal-title-${++titleIdCounter}`,\n\t\t\ttypeSelectId: `cn-add-widget-modal-type-${++selectIdCounter}`,\n\t\t\t// Widget chrome (title / background / icon) edited in the same modal\n\t\t\t// as the per-type content and emitted back under `payload.chrome`.\n\t\t\tchrome: { showTitle: true, customTitle: '', backgroundColor: '', customIcon: '' },\n\t\t\t// True while the sub-form's commit() (e.g. an image upload) runs on\n\t\t\t// submit, so both footer buttons disable and the label shows progress.\n\t\t\tsubmitting: false,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The shared form state container ({type, content, editingWidget}).\n\t\t *\n\t\t * @return {{type: string, content: object, editingWidget: (object|null)}} the reactive state.\n\t\t */\n\t\tstate() {\n\t\t\treturn this.form.state\n\t\t},\n\n\t\t/**\n\t\t * Type keys the picker offers — only registry entries that have a form.\n\t\t *\n\t\t * @return {string[]} the form-bearing type keys.\n\t\t */\n\t\tavailableTypes() {\n\t\t\t// A USER PICKING FOR THEMSELVES IS OFFERED A SMALLER LIST. An\n\t\t\t// administrator configures a widget once with the register and\n\t\t\t// schema in front of them; a user has neither and cannot be told\n\t\t\t// about them, so they see only the types whose registry entry\n\t\t\t// declares `userAddable`.\n\t\t\treturn this.userAddableOnly\n\t\t\t\t? listUserAddableWidgetTypes(this.surface)\n\t\t\t\t: listWidgetTypes(this.surface)\n\t\t},\n\n\t\t/**\n\t\t * The presets this page offers a user, from `config.userWidgets[]`.\n\t\t *\n\t\t * @return {Array<object>} The offerable presets.\n\t\t */\n\t\tavailablePresets() {\n\t\t\treturn this.userAddableOnly ? userWidgetPresets(this.pageConfig) : []\n\t\t},\n\n\t\t/**\n\t\t * Whether the active type's sub-form owns the widget title (declares\n\t\t * `ownsTitle` in its registry entry). When true the modal hides its\n\t\t * generic Title chrome so there aren't two title inputs.\n\t\t *\n\t\t * @return {boolean} true when the sub-form provides its own title field.\n\t\t */\n\t\tactiveTypeOwnsTitle() {\n\t\t\tconst entry = getWidgetTypeEntry(this.state.type)\n\t\t\treturn !!(entry && entry.ownsTitle)\n\t\t},\n\n\t\t/**\n\t\t * Whether to show the type select (hidden in edit / preselected mode).\n\t\t *\n\t\t * @return {boolean} true only in pure-create mode.\n\t\t */\n\t\tshowTypeSelect() {\n\t\t\treturn !this.editingWidget && !this.preselectedType\n\t\t},\n\n\t\t/**\n\t\t * The Vue component to mount via `<component :is>` for the active type,\n\t\t * or `null` when the type is unknown or renderer-only.\n\t\t *\n\t\t * @return {object|null} the active sub-form component reference.\n\t\t */\n\t\tactiveSubFormComponent() {\n\t\t\tconst entry = getWidgetTypeEntry(this.state.type)\n\t\t\treturn entry?.form || null\n\t\t},\n\n\t\t/**\n\t\t * Modal heading — flips between Add and Edit based on edit mode.\n\t\t *\n\t\t * @return {string} the localised modal title.\n\t\t */\n\t\tmodalTitle() {\n\t\t\treturn this.editingWidget\n\t\t\t\t? t('nextcloud-vue', 'Edit Widget')\n\t\t\t\t: t('nextcloud-vue', 'Add Widget')\n\t\t},\n\n\t\t/**\n\t\t * Submit button label — flips between Add and Save based on edit mode.\n\t\t *\n\t\t * @return {string} the localised submit label.\n\t\t *\n\t\t * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n\t\t */\n\t\tsubmitLabel() {\n\t\t\tif (this.submitting) {\n\t\t\t\treturn t('nextcloud-vue', 'Uploading…')\n\t\t\t}\n\t\t\treturn this.editingWidget ? t('nextcloud-vue', 'Save') : t('nextcloud-vue', 'Add')\n\t\t},\n\n\t\t/**\n\t\t * The active sub-form's validation errors. `validationTick` keeps Vue's\n\t\t * dependency tracker aware that this computed re-runs on every input.\n\t\t *\n\t\t * @return {string[]} the validation error messages.\n\t\t */\n\t\tvalidationErrors() {\n\t\t\t// Read the tick, discard the value: `$refs` is not reactive, so the\n\t\t\t// tick is what Vue can track as this computed's dependency.\n\t\t\tvoid this.validationTick\n\t\t\treturn this.form.validate(this.$refs.activeSubForm)\n\t\t},\n\n\t\t/**\n\t\t * Whether the submit button is enabled (no validation errors).\n\t\t *\n\t\t * @return {boolean} true when the active sub-form is valid.\n\t\t */\n\t\tisValid() {\n\t\t\treturn this.validationErrors.length === 0\n\t\t},\n\n\t\t/**\n\t\t * Whether the content or chrome differs from the snapshot taken when the\n\t\t * modal opened. Depends on `chrome` (via the snapshot's JSON) and the\n\t\t * `validationTick` (bumped on every sub-form `update:content`) so it\n\t\t * re-runs on both chrome and form-field edits.\n\t\t *\n\t\t * @return {boolean} true when something changed since open.\n\t\t */\n\t\tisDirty() {\n\t\t\t// Read the tick, discard the value, so content edits re-run this.\n\t\t\tvoid this.validationTick\n\t\t\treturn this.currentSnapshot() !== this.initialSnapshot\n\t\t},\n\n\t\t/**\n\t\t * Whether Save is allowed: the form must be valid, and — when editing an\n\t\t * existing widget — something must have changed. Create mode may submit\n\t\t * the (valid) defaults straight away.\n\t\t *\n\t\t * @return {boolean} true when the submit button is enabled.\n\t\t */\n\t\tcanSubmit() {\n\t\t\tif (!this.isValid) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn !this.editingWidget || this.isDirty\n\t\t},\n\n\t\t/**\n\t\t * The first user-visible validation error (hides the internal\n\t\t * `__no-active-form__` sentinel).\n\t\t *\n\t\t * @return {string} the first error message, or an empty string.\n\t\t */\n\t\tfirstError() {\n\t\t\tconst err = this.validationErrors[0]\n\t\t\treturn err && err !== '__no-active-form__' ? err : ''\n\t\t},\n\t},\n\n\twatch: {\n\t\t/**\n\t\t * Re-initialise the form when the modal opens.\n\t\t *\n\t\t * @param {boolean} isOpen the new `show` value.\n\t\t * @return {void}\n\t\t */\n\t\tshow(isOpen) {\n\t\t\tif (isOpen) {\n\t\t\t\tthis.openLifecycle()\n\t\t\t}\n\t\t},\n\n\t\teditingWidget: {\n\t\t\timmediate: false,\n\t\t\t/**\n\t\t\t * Pre-fill from a newly-supplied editing widget while open.\n\t\t\t *\n\t\t\t * @param {object|null} widget the placement being edited.\n\t\t\t * @return {void}\n\t\t\t */\n\t\t\thandler(widget) {\n\t\t\t\tif (this.show && widget) {\n\t\t\t\t\tthis.form.loadEditingWidget(widget)\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\n\t\t/**\n\t\t * Re-seed the form when the preselected type changes while open.\n\t\t *\n\t\t * @param {string|null} type the new preselected type.\n\t\t * @return {void}\n\t\t */\n\t\tpreselectedType(type) {\n\t\t\tif (this.show && type && !this.editingWidget) {\n\t\t\t\tthis.form.resetForm(type)\n\t\t\t}\n\t\t},\n\t},\n\n\tcreated() {\n\t\t// Seed state synchronously before the first render so the\n\t\t// `v-if=\"activeSubFormComponent\"` path resolves to the right sub-form\n\t\t// on initial mount (otherwise the modal flashes the \"No widget types\n\t\t// available\" empty state for one tick).\n\t\tif (this.show) {\n\t\t\tthis.openLifecycle()\n\t\t}\n\t},\n\n\tmounted() {\n\t\tdocument.addEventListener('keydown', this.onKeydown)\n\t\t// The validation gate reads `$refs.activeSubForm`, which is null while\n\t\t// `created()` runs (the sub-form mounts after the first render). Bump\n\t\t// the tick once the ref is bound so `isValid` reflects the freshly\n\t\t// mounted sub-form's `validate()` without waiting for the first input.\n\t\tthis.$nextTick(() => {\n\t\t\tthis.validationTick++\n\t\t})\n\t},\n\n\tbeforeUnmount() {\n\t\tdocument.removeEventListener('keydown', this.onKeydown)\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * The note card type of a notice: its own when known, else `warning`.\n\t\t *\n\t\t * @param {{type?: string}} notice The notice.\n\t\t * @return {string}\n\t\t * @spec openspec/changes/add-widget-modal-notices/specs/add-widget-modal-notices/spec.md#requirement-the-widget-dialog-can-show-the-hosts-notices\n\t\t */\n\t\tnoticeType(notice) {\n\t\t\treturn ['warning', 'info', 'error', 'success'].includes(notice && notice.type) ? notice.type : 'warning'\n\t\t},\n\n\t\tt,\n\n\t\t/**\n\t\t * Initialise form state when the modal opens. Edit mode pre-fills from\n\t\t * `editingWidget`; create mode resets to the preselected type (toolbar\n\t\t * invocation) or to the first available registered type.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\topenLifecycle() {\n\t\t\tif (this.editingWidget) {\n\t\t\t\tthis.form.loadEditingWidget(this.editingWidget)\n\t\t\t\tthis.seedChrome(this.editingWidget)\n\t\t\t} else {\n\t\t\t\tconst initialType = this.preselectedType\n\t\t\t\t\t|| this.availableTypes[0]\n\t\t\t\t\t|| ''\n\t\t\t\tthis.form.resetForm(initialType)\n\t\t\t\tthis.seedChrome(null)\n\t\t\t}\n\t\t\t// Revalidate on every open (the modal instance persists across\n\t\t\t// open/close, so `mounted()`'s one-time bump doesn't fire again).\n\t\t\t// Bump synchronously and again once the sub-form has (re)mounted and\n\t\t\t// its `$refs.activeSubForm` is bound — otherwise the submit gate stays\n\t\t\t// stale in edit mode until the user touches a form field. The nextTick\n\t\t\t// pass also captures the pristine snapshot `isDirty` compares against.\n\t\t\tthis.validationTick++\n\t\t\tthis.$nextTick(() => {\n\t\t\t\tthis.validationTick++\n\t\t\t\tthis.initialSnapshot = this.currentSnapshot()\n\t\t\t})\n\t\t},\n\n\t\t/**\n\t\t * Serialise the current assembled content + chrome for dirty comparison.\n\t\t *\n\t\t * @return {string} a stable JSON snapshot of the editable state.\n\t\t */\n\t\tcurrentSnapshot() {\n\t\t\tconst { content } = this.form.assembleContent(this.$refs.activeSubForm)\n\t\t\treturn JSON.stringify({ content, chrome: this.chrome })\n\t\t},\n\n\t\t/**\n\t\t * Seed the Appearance controls (title / background / icon) from a\n\t\t * placement being edited, or to defaults in create mode. Reads chrome\n\t\t * fields from the placement's top level with a fallback to its `content`\n\t\t * (and `styleConfig.backgroundColor`), so it round-trips whatever shape\n\t\t * the consumer persists.\n\t\t *\n\t\t * @param {object|null} widget The placement being edited, or null.\n\t\t * @return {void}\n\t\t */\n\t\tseedChrome(widget) {\n\t\t\tconst w = widget || {}\n\t\t\tconst c = (w.content && typeof w.content === 'object') ? w.content : {}\n\t\t\tconst pick = (...vals) => vals.find((v) => v !== undefined && v !== null)\n\t\t\tconst showRaw = pick(w.showTitle, c.showTitle)\n\t\t\tthis.chrome = {\n\t\t\t\t// Cards (stat / gauge / delta) headline themselves via `content.label`,\n\t\t\t\t// so they default headerless — otherwise the chrome header just repeats\n\t\t\t\t// the label, or shows the bare type name when no title was ever set.\n\t\t\t\tshowTitle: showRaw === undefined\n\t\t\t\t\t? !this.isCardType(w.type || this.state.type)\n\t\t\t\t\t: Boolean(Number(showRaw) || showRaw === true),\n\n\t\t\t\tcustomTitle: pick(w.customTitle, c.customTitle, c.title) || '',\n\t\t\t\tbackgroundColor: pick(w.backgroundColor, w.styleConfig?.backgroundColor, c.styleConfig?.backgroundColor) || '',\n\t\t\t\tcustomIcon: pick(w.customIcon, c.customIcon, c.icon) || '',\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Handle a `<select>` change: swap the active sub-form and reset its\n\t\t * state to defaults. Switching type discards any in-progress field\n\t\t * input. The sub-form is keyed on `state.type`, so changing the type\n\t\t * tears down the old `<component :is>` and remounts a new one;\n\t\t * `$refs.activeSubForm` is briefly null between teardown and mount, so\n\t\t * we bump the tick again on the next tick once the ref is rebound.\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\tonTypeSwitch() {\n\t\t\tthis.form.resetForm(this.state.type)\n\t\t\t// Re-apply the type's chrome default: switching between a card and a\n\t\t\t// full widget flips whether a header makes sense.\n\t\t\tthis.chrome.showTitle = !this.isCardType(this.state.type)\n\t\t\tthis.validationTick++\n\t\t\tthis.$nextTick(() => {\n\t\t\t\tthis.validationTick++\n\t\t\t})\n\t\t},\n\n\t\t/**\n\t\t * Whether a widget type is a self-contained card (stat / gauge / delta),\n\t\t * which renders headerless by default.\n\t\t *\n\t\t * @param {string} type the registry type key.\n\t\t * @return {boolean} true when the registry entry is a card.\n\t\t */\n\t\tisCardType(type) {\n\t\t\tif (!type) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tconst entry = getWidgetTypeEntry(type)\n\t\t\treturn Boolean(entry && entry.card === true)\n\t\t},\n\n\t\t/**\n\t\t * Mirror a sub-form `update:content` payload into the composable state\n\t\t * (so `assembleContent()` can fall back to it) and bump the validation\n\t\t * tick so the submit button enables/disables reactively on input.\n\t\t *\n\t\t * @param {object} content the sub-form's current content payload.\n\t\t * @return {void}\n\t\t */\n\t\tonContentUpdate(content) {\n\t\t\tthis.state.content = { ...content }\n\t\t\tthis.validationTick++\n\t\t},\n\n\t\t/**\n\t\t * Cancel button / backdrop / NcModal `close` event — non-destructive,\n\t\t * never emits submit. Suppressed while a sub-form `commit()` (e.g. an\n\t\t * image upload) is in flight so dismissing the dialog can't unmount the\n\t\t * sub-form mid-upload (which would orphan the upload and write into a\n\t\t * destroyed instance).\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\tonCancel() {\n\t\t\tif (this.submitting) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.$emit('close')\n\t\t},\n\n\t\t/**\n\t\t * Esc-key fallback listener (in case NcModal's own handler is\n\t\t * suppressed by a parent focus-trap). Emits `close`, never `submit`.\n\t\t * Suppressed while a commit() is in flight (see `onCancel`).\n\t\t *\n\t\t * @param {KeyboardEvent} event the keydown 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\tonKeydown(event) {\n\t\t\tif (this.submitting) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (this.show && event.key === 'Escape') {\n\t\t\t\tthis.$emit('close')\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Commit the active sub-form (e.g. upload a pending image), then build\n\t\t * the `{type, content}` payload via the composable's `assembleContent()`\n\t\t * and emit it. The commit is the only step that can hit the network; a\n\t\t * commit failure keeps the modal open and blocks the `submit` emit.\n\t\t *\n\t\t * @return {Promise<void>} resolves once submit is emitted or aborted.\n\t\t *\n\t\t * @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md\n\t\t */\n\t\tasync onSubmit() {\n\t\t\tif (!this.isValid || this.submitting) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst subForm = this.$refs.activeSubForm\n\t\t\tif (subForm && typeof subForm.commit === 'function') {\n\t\t\t\tthis.submitting = true\n\t\t\t\ttry {\n\t\t\t\t\tawait subForm.commit()\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// The sub-form surfaces its own inline error; keep the modal\n\t\t\t\t\t// open so the author can retry or pick another file.\n\t\t\t\t\t// eslint-disable-next-line no-console -- diagnostic for a failure this code already degrades from\n\t\t\t\t\tconsole.error('[CnAddWidgetModal] Widget commit failed:', error)\n\t\t\t\t\treturn\n\t\t\t\t} finally {\n\t\t\t\t\tthis.submitting = false\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst payload = this.form.assembleContent(this.$refs.activeSubForm)\n\t\t\t// Carry the chrome (title / background / icon) alongside the content\n\t\t\t// so the parent persists both from this single modal.\n\t\t\tpayload.chrome = {\n\t\t\t\tshowTitle: this.chrome.showTitle,\n\t\t\t\tcustomTitle: this.chrome.customTitle,\n\t\t\t\tcustomIcon: this.chrome.customIcon,\n\t\t\t\tbackgroundColor: this.chrome.backgroundColor,\n\t\t\t}\n\t\t\tthis.$emit('submit', payload)\n\t\t},\n\n\t\t/**\n\t\t * Look up the human-readable display name for a registry type, falling\n\t\t * back to the type key itself.\n\t\t *\n\t\t * @param {string} type the registry type key.\n\t\t * @return {string} the display name.\n\t\t */\n\t\ttypeDisplayName(type) {\n\t\t\tconst entry = getWidgetTypeEntry(type)\n\t\t\treturn entry?.displayName || type\n\t\t},\n\n\t\t/**\n\t\t * The icon a registry type declares (an MDI name, SVG path or URL), or\n\t\t * `null` for the default widget icon.\n\t\t *\n\t\t * @param {string} type the registry type key.\n\t\t * @return {string|null} the icon.\n\t\t */\n\t\ttypeIcon(type) {\n\t\t\tconst icon = getWidgetTypeEntry(type)?.icon\n\t\t\treturn typeof icon === 'string' && icon !== '' ? icon : null\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-add-widget-modal__type {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 6px;\n}\n\n.cn-add-widget-modal__type-label {\n\tfont-size: 14px;\n\tfont-weight: 500;\n}\n\n.cn-add-widget-modal__type-row {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n}\n\n.cn-add-widget-modal__type-icon {\n\tdisplay: inline-flex;\n\tflex: none;\n\tcolor: var(--color-main-text);\n}\n\n.cn-add-widget-modal__type-select {\n\tflex: 1;\n\tmin-width: 0;\n\tpadding: 8px 12px;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n\tbackground: var(--color-main-background);\n\tcolor: var(--color-main-text);\n\tfont-size: 14px;\n}\n\n.cn-add-widget-modal__form {\n\toverflow-y: auto;\n\t/* Prefer a roomy ~340px for the type-specific fields (data-driven widgets\n\t carry tall forms — columns, thresholds, data source); still shrinks with\n\t its own scroll on short viewports so the Appearance + actions stay visible. */\n\tflex: 1 1 340px;\n\tmin-height: 0;\n}\n\n.cn-add-widget-modal__empty {\n\tpadding: 16px;\n\ttext-align: center;\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-add-widget-modal__chrome {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 10px;\n\tborder-top: 1px solid var(--color-border);\n\tpadding-top: 12px;\n}\n\n.cn-add-widget-modal__chrome-title {\n\tmargin: 0;\n\tfont-size: 15px;\n\tfont-weight: 600;\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-add-widget-modal__chrome-row {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 12px;\n}\n\n.cn-add-widget-modal__chrome-label {\n\tmin-width: 96px;\n\tfont-size: 14px;\n}\n\n.cn-add-widget-modal__chrome-value {\n\tfont-size: 13px;\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-add-widget-modal__notices {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n\tmargin-block-end: 12px;\n}\n</style>\n"],"names":["CnIconBrowser","CnColorPicker","CnWidgetIcon","t"],"mappings":";;;;;;;;;AAyJA,IAAI,iBAAiB;AACrB,IAAI,kBAAkB;;AAEtB;;AAEC;AACA;AACA;;AAEA;AACA;;AAED,aAAe;CACd,IAAI,EAAE,kBAAkB;;CAExB,UAAU,EAAE;AACX,EAAA,QAAQ;AACR,EAAA,QAAQ;EACR,WAAW;AACX,EAAA,qBAAqB;EACrB,UAAU;iBACVA,YAAa;iBACbC,YAAa;gBACbC,UAAY;EACZ;;AAED,CAAA,KAAK,EAAE;AACN;;;;EAIA,IAAI,EAAE;GACL,IAAI,EAAE,OAAO;GACb,OAAO,EAAE,KAAK;GACd;;AAED;;AAEC;;AAED,EAAA,eAAe,EAAE;GAChB,IAAI,EAAE,MAAM;GACZ,OAAO,EAAE,IAAI;GACb;;AAED;;;;AAIC;AACA;;AAED,EAAA,aAAa,EAAE;GACd,IAAI,EAAE,MAAM;GACZ,OAAO,EAAE,IAAI;GACb;;AAED;;;;;;AAMC;;;AAGD,EAAA,QAAQ,EAAE;GACT,IAAI,EAAE,QAAQ;GACd,OAAO,EAAE,IAAI;GACb;;AAED;;;;;AAKC;;;AAGA;;;EAGD,YAAY,EAAE;GACb,IAAI,EAAE,QAAQ;GACd,OAAO,EAAE,IAAI;GACb;;AAED;;;;;AAKC;A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