@conduction/nextcloud-vue 2.183.0 → 2.185.0

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.
@@ -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<!-- 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, 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\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 * 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\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</style>\n"],"names":["CnIconBrowser","CnColorPicker","t"],"mappings":";;;;;;;;AA6HA,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;iBACrBA,YAAa;iBACbC,UAAa;EACb;;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;AACA;;AAED,EAAA,gBAAgB,EAAE;GACjB,IAAI,EAAE,QAAQ;GACd,OAAO,EAAE,IAAI;GACb;;AAED;;AAEC;;AAEA;AACA;;;AAGD,EAAA,OAAO,EAAE;GACR,IAAI,EAAE,MAAM;GACZ,OAAO,EAAE,eAAe;GACxB;;AAED;;;;;AAKC;AACA;;AAED,EAAA,eAAe,EAAE;GAChB,IAAI,EAA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,OAAM,IAAK,OAAO,OAAO,CAAC,MAAK,KAAM,UAAU,EAAE;AACpD,IAAA,IAAI,CAAC,aAAa;AAClB,IAAA,IAAI;AACH,KAAA,MAAM,OAAO,CAAC,MAAM;IACrB,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<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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C,MAAM;IACrB,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,4 +1,4 @@
1
- import { resolveComponent, openBlock, createBlock, withCtx, createElementBlock, createElementVNode, toDisplayString, withDirectives, Fragment, renderList, vModelSelect, createCommentVNode, resolveDynamicComponent, createVNode, createTextVNode } from 'vue';
1
+ import { resolveComponent, openBlock, createBlock, withCtx, createElementBlock, createElementVNode, toDisplayString, withDirectives, Fragment, renderList, vModelSelect, createCommentVNode, renderSlot, resolveDynamicComponent, createVNode, createTextVNode } from 'vue';
2
2
 
3
3
  const _hoisted_1 = {
4
4
  key: 0,
@@ -9,24 +9,30 @@ const _hoisted_3 = ["id"];
9
9
  const _hoisted_4 = ["value", "data-testid"];
10
10
  const _hoisted_5 = {
11
11
  key: 1,
12
- class: "cn-add-widget-modal__form"
12
+ class: "cn-add-widget-modal__notices",
13
+ "data-testid": "cn-add-widget-modal-notices"
13
14
  };
14
15
  const _hoisted_6 = {
15
16
  key: 2,
16
- class: "cn-add-widget-modal__empty"
17
+ class: "cn-add-widget-modal__form"
17
18
  };
18
19
  const _hoisted_7 = {
19
20
  key: 3,
21
+ class: "cn-add-widget-modal__empty"
22
+ };
23
+ const _hoisted_8 = {
24
+ key: 4,
20
25
  class: "cn-add-widget-modal__chrome"
21
26
  };
22
- const _hoisted_8 = { class: "cn-add-widget-modal__chrome-title" };
23
- const _hoisted_9 = { class: "cn-add-widget-modal__chrome-row" };
24
- const _hoisted_10 = { class: "cn-add-widget-modal__chrome-label" };
25
- const _hoisted_11 = { class: "cn-add-widget-modal__chrome-value" };
26
- const _hoisted_12 = { class: "cn-add-widget-modal__chrome-row" };
27
- const _hoisted_13 = { class: "cn-add-widget-modal__chrome-label" };
27
+ const _hoisted_9 = { class: "cn-add-widget-modal__chrome-title" };
28
+ const _hoisted_10 = { class: "cn-add-widget-modal__chrome-row" };
29
+ const _hoisted_11 = { class: "cn-add-widget-modal__chrome-label" };
30
+ const _hoisted_12 = { class: "cn-add-widget-modal__chrome-value" };
31
+ const _hoisted_13 = { class: "cn-add-widget-modal__chrome-row" };
32
+ const _hoisted_14 = { class: "cn-add-widget-modal__chrome-label" };
28
33
 
29
34
  function render(_ctx, _cache, $props, $setup, $data, $options) {
35
+ const _component_NcNoteCard = resolveComponent("NcNoteCard");
30
36
  const _component_NcCheckboxRadioSwitch = resolveComponent("NcCheckboxRadioSwitch");
31
37
  const _component_NcTextField = resolveComponent("NcTextField");
32
38
  const _component_CnColorPicker = resolveComponent("CnColorPicker");
@@ -91,8 +97,21 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
91
97
  ])
92
98
  ]))
93
99
  : createCommentVNode("v-if", true),
94
- ($options.activeSubFormComponent)
100
+ ($props.notices.length > 0 || _ctx.$slots.notices)
95
101
  ? (openBlock(), createElementBlock("div", _hoisted_5, [
102
+ (openBlock(true), createElementBlock(Fragment, null, renderList($props.notices, (notice, index) => {
103
+ return (openBlock(), createBlock(_component_NcNoteCard, {
104
+ key: notice.id || index,
105
+ type: $options.noticeType(notice),
106
+ text: notice.text,
107
+ "data-testid": "cn-add-widget-modal-notice"
108
+ }, null, 8 /* PROPS */, ["type", "text"]))
109
+ }), 128 /* KEYED_FRAGMENT */)),
110
+ renderSlot(_ctx.$slots, "notices")
111
+ ]))
112
+ : createCommentVNode("v-if", true),
113
+ ($options.activeSubFormComponent)
114
+ ? (openBlock(), createElementBlock("div", _hoisted_6, [
96
115
  (openBlock(), createBlock(resolveDynamicComponent($options.activeSubFormComponent), {
97
116
  ref: "activeSubForm",
98
117
  key: $options.state.type,
@@ -103,10 +122,10 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
103
122
  "onUpdate:content": $options.onContentUpdate
104
123
  }, null, 40 /* PROPS, NEED_HYDRATION */, ["editingWidget", "value", "fileUploadFn", "calendarsFetcher", "onUpdate:content"]))
105
124
  ]))
106
- : (openBlock(), createElementBlock("div", _hoisted_6, toDisplayString($options.t('nextcloud-vue', 'No widget types available')), 1 /* TEXT */)),
125
+ : (openBlock(), createElementBlock("div", _hoisted_7, toDisplayString($options.t('nextcloud-vue', 'No widget types available')), 1 /* TEXT */)),
107
126
  ($options.activeSubFormComponent)
108
- ? (openBlock(), createElementBlock("div", _hoisted_7, [
109
- createElementVNode("h3", _hoisted_8, toDisplayString($options.t('nextcloud-vue', 'Appearance')), 1 /* TEXT */),
127
+ ? (openBlock(), createElementBlock("div", _hoisted_8, [
128
+ createElementVNode("h3", _hoisted_9, toDisplayString($options.t('nextcloud-vue', 'Appearance')), 1 /* TEXT */),
110
129
  (!$options.activeTypeOwnsTitle)
111
130
  ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
112
131
  createVNode(_component_NcCheckboxRadioSwitch, {
@@ -128,18 +147,18 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
128
147
  : createCommentVNode("v-if", true)
129
148
  ], 64 /* STABLE_FRAGMENT */))
130
149
  : createCommentVNode("v-if", true),
131
- createElementVNode("div", _hoisted_9, [
132
- createElementVNode("span", _hoisted_10, toDisplayString($options.t('nextcloud-vue', 'Background')), 1 /* TEXT */),
150
+ createElementVNode("div", _hoisted_10, [
151
+ createElementVNode("span", _hoisted_11, toDisplayString($options.t('nextcloud-vue', 'Background')), 1 /* TEXT */),
133
152
  createVNode(_component_CnColorPicker, {
134
153
  value: $data.chrome.backgroundColor,
135
154
  clearable: "",
136
155
  onInput: _cache[4] || (_cache[4] = $event => ($data.chrome.backgroundColor = $event.hex)),
137
156
  onClear: _cache[5] || (_cache[5] = $event => ($data.chrome.backgroundColor = ''))
138
157
  }, null, 8 /* PROPS */, ["value"]),
139
- createElementVNode("span", _hoisted_11, toDisplayString($data.chrome.backgroundColor || $options.t('nextcloud-vue', 'Default')), 1 /* TEXT */)
158
+ createElementVNode("span", _hoisted_12, toDisplayString($data.chrome.backgroundColor || $options.t('nextcloud-vue', 'Default')), 1 /* TEXT */)
140
159
  ]),
141
- createElementVNode("div", _hoisted_12, [
142
- createElementVNode("span", _hoisted_13, toDisplayString($options.t('nextcloud-vue', 'Icon')), 1 /* TEXT */),
160
+ createElementVNode("div", _hoisted_13, [
161
+ createElementVNode("span", _hoisted_14, toDisplayString($options.t('nextcloud-vue', 'Icon')), 1 /* TEXT */),
143
162
  createVNode(_component_CnIconBrowser, {
144
163
  value: $data.chrome.customIcon,
145
164
  uploadFn: $props.uploadFn,
@@ -151,7 +170,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
151
170
  ]))
152
171
  : createCommentVNode("v-if", true)
153
172
  ]),
154
- _: 1 /* STABLE */
173
+ _: 3 /* FORWARDED */
155
174
  }, 8 /* PROPS */, ["name", "onClosing"]))
156
175
  : createCommentVNode("v-if", true)
157
176
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CnAddWidgetModal3.vue.js","sources":["../../../src/dialogs/CnAddWidgetModal.vue?vue&type=template&id=031e75b9&lang.js"],"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<!-- 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, 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\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 * 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\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</style>\n"],"names":["_createVNode","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_vModelSelect","_createBlock","_Fragment"],"mappings":";;;;AAkBqB,EAAA,KAAA,EAAA;;;;;;;AAuBgB,EAAA,KAAE,EAAA;;;;AAWzB,EAAA,KAAK,EAAC;;;;AAOiB,EAAA,KAAK,EAAC;;AACnC,MAAA,UAAA,GAAA,EAAA,KAAI,EAAA,mCAAY;AAkBhB,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,iCAAiC;AACrC,MAAA,WAAA,GAAA,EAAA,KAAK,EAAC,mCAA2B;AAMjC,MAAA,WAAA,GAAA,EAAA,KAAK,EAAC,mCAAmC;AAI3C,MAAA,WAAA,GAAA,EAAA,KAAI,EAAA,iCAAA;AACF,MAAA,WAAA,GAAA,EAAA,KAAG,EAAA,mCAAA;;;;;;;;;;UA9EL,MAAA,CAAA,IAAG;;;AACT,QAAA,IAAG,EAAE,QAAQ;AACZ,QAAA,IAAI,EAAC,QAAA,CAAA,UAAW;AACf,QAAA,SAAM,EAAE,QAAA,CAAA;;AAqFC,QAAA,OAAO,UAChB,MAEU;UAFVA,WAAA,CAEU,mBAAA,EAAA;AAFD,YAAA,OAAO,EAAC,UAAU;AAAE,YAAA,QAAM,EAAA,KAAA,CAAA,UAAA;AAAA,YAAA,OAAA,EAAA,QAAA,CAAA;;6BACnC,MAAwB;8CAArB,QAAA,CAAA,CAAC,CAAA,eAAA,EAAA,QAAA,CAAA,CAAA,EAAA,CAAA;;;;UAEJA,WAAA;AACA,YAAA,OAAO,EAAC,SAAQ;YACf,QAAQ,EAAA,CAAA,QAAA,CAAA,SAAA,IAAA,KAAA,CAAA,UAAA;AACR,YAAA,KAAK,EAAE,QAAA,CAAA,UAAA,IAAA,EAAA;AACR,YAAA,aAAO,EAAA,iBAAA;;;;;;;;;yBA1FP,MAkBI;WAlBK,QAAA,CAAA,cAAQ;AAAjB,eAAAC,SAAA,EAAA,EAAAC,k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duction 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":["_createVNode","_openBlock","_createElementBlock","_createElementVNode","_Fragment","_renderList","_toDisplayString","_vModelSelect","_createBlock"],"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