@conduction/nextcloud-vue 2.56.0-beta.69 → 2.56.0-beta.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue.js +1 -1
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js +114 -11
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js +67 -17
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js +9 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js.map +1 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js +352 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js.map +1 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js +266 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js.map +1 -0
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue.js +1 -1
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js +257 -7
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js +113 -59
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue.js +1 -1
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js +210 -5
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js.map +1 -1
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js +134 -46
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js.map +1 -1
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js +9 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js.map +1 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js +385 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js.map +1 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js +277 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js.map +1 -0
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue.js +1 -1
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js +175 -20
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js +30 -8
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue.js +1 -1
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js +72 -6
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js +48 -14
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue.js +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js +162 -9
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js.map +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js +63 -23
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js.map +1 -1
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js +9 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js.map +1 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js +175 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js.map +1 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js +114 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js.map +1 -0
- package/dist/esm/components/CnDurationField/CnDurationField.vue.js +1 -1
- package/dist/esm/components/CnDurationField/CnDurationField.vue2.js +218 -4
- package/dist/esm/components/CnDurationField/CnDurationField.vue2.js.map +1 -1
- package/dist/esm/components/CnDurationField/CnDurationField.vue3.js +133 -44
- package/dist/esm/components/CnDurationField/CnDurationField.vue3.js.map +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue.js +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js +5 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js +9 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js.map +1 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js +113 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js.map +1 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js +43 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js.map +1 -0
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue.js +1 -1
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js +110 -1
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js.map +1 -1
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js +60 -18
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js.map +1 -1
- package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js +2 -2
- package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js +2 -2
- package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js.map +1 -1
- package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js +2 -2
- package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnQrCode/CnQrCode.vue.js +9 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue.js.map +1 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue2.js +241 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue2.js.map +1 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue3.js +75 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue3.js.map +1 -0
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue.js +1 -1
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js +34 -3
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js.map +1 -1
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js +81 -19
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +11 -0
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js +112 -88
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnRevealField/CnRevealField.vue.js +9 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue.js.map +1 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue2.js +157 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue2.js.map +1 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue3.js +116 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue3.js.map +1 -0
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue.js +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js +43 -3
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js +19 -12
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js +9 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js.map +1 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js +87 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js.map +1 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js +126 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js.map +1 -0
- package/dist/esm/components/CnTreeView/CnTreeNode.vue.js +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js +66 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js +129 -29
- package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue.js +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue2.js +158 -6
- package/dist/esm/components/CnTreeView/CnTreeView.vue2.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue3.js +100 -39
- package/dist/esm/components/CnTreeView/CnTreeView.vue3.js.map +1 -1
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/l10n/en.json.js +63 -1
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +63 -1
- package/dist/esm/l10n/nl.json.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +1134 -499
- package/dist/esm/node_modules/vuedraggable/dist/vuedraggable.umd.js +2 -2
- package/dist/esm/utils/captureLocation.js +32 -0
- package/dist/esm/utils/captureLocation.js.map +1 -0
- package/dist/esm/utils/childRecordTotals.js +157 -0
- package/dist/esm/utils/childRecordTotals.js.map +1 -0
- package/dist/esm/utils/isoDuration.js +51 -1
- package/dist/esm/utils/isoDuration.js.map +1 -1
- package/dist/esm/utils/qr.js +649 -0
- package/dist/esm/utils/qr.js.map +1 -0
- package/dist/esm/utils/schema.js +3 -0
- package/dist/esm/utils/schema.js.map +1 -1
- package/dist/esm/utils/templateVariables.js +54 -0
- package/dist/esm/utils/templateVariables.js.map +1 -0
- package/dist/nextcloud-vue.cjs.js +20307 -14544
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +1134 -499
- package/l10n/en.json +63 -1
- package/l10n/nl.json +63 -1
- package/package.json +1 -1
- package/src/components/CnActionDialog/CnActionDialog.vue +156 -9
- package/src/components/CnBlockListEditor/CnBlockListEditor.vue +615 -0
- package/src/components/CnBlockListEditor/index.js +9 -0
- package/src/components/CnChecklistRunWidget/CnChecklistRunWidget.vue +311 -10
- package/src/components/CnChildRecordsField/CnChildRecordsField.vue +306 -15
- package/src/components/CnChoiceMatrix/CnChoiceMatrix.vue +710 -0
- package/src/components/CnChoiceMatrix/index.js +9 -0
- package/src/components/CnCountdownWidget/CnCountdownWidget.vue +223 -28
- package/src/components/CnCreateFormWidget/CnCreateFormWidget.vue +97 -6
- package/src/components/CnDataMatrix/CnDataMatrix.vue +199 -13
- package/src/components/CnDisplayScreen/CnDisplayScreen.vue +308 -0
- package/src/components/CnDisplayScreen/index.js +9 -0
- package/src/components/CnDurationField/CnDurationField.vue +330 -5
- package/src/components/CnFormDialog/CnFormDialog.vue +4 -0
- package/src/components/CnGeoCaptureField/CnGeoCaptureField.vue +148 -0
- package/src/components/CnGeoCaptureField/index.js +9 -0
- package/src/components/CnMarkdownEditor/CnMarkdownEditor.vue +139 -1
- package/src/components/CnQrCode/CnQrCode.vue +321 -0
- package/src/components/CnQrCode/index.js +9 -0
- package/src/components/CnReadinessChecklist/CnReadinessChecklist.vue +80 -3
- package/src/components/CnRecordListWidget/CnRecordListWidget.vue +34 -1
- package/src/components/CnRevealField/CnRevealField.vue +273 -0
- package/src/components/CnRevealField/index.js +9 -0
- package/src/components/CnTextWidget/CnTextWidget.vue +62 -3
- package/src/components/CnTransferCard/CnTransferCard.vue +205 -0
- package/src/components/CnTransferCard/index.js +9 -0
- package/src/components/CnTreeView/CnTreeNode.vue +145 -2
- package/src/components/CnTreeView/CnTreeView.vue +210 -6
- package/src/components/index.js +7 -0
- package/src/index.js +8 -0
- package/src/utils/captureLocation.js +29 -0
- package/src/utils/childRecordTotals.js +153 -0
- package/src/utils/isoDuration.js +50 -0
- package/src/utils/qr.js +681 -0
- package/src/utils/schema.js +3 -0
- package/src/utils/templateVariables.js +51 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnTextWidget.vue3.js","sources":["../../../../src/components/CnTextWidget/CnTextWidget.vue?vue&type=template&id=f00a6820&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-text-widget\" :style=\"wrapperStyle\">\n\t\t<table\n\t\t\tv-if=\"tableMode\"\n\t\t\tclass=\"cn-text-widget__table\"\n\t\t\t:style=\"tableContainerStyle\">\n\t\t\t<tbody>\n\t\t\t\t<tr v-for=\"(row, rIdx) in tableRows\" :key=\"`r-${rIdx}`\">\n\t\t\t\t\t<template v-for=\"(cell, cIdx) in row\">\n\t\t\t\t\t\t<th\n\t\t\t\t\t\t\tv-if=\"isHeaderCell(rIdx)\"\n\t\t\t\t\t\t\tv-show=\"!isPlaceholderCellAt(rIdx, cIdx)\"\n\t\t\t\t\t\t\t:key=\"`c-${rIdx}-${cIdx}`\"\n\t\t\t\t\t\t\t:rowspan=\"cell.rowSpan || 1\"\n\t\t\t\t\t\t\t:colspan=\"cell.colSpan || 1\"\n\t\t\t\t\t\t\t:style=\"headerCellStyle(cIdx)\">\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-if=\"cellHasText(cell)\"\n\t\t\t\t\t\t\t\tv-html=\"sanitizeCell(cell.text)\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\tclass=\"cn-text-widget__cell-placeholder\">\n\t\t\t\t\t\t\t\t{{ emptyCellPlaceholder }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<td\n\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\tv-show=\"!isPlaceholderCellAt(rIdx, cIdx)\"\n\t\t\t\t\t\t\t:key=\"`c-${rIdx}-${cIdx}`\"\n\t\t\t\t\t\t\t:rowspan=\"cell.rowSpan || 1\"\n\t\t\t\t\t\t\t:colspan=\"cell.colSpan || 1\"\n\t\t\t\t\t\t\t:style=\"dataCellStyle(cIdx)\">\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-if=\"cellHasText(cell)\"\n\t\t\t\t\t\t\t\tv-html=\"sanitizeCell(cell.text)\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\tclass=\"cn-text-widget__cell-placeholder\">\n\t\t\t\t\t\t\t\t{{ emptyCellPlaceholder }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</template>\n\t\t\t\t</tr>\n\t\t\t</tbody>\n\t\t</table>\n\t\t<div\n\t\t\tv-else-if=\"hasText\"\n\t\t\tclass=\"cn-text-widget__content\"\n\t\t\t:class=\"contentClass\"\n\t\t\t:style=\"contentStyle\"\n\t\t\tv-html=\"sanitizedHtml\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t<span\n\t\t\tv-else\n\t\t\tclass=\"cn-text-widget__placeholder\"\n\t\t\t:style=\"contentStyle\">\n\t\t\t{{ placeholderText }}\n\t\t</span>\n\t\t<a\n\t\t\tv-if=\"link\"\n\t\t\tclass=\"cn-text-widget__link\"\n\t\t\tdata-testid=\"cn-text-widget-link\"\n\t\t\t:href=\"link.url\"\n\t\t\t:target=\"link.external ? '_blank' : null\"\n\t\t\t:rel=\"link.external ? 'noopener noreferrer' : null\"\n\t\t\t@click=\"openLink\">\n\t\t\t{{ link.label }}\n\t\t\t<ChevronRight :size=\"16\" />\n\t\t</a>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport DOMPurify from 'dompurify'\nimport { Marked } from 'marked'\nimport ChevronRight from 'vue-material-design-icons/ChevronRight.vue'\nimport { followLinkClick, resolveHref } from '../../utils/linkNavigation.js'\nimport { isPlaceholderCell } from '../../utils/textTable.js'\n\n// Per-module `Marked` instance so configuration is scoped here and does NOT\n// mutate the global `marked` singleton (which would affect any other code in\n// the same app that imports `marked`). `gfm: true` enables tables; `breaks:\n// false` keeps CommonMark-strict newline behaviour.\nconst markedInstance = new Marked({\n\tgfm: true,\n\tbreaks: false,\n})\n\n// DOMPurify allow-list hook: author-supplied `target=_blank` links survive\n// sanitisation (we add `target` to ADD_ATTR below); the hook then appends\n// `rel=\"noopener noreferrer\"` to mitigate reverse-tabnabbing. The hook is\n// idempotent and registered once.\nlet hookRegistered = false\nfunction ensureDomPurifyHook() {\n\tif (hookRegistered) {\n\t\treturn\n\t}\n\tDOMPurify.addHook('afterSanitizeAttributes', (node) => {\n\t\tif (node.tagName === 'A' && node.getAttribute('target') === '_blank') {\n\t\t\tnode.setAttribute('rel', 'noopener noreferrer')\n\t\t}\n\t})\n\thookRegistered = true\n}\n\n/**\n * CnTextWidget — renders user-authored multi-line text (or a small table)\n * inside a dashboard cell. Text content is passed through DOMPurify before\n * injection via `v-html` so common formatting tags survive while XSS vectors\n * (`<script>`, `on*` attributes, `javascript:` URLs) are stripped.\n *\n * Persisted shape: `{text, fontSize, color, backgroundColor, textAlign,\n * contentMode, tableMode, tableData}`. Defaults: `fontSize='14px'`,\n * `color='var(--color-main-text)'`, `backgroundColor='transparent'`,\n * `textAlign='left'`. `contentMode` absent means the legacy `'html'` branch;\n * the literal `'markdown'` parses via marked (GFM tables) then sanitises\n * through the same allow-list — a single trust boundary protects both modes.\n *\n * When `tableMode === true`, the renderer draws an HTML `<table>` from\n * `tableData` instead: header rows promote row 0 to `<th>`, per-column\n * alignment is applied inline, and `colSpan` / `rowSpan` become native HTML\n * attributes. Merge-swallowed cells are hidden via `v-show` so the visual\n * grid stays rectangular.\n *\n * Registered as the `text` dashboard widget type via the renderer's\n * `index.js`.\n */\nexport default {\n\tname: 'CnTextWidget',\n\n\tcomponents: { ChevronRight },\n\n\tinject: {\n\t\t/** The app's translate function, provided by CnAppRoot. Identity outside one. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * Persisted widget content blob: `{text, fontSize, color,\n\t\t * backgroundColor, textAlign, contentMode, tableMode, tableData, link}`.\n\t\t * All keys are optional; missing keys collapse to documented defaults.\n\t\t * `text` and `link.label` go through the app's translate function.\n\t\t * `link` is `{label, route}` (a page id, or a path starting with `/`) or\n\t\t * `{label, href}` (an external URL), drawn under the text.\n\t\t *\n\t\t * @type {{text: string, fontSize: string, color: string, backgroundColor: string, textAlign: string, contentMode: string, tableMode: boolean, tableData: object, link: {label: string, route: string, href: string}}}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\t},\n\n\tcomputed: {\n\t\t/** The author text through the app's translate function, or '' when absent / non-string. */\n\t\ttext() {\n\t\t\treturn typeof this.content?.text === 'string' ? this.tr(this.content.text) : ''\n\t\t},\n\n\t\t/**\n\t\t * The link under the text, from `content.link`: `{ label, route }`\n\t\t * (a page id, or a router path when it starts with `/`) or\n\t\t * `{ label, href }` (an external URL, opened in a new tab). The label\n\t\t * goes through the app's translate function. Null without a label or\n\t\t * a target.\n\t\t *\n\t\t * @return {{label: string, url: string, location: (object|null), external: boolean}|null} The link.\n\t\t */\n\t\tlink() {\n\t\t\tconst link = this.content?.link\n\t\t\tif (!link || typeof link !== 'object' || typeof link.label !== 'string' || link.label === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tif (typeof link.route === 'string' && link.route !== '') {\n\t\t\t\tconst location = link.route.startsWith('/') ? { path: link.route } : { name: link.route }\n\t\t\t\tconst url = resolveHref(location, this.$router)\n\t\t\t\treturn url ? { label: this.tr(link.label), url, location, external: false } : null\n\t\t\t}\n\t\t\tif (typeof link.href === 'string' && link.href !== '') {\n\t\t\t\treturn { label: this.tr(link.label), url: link.href, location: null, external: true }\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\n\t\t/** Whether the text has any non-whitespace content. */\n\t\thasText() {\n\t\t\treturn this.text.trim() !== ''\n\t\t},\n\n\t\t/** Resolved content mode — only `'markdown'` switches the branch. */\n\t\tcontentMode() {\n\t\t\treturn this.content?.contentMode === 'markdown' ? 'markdown' : 'html'\n\t\t},\n\n\t\t/** CSS class selecting the markdown vs html content-spacing rules. */\n\t\tcontentClass() {\n\t\t\treturn this.contentMode === 'markdown'\n\t\t\t\t? 'cn-text-widget__content--markdown'\n\t\t\t\t: 'cn-text-widget__content--html'\n\t\t},\n\n\t\t/**\n\t\t * The HTML to render: either the raw author HTML (sanitised) or the\n\t\t * markdown rendering of the author text (sanitised). Both branches go\n\t\t * through DOMPurify, which strips `<script>`, `<style>`, `<link>`,\n\t\t * `on*` attributes, and `javascript:` URLs.\n\t\t *\n\t\t * @return {string} sanitised HTML safe for `v-html` injection.\n\t\t */\n\t\tsanitizedHtml() {\n\t\t\tlet html\n\t\t\tif (this.contentMode === 'markdown') {\n\t\t\t\ttry {\n\t\t\t\t\thtml = markedInstance.parse(this.text)\n\t\t\t\t\tif (typeof html !== 'string') {\n\t\t\t\t\t\thtml = String(html)\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Defensive: fall back to the raw text rather than crash\n\t\t\t\t\t// the dashboard if the parser throws.\n\t\t\t\t\thtml = this.text\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thtml = this.text\n\t\t\t}\n\t\t\treturn DOMPurify.sanitize(html, {\n\t\t\t\tADD_ATTR: ['target'],\n\t\t\t})\n\t\t},\n\n\t\t/** Localised placeholder shown when there is no text content. */\n\t\tplaceholderText() {\n\t\t\treturn t('nextcloud-vue', 'No text content')\n\t\t},\n\n\t\t/** Localised placeholder shown inside an empty table cell. */\n\t\temptyCellPlaceholder() {\n\t\t\treturn t('nextcloud-vue', 'Empty cell')\n\t\t},\n\n\t\t/** Resolved font size (default `14px`). */\n\t\tfontSize() {\n\t\t\treturn this.content?.fontSize || '14px'\n\t\t},\n\n\t\t/** Resolved text colour (default theme main text). */\n\t\tcolor() {\n\t\t\treturn this.content?.color || 'var(--color-main-text)'\n\t\t},\n\n\t\t/** Resolved background colour (default transparent). */\n\t\tbackgroundColor() {\n\t\t\treturn this.content?.backgroundColor || 'transparent'\n\t\t},\n\n\t\t/** Resolved text alignment (default `left`). */\n\t\ttextAlign() {\n\t\t\treturn this.content?.textAlign || 'left'\n\t\t},\n\n\t\t/** Whether the renderer is in table mode. */\n\t\ttableMode() {\n\t\t\treturn this.content?.tableMode === true\n\t\t},\n\n\t\t/** The persisted tableData object, or null. */\n\t\ttableData() {\n\t\t\treturn this.content?.tableData || null\n\t\t},\n\n\t\t/** The table rows array (empty when no table data). */\n\t\ttableRows() {\n\t\t\treturn Array.isArray(this.tableData?.rows) ? this.tableData.rows : []\n\t\t},\n\n\t\t/** Whether row 0 should render as a header row. */\n\t\theaderRow() {\n\t\t\treturn this.tableData?.headerRow === true\n\t\t},\n\n\t\t/** Per-column text-alignment array. */\n\t\tcolumnAlignments() {\n\t\t\tconst aligns = this.tableData?.columnAlignments\n\t\t\treturn Array.isArray(aligns) ? aligns : []\n\t\t},\n\n\t\t/** Inline style for the flex wrapper. */\n\t\twrapperStyle() {\n\t\t\treturn {\n\t\t\t\twidth: '100%',\n\t\t\t\theight: '100%',\n\t\t\t\tpadding: '16px',\n\t\t\t\tdisplay: 'flex',\n\t\t\t\t'align-items': 'center',\n\t\t\t\t'justify-content': 'center',\n\t\t\t\toverflow: 'auto',\n\t\t\t\t'background-color': this.backgroundColor,\n\t\t\t\t...(this.link ? { 'flex-direction': 'column', gap: '8px', 'align-items': 'flex-start' } : {}),\n\t\t\t}\n\t\t},\n\n\t\t/** Inline style for the text / placeholder content. */\n\t\tcontentStyle() {\n\t\t\tconst base = {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\t'text-align': this.textAlign,\n\t\t\t\tcolor: this.color,\n\t\t\t\twidth: '100%',\n\t\t\t\t'overflow-wrap': 'break-word',\n\t\t\t}\n\t\t\tif (!this.hasText) {\n\t\t\t\tbase['font-style'] = 'italic'\n\t\t\t\tbase.color = 'var(--color-text-maxcontrast)'\n\t\t\t}\n\t\t\treturn base\n\t\t},\n\n\t\t/** Inline style for the table container. */\n\t\ttableContainerStyle() {\n\t\t\treturn {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\tcolor: this.color,\n\t\t\t\twidth: '100%',\n\t\t\t}\n\t\t},\n\t},\n\n\tcreated() {\n\t\tensureDomPurifyHook()\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * A manifest string through the app's translate function.\n\t\t *\n\t\t * @param {string} text The string.\n\t\t * @return {string} The translated string.\n\t\t */\n\t\ttr(text) {\n\t\t\treturn typeof this.cnTranslate === 'function' ? this.cnTranslate(text) : text\n\t\t},\n\n\t\t/**\n\t\t * Route a plain click on an in-app link, so the page does not reload.\n\t\t *\n\t\t * @param {MouseEvent} event The click.\n\t\t */\n\t\topenLink(event) {\n\t\t\tif (this.link && !this.link.external) {\n\t\t\t\tfollowLinkClick(event, this.link.location, this.$router)\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Run cell text through DOMPurify so the table-mode render path has\n\t\t * the same XSS-stripping guarantees as the text-mode path.\n\t\t *\n\t\t * @param {string} text raw cell text (may contain HTML).\n\t\t * @return {string} sanitised HTML safe to render via `v-html`.\n\t\t */\n\t\tsanitizeCell(text) {\n\t\t\treturn DOMPurify.sanitize(typeof text === 'string' ? text : '')\n\t\t},\n\n\t\t/**\n\t\t * Whether the given row index renders as `<th>` (header row).\n\t\t *\n\t\t * @param {number} rIdx the 0-based row index.\n\t\t * @return {boolean} true when row 0 and the header flag is set.\n\t\t */\n\t\tisHeaderCell(rIdx) {\n\t\t\treturn this.headerRow && rIdx === 0\n\t\t},\n\n\t\t/**\n\t\t * Whether a cell is covered by another cell's `rowSpan` / `colSpan`\n\t\t * and so must be hidden to keep the grid rectangular.\n\t\t *\n\t\t * @param {number} rIdx the row index.\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {boolean} true when the cell is a covered placeholder.\n\t\t */\n\t\tisPlaceholderCellAt(rIdx, cIdx) {\n\t\t\treturn isPlaceholderCell(this.tableRows, rIdx, cIdx)\n\t\t},\n\n\t\t/**\n\t\t * Whether a cell has any non-whitespace text.\n\t\t *\n\t\t * @param {object} cell the cell object.\n\t\t * @return {boolean} true when the cell has text.\n\t\t */\n\t\tcellHasText(cell) {\n\t\t\treturn typeof cell?.text === 'string' && cell.text.trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * Inline style for a data cell at a given column.\n\t\t *\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {object} the cell style object.\n\t\t */\n\t\tdataCellStyle(cIdx) {\n\t\t\treturn {\n\t\t\t\t'text-align': this.columnAlignments[cIdx] || 'left',\n\t\t\t\tborder: '1px solid var(--color-border)',\n\t\t\t\tpadding: '8px',\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Inline style for a header cell at a given column.\n\t\t *\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {object} the header cell style object.\n\t\t */\n\t\theaderCellStyle(cIdx) {\n\t\t\treturn {\n\t\t\t\t...this.dataCellStyle(cIdx),\n\t\t\t\t'background-color': 'var(--color-background-hover)',\n\t\t\t\t'font-weight': 'bold',\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-text-widget {\n\twidth: 100%;\n\theight: 100%;\n}\n\n.cn-text-widget__content,\n.cn-text-widget__placeholder {\n\t/* Safety net — ensures long URLs / words inside the sanitised HTML wrap\n\t rather than overflowing horizontally. */\n\toverflow-wrap: break-word;\n\tmax-width: 100%;\n}\n\n/* Restore inline-emphasis semantics inside rendered content. Nextcloud's\n server CSS styles bare <em> as muted (var(--color-text-maxcontrast)) and can\n drop the italic, so `_x_` / `**_x_**` looked greyed-out and non-italic. Force\n italic <em> / bold <strong> that inherit the widget's own text colour. */\n.cn-text-widget :deep(em),\n.cn-text-widget :deep(i) {\n\tfont-style: italic;\n\tcolor: inherit;\n}\n\n.cn-text-widget :deep(strong),\n.cn-text-widget :deep(b) {\n\tfont-weight: bold;\n\tcolor: inherit;\n}\n\n/* Nextcloud's server CSS strips list markers/indent (`list-style: none`,\n no padding), so rendered `<ul>`/`<ol>` looked like plain text. Restore\n bullets/numbers and indentation, including nested levels. */\n.cn-text-widget :deep(ul),\n.cn-text-widget :deep(ol) {\n\tmargin: 4px 0;\n\tpadding-left: 1.5em;\n}\n\n.cn-text-widget :deep(ul) {\n\tlist-style: disc outside;\n}\n\n.cn-text-widget :deep(ol) {\n\tlist-style: decimal outside;\n}\n\n.cn-text-widget :deep(ul ul) {\n\tlist-style-type: circle;\n}\n\n.cn-text-widget :deep(ul ul ul) {\n\tlist-style-type: square;\n}\n\n.cn-text-widget :deep(li) {\n\tdisplay: list-item;\n}\n\n/* Nextcloud's server CSS flattens heading sizes (e.g. h1 → 100%, so it fell\n back to the ~14px body size while h2 stayed 1.8em), leaving them oddly\n scaled. Apply a consistent em-based scale that grows with the widget's own\n font size. */\n.cn-text-widget :deep(h1) {\n\tfont-size: 2em;\n}\n\n.cn-text-widget :deep(h2) {\n\tfont-size: 1.5em;\n}\n\n.cn-text-widget :deep(h3) {\n\tfont-size: 1.25em;\n}\n\n.cn-text-widget :deep(h4) {\n\tfont-size: 1.1em;\n}\n\n.cn-text-widget :deep(h5) {\n\tfont-size: 1em;\n}\n\n.cn-text-widget :deep(h6) {\n\tfont-size: 0.85em;\n}\n\n.cn-text-widget__content--markdown :deep(h1),\n.cn-text-widget__content--markdown :deep(h2),\n.cn-text-widget__content--markdown :deep(h3),\n.cn-text-widget__content--markdown :deep(h4),\n.cn-text-widget__content--markdown :deep(h5),\n.cn-text-widget__content--markdown :deep(h6) {\n\tmargin: 8px 0 4px;\n\tfont-weight: 600;\n\tline-height: 1.3;\n}\n\n.cn-text-widget__content--markdown :deep(p),\n.cn-text-widget__content--markdown :deep(ul),\n.cn-text-widget__content--markdown :deep(ol),\n.cn-text-widget__content--markdown :deep(blockquote) {\n\tmargin: 4px 0;\n}\n\n.cn-text-widget__content--markdown :deep(code) {\n\tpadding: 1px 4px;\n\tborder-radius: 3px;\n\tbackground: var(--color-background-hover);\n\tfont-family: var(--font-monospace, monospace);\n\tfont-size: 0.95em;\n}\n\n.cn-text-widget__content--markdown :deep(pre) {\n\tpadding: 8px;\n\tborder-radius: var(--border-radius);\n\tbackground: var(--color-background-hover);\n\toverflow: auto;\n}\n\n.cn-text-widget__content--markdown :deep(pre) :deep(code) {\n\tpadding: 0;\n\tbackground: transparent;\n}\n\n.cn-text-widget__content--markdown :deep(blockquote) {\n\tpadding-left: 8px;\n\tborder-left: 3px solid var(--color-border);\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-text-widget__content--markdown :deep(table) {\n\tborder-collapse: collapse;\n\tmargin: 4px 0;\n}\n\n.cn-text-widget__content--markdown :deep(th),\n.cn-text-widget__content--markdown :deep(td) {\n\tpadding: 4px 8px;\n\tborder: 1px solid var(--color-border);\n}\n\n.cn-text-widget__table {\n\tborder-collapse: collapse;\n\twidth: 100%;\n}\n\n.cn-text-widget__table th,\n.cn-text-widget__table td {\n\toverflow-wrap: break-word;\n\tvertical-align: top;\n}\n\n.cn-text-widget__cell-placeholder {\n\tcolor: var(--color-text-maxcontrast);\n\tfont-style: italic;\n}\n\n.cn-text-widget__link {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 2px;\n\tfont-size: 14px;\n\tfont-weight: 600;\n\tcolor: var(--color-primary-element);\n\ttext-decoration: none;\n}\n\n.cn-text-widget__link:hover,\n.cn-text-widget__link:focus-visible {\n\ttext-decoration: underline;\n}\n</style>\n"],"names":["_createElementBlock","_createElementVNode","_Fragment","_renderList","_normalizeStyle","_toDisplayString","_normalizeClass"],"mappings":";;;;;;AA+BQ,EAAA,KAAI,EAAA,kCAAA;;;;;;AAgBJ,EAAA,KAAA,EAAA,kCAAA;;;;;;;;uBApCLA;AAAG,IAAA,KAAG,EAAA,gBAAA;AAAA,IAAA,KAAA,iBAAA,QAAA,CAAA,YAAA,CAAA;;KAEA,QAAS,CAAA,SAAA;wCAyCR,CAAA,OAAA,EAAA;;AAxCJ,UAAA,KAAE,EAAA,uBAAA;eACC,iBAAE,QAAmB,CAAA,mBAAA,CAAA;;UACvBC,kBAqCI,CAAA,OAAA,EAAA,IAAA,EAAA;iDADFC,QAnCqB,EAAA,IAAA,EAAAC,UAAA,CAAA,QAAA,CAAA,SAAE,EAAhB,CAAA,GAAG,EAAE,IAAI,KAAA;qDAmChB,CAAA,IAAA,EAAA;AAnCuB,gBAAA,GAAA,OAAA,IAAA,CAAA,CAAA;;qDAkChBD,QAjCkB,EAAA,IAAA,EAAAC,UAAA,CAAA,GAAA,EAAX,CAAA,IAAI,EAAC,IAAK,KAAA;;AAEpB,oBAAA,CAAA,QAAA,CAAA,YAAY,CAAC,IAAI,CAAA;uEAcnB,CAAA,IAAA,EAAA;0BAZH,GAAG,EAAA,CAAA,EAAA,EAAO,IAAI,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;0BACtB,OAAO,EAAE,IAAI,CAAC,OAAO,IAAA,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;AACnB,YAAA,KAAK,iBAAE,QAAY,CAAA,YAAA,CAAA;AACpB,YAAA,SAAoB,EAAZ,QAAY,CAAA,aAAA;;wBACrBN,kBAKO,CAAA,MAAA,EAAA;;AAHN,YAAA,KAAK,EAAC,6BAAI;AACT,YAAA,KAAK,iBAAE,QAAY,CAAA,YAAA,CAAA;6BACjB,QAAe,CAAA,eAAA,CAAA,EAAA,CAAA,mBAAA,CAAA;KAGZ,QAAI,CAAA,IAAA;sBADVA;;AAEA,UAAA,KAAK,EAAC,sBAAW;AACjB,UAAA,aAAW,EAAC,qBAAG;UACd,IAAI,EAAE,QAAI,CAAA,IAAA,CAAC,GAAG;UACd,MAAC,EAAA,QAAA,CAAA,IAAA,CAAA,QAAA,GAAA,QAAA,GAAA,IAAA;UACD,GAAE,EAAA,QAAA,CAAA,IAAA,CAAA,QAAA,GAAA,qBAAA,GAAA,IAAA;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"CnTextWidget.vue3.js","sources":["../../../../src/components/CnTextWidget/CnTextWidget.vue?vue&type=template&id=8e69025a&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-text-widget\" :style=\"wrapperStyle\">\n\t\t<table\n\t\t\tv-if=\"tableMode\"\n\t\t\tclass=\"cn-text-widget__table\"\n\t\t\t:style=\"tableContainerStyle\">\n\t\t\t<tbody>\n\t\t\t\t<tr v-for=\"(row, rIdx) in tableRows\" :key=\"`r-${rIdx}`\">\n\t\t\t\t\t<template v-for=\"(cell, cIdx) in row\">\n\t\t\t\t\t\t<th\n\t\t\t\t\t\t\tv-if=\"isHeaderCell(rIdx)\"\n\t\t\t\t\t\t\tv-show=\"!isPlaceholderCellAt(rIdx, cIdx)\"\n\t\t\t\t\t\t\t:key=\"`c-${rIdx}-${cIdx}`\"\n\t\t\t\t\t\t\t:rowspan=\"cell.rowSpan || 1\"\n\t\t\t\t\t\t\t:colspan=\"cell.colSpan || 1\"\n\t\t\t\t\t\t\t:style=\"headerCellStyle(cIdx)\">\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-if=\"cellHasText(cell)\"\n\t\t\t\t\t\t\t\tv-html=\"sanitizeCell(cell.text)\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\tclass=\"cn-text-widget__cell-placeholder\">\n\t\t\t\t\t\t\t\t{{ emptyCellPlaceholder }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<td\n\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\tv-show=\"!isPlaceholderCellAt(rIdx, cIdx)\"\n\t\t\t\t\t\t\t:key=\"`c-${rIdx}-${cIdx}`\"\n\t\t\t\t\t\t\t:rowspan=\"cell.rowSpan || 1\"\n\t\t\t\t\t\t\t:colspan=\"cell.colSpan || 1\"\n\t\t\t\t\t\t\t:style=\"dataCellStyle(cIdx)\">\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-if=\"cellHasText(cell)\"\n\t\t\t\t\t\t\t\tv-html=\"sanitizeCell(cell.text)\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\tclass=\"cn-text-widget__cell-placeholder\">\n\t\t\t\t\t\t\t\t{{ emptyCellPlaceholder }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</template>\n\t\t\t\t</tr>\n\t\t\t</tbody>\n\t\t</table>\n\t\t<pre\n\t\t\tv-else-if=\"monospace && hasText\"\n\t\t\tclass=\"cn-text-widget__mono\"\n\t\t\tdata-testid=\"cn-text-widget-mono\"\n\t\t\t:style=\"monoStyle\">{{ text }}</pre>\n\t\t<div\n\t\t\tv-else-if=\"hasText\"\n\t\t\tclass=\"cn-text-widget__content\"\n\t\t\t:class=\"contentClass\"\n\t\t\t:style=\"contentStyle\"\n\t\t\tv-html=\"sanitizedHtml\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t<span\n\t\t\tv-else\n\t\t\tclass=\"cn-text-widget__placeholder\"\n\t\t\t:style=\"contentStyle\">\n\t\t\t{{ placeholderText }}\n\t\t</span>\n\t\t<a\n\t\t\tv-if=\"link\"\n\t\t\tclass=\"cn-text-widget__link\"\n\t\t\tdata-testid=\"cn-text-widget-link\"\n\t\t\t:href=\"link.url\"\n\t\t\t:target=\"link.external ? '_blank' : null\"\n\t\t\t:rel=\"link.external ? 'noopener noreferrer' : null\"\n\t\t\t@click=\"openLink\">\n\t\t\t{{ link.label }}\n\t\t\t<ChevronRight :size=\"16\" />\n\t\t</a>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport DOMPurify from 'dompurify'\nimport { Marked } from 'marked'\nimport ChevronRight from 'vue-material-design-icons/ChevronRight.vue'\nimport { followLinkClick, resolveHref } from '../../utils/linkNavigation.js'\nimport { isPlaceholderCell } from '../../utils/textTable.js'\n\n// Per-module `Marked` instance so configuration is scoped here and does NOT\n// mutate the global `marked` singleton (which would affect any other code in\n// the same app that imports `marked`). `gfm: true` enables tables; `breaks:\n// false` keeps CommonMark-strict newline behaviour.\nconst markedInstance = new Marked({\n\tgfm: true,\n\tbreaks: false,\n})\n\n// DOMPurify allow-list hook: author-supplied `target=_blank` links survive\n// sanitisation (we add `target` to ADD_ATTR below); the hook then appends\n// `rel=\"noopener noreferrer\"` to mitigate reverse-tabnabbing. The hook is\n// idempotent and registered once.\nlet hookRegistered = false\nfunction ensureDomPurifyHook() {\n\tif (hookRegistered) {\n\t\treturn\n\t}\n\tDOMPurify.addHook('afterSanitizeAttributes', (node) => {\n\t\tif (node.tagName === 'A' && node.getAttribute('target') === '_blank') {\n\t\t\tnode.setAttribute('rel', 'noopener noreferrer')\n\t\t}\n\t})\n\thookRegistered = true\n}\n\n/**\n * CnTextWidget — renders user-authored multi-line text (or a small table)\n * inside a dashboard cell. Text content is passed through DOMPurify before\n * injection via `v-html` so common formatting tags survive while XSS vectors\n * (`<script>`, `on*` attributes, `javascript:` URLs) are stripped.\n *\n * Persisted shape: `{text, fontSize, color, backgroundColor, textAlign,\n * contentMode, tableMode, tableData}`. Defaults: `fontSize='14px'`,\n * `color='var(--color-main-text)'`, `backgroundColor='transparent'`,\n * `textAlign='left'`. `contentMode` absent means the legacy `'html'` branch;\n * the literal `'markdown'` parses via marked (GFM tables) then sanitises\n * through the same allow-list — a single trust boundary protects both modes.\n *\n * When `tableMode === true`, the renderer draws an HTML `<table>` from\n * `tableData` instead: header rows promote row 0 to `<th>`, per-column\n * alignment is applied inline, and `colSpan` / `rowSpan` become native HTML\n * attributes. Merge-swallowed cells are hidden via `v-show` so the visual\n * grid stays rectangular.\n *\n * With `monospace: true` the text is shown as typed, in a fixed-width font\n * with its spaces and line breaks kept, and is never parsed as HTML or\n * markdown: a receipt or a log line. `textField` reads the text from that\n * field of the detail page's object instead of `text`.\n *\n * Registered as the `text` dashboard widget type via the renderer's\n * `index.js`.\n */\nexport default {\n\tname: 'CnTextWidget',\n\n\tcomponents: { ChevronRight },\n\n\tinject: {\n\t\t/** The app's translate function, provided by CnAppRoot. Identity outside one. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * Persisted widget content blob: `{text, fontSize, color,\n\t\t * backgroundColor, textAlign, contentMode, tableMode, tableData, link,\n\t\t * monospace, textField}`.\n\t\t * All keys are optional; missing keys collapse to documented defaults.\n\t\t * `text` and `link.label` go through the app's translate function.\n\t\t * `link` is `{label, route}` (a page id, or a path starting with `/`) or\n\t\t * `{label, href}` (an external URL), drawn under the text.\n\t\t * `monospace` shows the text as typed in a fixed-width font;\n\t\t * `textField` reads the text from that field of `objectData`.\n\t\t *\n\t\t * @type {{text: string, fontSize: string, color: string, backgroundColor: string, textAlign: string, contentMode: string, tableMode: boolean, tableData: object, link: {label: string, route: string, href: string}, monospace: boolean, textField: string}}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** The detail page's object, which `content.textField` reads from. */\n\t\tobjectData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The text: `content.textField` of the object as it is, else `content.text` translated; '' when absent.\n\t\t *\n\t\t * @spec openspec/changes/text-widget-monospace/tasks.md#task-2\n\t\t */\n\t\ttext() {\n\t\t\tconst field = this.content?.textField\n\t\t\tif (typeof field === 'string' && field !== '') {\n\t\t\t\tconst value = this.objectData?.[field]\n\t\t\t\treturn value === undefined || value === null ? '' : String(value)\n\t\t\t}\n\t\t\treturn typeof this.content?.text === 'string' ? this.tr(this.content.text) : ''\n\t\t},\n\n\t\t/**\n\t\t * Whether the text shows as typed, in a fixed-width font.\n\t\t *\n\t\t * @spec openspec/changes/text-widget-monospace/tasks.md#task-1\n\t\t */\n\t\tmonospace() {\n\t\t\treturn this.content?.monospace === true\n\t\t},\n\n\t\t/** Inline style for the fixed-width text. */\n\t\tmonoStyle() {\n\t\t\treturn {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\tcolor: this.color,\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The link under the text, from `content.link`: `{ label, route }`\n\t\t * (a page id, or a router path when it starts with `/`) or\n\t\t * `{ label, href }` (an external URL, opened in a new tab). The label\n\t\t * goes through the app's translate function. Null without a label or\n\t\t * a target.\n\t\t *\n\t\t * @return {{label: string, url: string, location: (object|null), external: boolean}|null} The link.\n\t\t */\n\t\tlink() {\n\t\t\tconst link = this.content?.link\n\t\t\tif (!link || typeof link !== 'object' || typeof link.label !== 'string' || link.label === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tif (typeof link.route === 'string' && link.route !== '') {\n\t\t\t\tconst location = link.route.startsWith('/') ? { path: link.route } : { name: link.route }\n\t\t\t\tconst url = resolveHref(location, this.$router)\n\t\t\t\treturn url ? { label: this.tr(link.label), url, location, external: false } : null\n\t\t\t}\n\t\t\tif (typeof link.href === 'string' && link.href !== '') {\n\t\t\t\treturn { label: this.tr(link.label), url: link.href, location: null, external: true }\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\n\t\t/** Whether the text has any non-whitespace content. */\n\t\thasText() {\n\t\t\treturn this.text.trim() !== ''\n\t\t},\n\n\t\t/** Resolved content mode — only `'markdown'` switches the branch. */\n\t\tcontentMode() {\n\t\t\treturn this.content?.contentMode === 'markdown' ? 'markdown' : 'html'\n\t\t},\n\n\t\t/** CSS class selecting the markdown vs html content-spacing rules. */\n\t\tcontentClass() {\n\t\t\treturn this.contentMode === 'markdown'\n\t\t\t\t? 'cn-text-widget__content--markdown'\n\t\t\t\t: 'cn-text-widget__content--html'\n\t\t},\n\n\t\t/**\n\t\t * The HTML to render: either the raw author HTML (sanitised) or the\n\t\t * markdown rendering of the author text (sanitised). Both branches go\n\t\t * through DOMPurify, which strips `<script>`, `<style>`, `<link>`,\n\t\t * `on*` attributes, and `javascript:` URLs.\n\t\t *\n\t\t * @return {string} sanitised HTML safe for `v-html` injection.\n\t\t */\n\t\tsanitizedHtml() {\n\t\t\tlet html\n\t\t\tif (this.contentMode === 'markdown') {\n\t\t\t\ttry {\n\t\t\t\t\thtml = markedInstance.parse(this.text)\n\t\t\t\t\tif (typeof html !== 'string') {\n\t\t\t\t\t\thtml = String(html)\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Defensive: fall back to the raw text rather than crash\n\t\t\t\t\t// the dashboard if the parser throws.\n\t\t\t\t\thtml = this.text\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thtml = this.text\n\t\t\t}\n\t\t\treturn DOMPurify.sanitize(html, {\n\t\t\t\tADD_ATTR: ['target'],\n\t\t\t})\n\t\t},\n\n\t\t/** Localised placeholder shown when there is no text content. */\n\t\tplaceholderText() {\n\t\t\treturn t('nextcloud-vue', 'No text content')\n\t\t},\n\n\t\t/** Localised placeholder shown inside an empty table cell. */\n\t\temptyCellPlaceholder() {\n\t\t\treturn t('nextcloud-vue', 'Empty cell')\n\t\t},\n\n\t\t/** Resolved font size (default `14px`). */\n\t\tfontSize() {\n\t\t\treturn this.content?.fontSize || '14px'\n\t\t},\n\n\t\t/** Resolved text colour (default theme main text). */\n\t\tcolor() {\n\t\t\treturn this.content?.color || 'var(--color-main-text)'\n\t\t},\n\n\t\t/** Resolved background colour (default transparent). */\n\t\tbackgroundColor() {\n\t\t\treturn this.content?.backgroundColor || 'transparent'\n\t\t},\n\n\t\t/** Resolved text alignment (default `left`). */\n\t\ttextAlign() {\n\t\t\treturn this.content?.textAlign || 'left'\n\t\t},\n\n\t\t/** Whether the renderer is in table mode. */\n\t\ttableMode() {\n\t\t\treturn this.content?.tableMode === true\n\t\t},\n\n\t\t/** The persisted tableData object, or null. */\n\t\ttableData() {\n\t\t\treturn this.content?.tableData || null\n\t\t},\n\n\t\t/** The table rows array (empty when no table data). */\n\t\ttableRows() {\n\t\t\treturn Array.isArray(this.tableData?.rows) ? this.tableData.rows : []\n\t\t},\n\n\t\t/** Whether row 0 should render as a header row. */\n\t\theaderRow() {\n\t\t\treturn this.tableData?.headerRow === true\n\t\t},\n\n\t\t/** Per-column text-alignment array. */\n\t\tcolumnAlignments() {\n\t\t\tconst aligns = this.tableData?.columnAlignments\n\t\t\treturn Array.isArray(aligns) ? aligns : []\n\t\t},\n\n\t\t/** Inline style for the flex wrapper. */\n\t\twrapperStyle() {\n\t\t\treturn {\n\t\t\t\twidth: '100%',\n\t\t\t\theight: '100%',\n\t\t\t\tpadding: '16px',\n\t\t\t\tdisplay: 'flex',\n\t\t\t\t'align-items': 'center',\n\t\t\t\t'justify-content': 'center',\n\t\t\t\toverflow: 'auto',\n\t\t\t\t'background-color': this.backgroundColor,\n\t\t\t\t...(this.link ? { 'flex-direction': 'column', gap: '8px', 'align-items': 'flex-start' } : {}),\n\t\t\t}\n\t\t},\n\n\t\t/** Inline style for the text / placeholder content. */\n\t\tcontentStyle() {\n\t\t\tconst base = {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\t'text-align': this.textAlign,\n\t\t\t\tcolor: this.color,\n\t\t\t\twidth: '100%',\n\t\t\t\t'overflow-wrap': 'break-word',\n\t\t\t}\n\t\t\tif (!this.hasText) {\n\t\t\t\tbase['font-style'] = 'italic'\n\t\t\t\tbase.color = 'var(--color-text-maxcontrast)'\n\t\t\t}\n\t\t\treturn base\n\t\t},\n\n\t\t/** Inline style for the table container. */\n\t\ttableContainerStyle() {\n\t\t\treturn {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\tcolor: this.color,\n\t\t\t\twidth: '100%',\n\t\t\t}\n\t\t},\n\t},\n\n\tcreated() {\n\t\tensureDomPurifyHook()\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * A manifest string through the app's translate function.\n\t\t *\n\t\t * @param {string} text The string.\n\t\t * @return {string} The translated string.\n\t\t */\n\t\ttr(text) {\n\t\t\treturn typeof this.cnTranslate === 'function' ? this.cnTranslate(text) : text\n\t\t},\n\n\t\t/**\n\t\t * Route a plain click on an in-app link, so the page does not reload.\n\t\t *\n\t\t * @param {MouseEvent} event The click.\n\t\t */\n\t\topenLink(event) {\n\t\t\tif (this.link && !this.link.external) {\n\t\t\t\tfollowLinkClick(event, this.link.location, this.$router)\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Run cell text through DOMPurify so the table-mode render path has\n\t\t * the same XSS-stripping guarantees as the text-mode path.\n\t\t *\n\t\t * @param {string} text raw cell text (may contain HTML).\n\t\t * @return {string} sanitised HTML safe to render via `v-html`.\n\t\t */\n\t\tsanitizeCell(text) {\n\t\t\treturn DOMPurify.sanitize(typeof text === 'string' ? text : '')\n\t\t},\n\n\t\t/**\n\t\t * Whether the given row index renders as `<th>` (header row).\n\t\t *\n\t\t * @param {number} rIdx the 0-based row index.\n\t\t * @return {boolean} true when row 0 and the header flag is set.\n\t\t */\n\t\tisHeaderCell(rIdx) {\n\t\t\treturn this.headerRow && rIdx === 0\n\t\t},\n\n\t\t/**\n\t\t * Whether a cell is covered by another cell's `rowSpan` / `colSpan`\n\t\t * and so must be hidden to keep the grid rectangular.\n\t\t *\n\t\t * @param {number} rIdx the row index.\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {boolean} true when the cell is a covered placeholder.\n\t\t */\n\t\tisPlaceholderCellAt(rIdx, cIdx) {\n\t\t\treturn isPlaceholderCell(this.tableRows, rIdx, cIdx)\n\t\t},\n\n\t\t/**\n\t\t * Whether a cell has any non-whitespace text.\n\t\t *\n\t\t * @param {object} cell the cell object.\n\t\t * @return {boolean} true when the cell has text.\n\t\t */\n\t\tcellHasText(cell) {\n\t\t\treturn typeof cell?.text === 'string' && cell.text.trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * Inline style for a data cell at a given column.\n\t\t *\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {object} the cell style object.\n\t\t */\n\t\tdataCellStyle(cIdx) {\n\t\t\treturn {\n\t\t\t\t'text-align': this.columnAlignments[cIdx] || 'left',\n\t\t\t\tborder: '1px solid var(--color-border)',\n\t\t\t\tpadding: '8px',\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Inline style for a header cell at a given column.\n\t\t *\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {object} the header cell style object.\n\t\t */\n\t\theaderCellStyle(cIdx) {\n\t\t\treturn {\n\t\t\t\t...this.dataCellStyle(cIdx),\n\t\t\t\t'background-color': 'var(--color-background-hover)',\n\t\t\t\t'font-weight': 'bold',\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-text-widget {\n\twidth: 100%;\n\theight: 100%;\n}\n\n.cn-text-widget__content,\n.cn-text-widget__mono {\n\twidth: 100%;\n\tmargin: 0;\n\tpadding: 12px;\n\tfont-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;\n\tline-height: 1.4;\n\twhite-space: pre-wrap;\n\toverflow-wrap: anywhere;\n\ttext-align: start;\n\tbackground: var(--color-background-dark);\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n}\n\n.cn-text-widget__placeholder {\n\t/* Safety net — ensures long URLs / words inside the sanitised HTML wrap\n\t rather than overflowing horizontally. */\n\toverflow-wrap: break-word;\n\tmax-width: 100%;\n}\n\n/* Restore inline-emphasis semantics inside rendered content. Nextcloud's\n server CSS styles bare <em> as muted (var(--color-text-maxcontrast)) and can\n drop the italic, so `_x_` / `**_x_**` looked greyed-out and non-italic. Force\n italic <em> / bold <strong> that inherit the widget's own text colour. */\n.cn-text-widget :deep(em),\n.cn-text-widget :deep(i) {\n\tfont-style: italic;\n\tcolor: inherit;\n}\n\n.cn-text-widget :deep(strong),\n.cn-text-widget :deep(b) {\n\tfont-weight: bold;\n\tcolor: inherit;\n}\n\n/* Nextcloud's server CSS strips list markers/indent (`list-style: none`,\n no padding), so rendered `<ul>`/`<ol>` looked like plain text. Restore\n bullets/numbers and indentation, including nested levels. */\n.cn-text-widget :deep(ul),\n.cn-text-widget :deep(ol) {\n\tmargin: 4px 0;\n\tpadding-left: 1.5em;\n}\n\n.cn-text-widget :deep(ul) {\n\tlist-style: disc outside;\n}\n\n.cn-text-widget :deep(ol) {\n\tlist-style: decimal outside;\n}\n\n.cn-text-widget :deep(ul ul) {\n\tlist-style-type: circle;\n}\n\n.cn-text-widget :deep(ul ul ul) {\n\tlist-style-type: square;\n}\n\n.cn-text-widget :deep(li) {\n\tdisplay: list-item;\n}\n\n/* Nextcloud's server CSS flattens heading sizes (e.g. h1 → 100%, so it fell\n back to the ~14px body size while h2 stayed 1.8em), leaving them oddly\n scaled. Apply a consistent em-based scale that grows with the widget's own\n font size. */\n.cn-text-widget :deep(h1) {\n\tfont-size: 2em;\n}\n\n.cn-text-widget :deep(h2) {\n\tfont-size: 1.5em;\n}\n\n.cn-text-widget :deep(h3) {\n\tfont-size: 1.25em;\n}\n\n.cn-text-widget :deep(h4) {\n\tfont-size: 1.1em;\n}\n\n.cn-text-widget :deep(h5) {\n\tfont-size: 1em;\n}\n\n.cn-text-widget :deep(h6) {\n\tfont-size: 0.85em;\n}\n\n.cn-text-widget__content--markdown :deep(h1),\n.cn-text-widget__content--markdown :deep(h2),\n.cn-text-widget__content--markdown :deep(h3),\n.cn-text-widget__content--markdown :deep(h4),\n.cn-text-widget__content--markdown :deep(h5),\n.cn-text-widget__content--markdown :deep(h6) {\n\tmargin: 8px 0 4px;\n\tfont-weight: 600;\n\tline-height: 1.3;\n}\n\n.cn-text-widget__content--markdown :deep(p),\n.cn-text-widget__content--markdown :deep(ul),\n.cn-text-widget__content--markdown :deep(ol),\n.cn-text-widget__content--markdown :deep(blockquote) {\n\tmargin: 4px 0;\n}\n\n.cn-text-widget__content--markdown :deep(code) {\n\tpadding: 1px 4px;\n\tborder-radius: 3px;\n\tbackground: var(--color-background-hover);\n\tfont-family: var(--font-monospace, monospace);\n\tfont-size: 0.95em;\n}\n\n.cn-text-widget__content--markdown :deep(pre) {\n\tpadding: 8px;\n\tborder-radius: var(--border-radius);\n\tbackground: var(--color-background-hover);\n\toverflow: auto;\n}\n\n.cn-text-widget__content--markdown :deep(pre) :deep(code) {\n\tpadding: 0;\n\tbackground: transparent;\n}\n\n.cn-text-widget__content--markdown :deep(blockquote) {\n\tpadding-left: 8px;\n\tborder-left: 3px solid var(--color-border);\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-text-widget__content--markdown :deep(table) {\n\tborder-collapse: collapse;\n\tmargin: 4px 0;\n}\n\n.cn-text-widget__content--markdown :deep(th),\n.cn-text-widget__content--markdown :deep(td) {\n\tpadding: 4px 8px;\n\tborder: 1px solid var(--color-border);\n}\n\n.cn-text-widget__table {\n\tborder-collapse: collapse;\n\twidth: 100%;\n}\n\n.cn-text-widget__table th,\n.cn-text-widget__table td {\n\toverflow-wrap: break-word;\n\tvertical-align: top;\n}\n\n.cn-text-widget__cell-placeholder {\n\tcolor: var(--color-text-maxcontrast);\n\tfont-style: italic;\n}\n\n.cn-text-widget__link {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 2px;\n\tfont-size: 14px;\n\tfont-weight: 600;\n\tcolor: var(--color-primary-element);\n\ttext-decoration: none;\n}\n\n.cn-text-widget__link:hover,\n.cn-text-widget__link:focus-visible {\n\ttext-decoration: underline;\n}\n</style>\n"],"names":["_createElementBlock","_createElementVNode","_Fragment","_renderList","_normalizeStyle","_toDisplayString","_normalizeClass"],"mappings":";;;;;;AA+BQ,EAAA,KAAI,EAAA,kCAAA;;;;;;AAgBJ,EAAA,KAAA,EAAA,kCAAA;;;;;;;;uBApCLA;AAAG,IAAA,KAAG,EAAA,gBAAA;AAAA,IAAA,KAAA,iBAAA,QAAA,CAAA,YAAA,CAAA;;KAEA,QAAS,CAAA,SAAA;wCAyCR,CAAA,OAAA,EAAA;;AAxCJ,UAAA,KAAE,EAAA,uBAAA;eACC,iBAAE,QAAmB,CAAA,mBAAA,CAAA;;UACvBC,kBAqCI,CAAA,OAAA,EAAA,IAAA,EAAA;iDADFC,QAnCqB,EAAA,IAAA,EAAAC,UAAA,CAAA,QAAA,CAAA,SAAE,EAAhB,CAAA,GAAG,EAAE,IAAI,KAAA;qDAmChB,CAAA,IAAA,EAAA;AAnCuB,gBAAA,GAAA,OAAA,IAAA,CAAA,CAAA;;qDAkChBD,QAjCkB,EAAA,IAAA,EAAAC,UAAA,CAAA,GAAA,EAAX,CAAA,IAAI,EAAC,IAAK,KAAA;;AAEpB,oBAAA,CAAA,QAAA,CAAA,YAAY,CAAC,IAAI,CAAA;uEAcnB,CAAA,IAAA,EAAA;0BAZH,GAAG,EAAA,CAAA,EAAA,EAAO,IAAI,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;0BACtB,OAAO,EAAE,IAAI,CAAC,OAAO,IAAA,CAAA;0BACrB,OAAG,EAAA,IAAA,CAAA,OAAA,IAAA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E,QAAS,CAAA,SAAA,CAAA;6BAAG,QAAA,CAAA,IAAA,CAAA,EAAA,CAAA,mBAAA;WAEjB,QAAA,CAAA,OAAA;0BADHA,kBAKoB,CAAA,KAAA,EAAA;;cAHpB,KAAK,EAAAM,cAAA,CAAA,CAAA,yBAAA,EACG,QAAY,CAAA,YAAA,CAAA,CAAA;AACnB,cAAA,KAAK,iBAAE,QAAY,CAAA,YAAA,CAAA;AACpB,cAAA,SAAoB,EAAZ,QAAY,CAAA,aAAA;;0BACrBN,kBAKO,CAAA,MAAA,EAAA;;AAHN,cAAA,KAAK,EAAC,6BAAI;AACT,cAAA,KAAK,iBAAE,QAAY,CAAA,YAAA,CAAA;+BACjB,QAAe,CAAA,eAAA,CAAA,EAAA,CAAA,mBAAA,CAAA;KAGZ,QAAI,CAAA,IAAA;sBADVA;;AAEA,UAAA,KAAK,EAAC,sBAAW;AACjB,UAAA,aAAW,EAAC,qBAAG;UACd,IAAI,EAAE,QAAI,CAAA,IAAA,CAAC,GAAG;UACd,MAAC,EAAA,QAAA,CAAA,IAAA,CAAA,QAAA,GAAA,QAAA,GAAA,IAAA;UACD,GAAE,EAAA,QAAA,CAAA,IAAA,CAAA,QAAA,GAAA,qBAAA,GAAA,IAAA;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import script from './CnTransferCard.vue2.js';
|
|
2
|
+
import { render } from './CnTransferCard.vue3.js';
|
|
3
|
+
|
|
4
|
+
script.render = render;
|
|
5
|
+
script.__scopeId = "data-v-1a6d8aba";
|
|
6
|
+
const __sfc_main = script;
|
|
7
|
+
|
|
8
|
+
export { __sfc_main as default };
|
|
9
|
+
//# sourceMappingURL=CnTransferCard.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CnTransferCard.vue.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { translate } from '@nextcloud/l10n';
|
|
2
|
+
import { NcButton, NcProgressBar } from '@nextcloud/vue';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* CnTransferCard: a transfer that takes a while, such as taking a day's work
|
|
6
|
+
* offline (board DqInspectie "Dag synchroniseren": "32 MB van 48 MB gedownload",
|
|
7
|
+
* "nog ca. 6 minuten", a row per part, and resuming after a dropped connection).
|
|
8
|
+
*
|
|
9
|
+
* The host owns the transfer and passes where it stands. The card holds no
|
|
10
|
+
* state, so the same card serves a download, an upload or a sync.
|
|
11
|
+
*
|
|
12
|
+
* ```vue
|
|
13
|
+
* <CnTransferCard
|
|
14
|
+
* title="Sync the day"
|
|
15
|
+
* :done="32"
|
|
16
|
+
* :total="48"
|
|
17
|
+
* unit="MB"
|
|
18
|
+
* remaining-text="about 6 minutes left"
|
|
19
|
+
* :items="[{ id: 'cases', label: 'Cases of 4 addresses', state: 'Done' }]"
|
|
20
|
+
* @resume="resume" />
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @event resume The user pressed Resume on a paused transfer.
|
|
24
|
+
* @spec openspec/changes/transfer-card/specs/transfer-card/spec.md
|
|
25
|
+
*/
|
|
26
|
+
var script = {
|
|
27
|
+
name: 'CnTransferCard',
|
|
28
|
+
|
|
29
|
+
components: { NcButton, NcProgressBar },
|
|
30
|
+
|
|
31
|
+
props: {
|
|
32
|
+
/** Title, already translated. */
|
|
33
|
+
title: { type: String, default: '' },
|
|
34
|
+
/** A line under the title, already translated. */
|
|
35
|
+
subtitle: { type: String, default: '' },
|
|
36
|
+
/** How much has been transferred. */
|
|
37
|
+
done: { type: Number, default: 0 },
|
|
38
|
+
/** How much there is in total. */
|
|
39
|
+
total: { type: Number, default: 0 },
|
|
40
|
+
/** The unit of `done` and `total`, such as "MB". */
|
|
41
|
+
unit: { type: String, default: '' },
|
|
42
|
+
/** The amount line, already translated, with `{done}`, `{total}` and `{unit}`; the library default is "{done} {unit} of {total} {unit}". */
|
|
43
|
+
amountTemplate: { type: String, default: '' },
|
|
44
|
+
/** How long it will still take, already translated. */
|
|
45
|
+
remainingText: { type: String, default: '' },
|
|
46
|
+
/** A line under the bar, already translated. */
|
|
47
|
+
hint: { type: String, default: '' },
|
|
48
|
+
/** The parts: `{ id?, label, state }`, both already translated. */
|
|
49
|
+
items: { type: Array, default: () => [] },
|
|
50
|
+
/** The transfer stopped and can carry on. */
|
|
51
|
+
paused: { type: Boolean, default: false },
|
|
52
|
+
/** Says why it stopped, already translated. */
|
|
53
|
+
pausedText: { type: String, default: '' },
|
|
54
|
+
/** Label of the Resume button, already translated. */
|
|
55
|
+
resumeLabel: { type: String, default: '' },
|
|
56
|
+
/** A line at the end of the card, already translated. */
|
|
57
|
+
note: { type: String, default: '' },
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
emits: ['resume'],
|
|
61
|
+
|
|
62
|
+
computed: {
|
|
63
|
+
/** @return {number} Progress in percent, from 0 to 100; 0 with no total. */
|
|
64
|
+
percent() {
|
|
65
|
+
if (!(this.total > 0)) {
|
|
66
|
+
return 0
|
|
67
|
+
}
|
|
68
|
+
return Math.min(100, Math.max(0, Math.round((this.done / this.total) * 100)))
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
/** @return {string} The amount in words. */
|
|
72
|
+
amountText() {
|
|
73
|
+
const values = { done: String(this.done), total: String(this.total), unit: this.unit };
|
|
74
|
+
if (this.amountTemplate) {
|
|
75
|
+
return this.amountTemplate.replace(/\{(done|total|unit)\}/g, (match, key) => values[key])
|
|
76
|
+
}
|
|
77
|
+
return translate('nextcloud-vue', '{done} {unit} of {total} {unit}', values)
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
methods: {
|
|
82
|
+
t: translate,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export { script as default };
|
|
87
|
+
//# sourceMappingURL=CnTransferCard.vue2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CnTransferCard.vue2.js","sources":["../../../../src/components/CnTransferCard/CnTransferCard.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<section class=\"cn-transfer-card\" data-testid=\"cn-transfer-card\">\n\t\t<header v-if=\"title || subtitle\" class=\"cn-transfer-card__header\">\n\t\t\t<h3 v-if=\"title\" class=\"cn-transfer-card__title\">\n\t\t\t\t{{ title }}\n\t\t\t</h3>\n\t\t\t<span v-if=\"subtitle\" class=\"cn-transfer-card__muted\">{{ subtitle }}</span>\n\t\t</header>\n\n\t\t<div class=\"cn-transfer-card__progress\">\n\t\t\t<span class=\"cn-transfer-card__line\">\n\t\t\t\t<strong data-testid=\"cn-transfer-amount\">{{ amountText }}</strong>\n\t\t\t\t<span v-if=\"remainingText && !paused\" class=\"cn-transfer-card__muted\" data-testid=\"cn-transfer-remaining\">{{ remainingText }}</span>\n\t\t\t</span>\n\t\t\t<NcProgressBar\n\t\t\t\t:value=\"percent\"\n\t\t\t\t:aria-label=\"amountText\"\n\t\t\t\tdata-testid=\"cn-transfer-bar\" />\n\t\t\t<span v-if=\"hint\" class=\"cn-transfer-card__muted\" data-testid=\"cn-transfer-hint\">{{ hint }}</span>\n\t\t</div>\n\n\t\t<p v-if=\"paused\"\n\t\t\tclass=\"cn-transfer-card__paused\"\n\t\t\trole=\"status\"\n\t\t\tdata-testid=\"cn-transfer-paused\">\n\t\t\t{{ pausedText || t('nextcloud-vue', 'The connection dropped. It carries on from where it stopped.') }}\n\t\t</p>\n\n\t\t<ul v-if=\"items.length > 0\" class=\"cn-transfer-card__items\">\n\t\t\t<li v-for=\"item in items\"\n\t\t\t\t:key=\"item.id ?? item.label\"\n\t\t\t\tclass=\"cn-transfer-card__item\"\n\t\t\t\tdata-testid=\"cn-transfer-item\">\n\t\t\t\t<span>{{ item.label }}</span>\n\t\t\t\t<span class=\"cn-transfer-card__muted\">{{ item.state }}</span>\n\t\t\t</li>\n\t\t</ul>\n\n\t\t<div v-if=\"paused || $slots.actions\" class=\"cn-transfer-card__actions\">\n\t\t\t<NcButton v-if=\"paused\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tdata-testid=\"cn-transfer-resume\"\n\t\t\t\t@click=\"$emit('resume')\">\n\t\t\t\t{{ resumeLabel || t('nextcloud-vue', 'Resume') }}\n\t\t\t</NcButton>\n\t\t\t<!-- @slot actions Further buttons under the card. -->\n\t\t\t<slot name=\"actions\" />\n\t\t</div>\n\n\t\t<p v-if=\"note\" class=\"cn-transfer-card__muted cn-transfer-card__note\" data-testid=\"cn-transfer-note\">\n\t\t\t{{ note }}\n\t\t</p>\n\t</section>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcProgressBar } from '@nextcloud/vue'\n\n/**\n * CnTransferCard: a transfer that takes a while, such as taking a day's work\n * offline (board DqInspectie \"Dag synchroniseren\": \"32 MB van 48 MB gedownload\",\n * \"nog ca. 6 minuten\", a row per part, and resuming after a dropped connection).\n *\n * The host owns the transfer and passes where it stands. The card holds no\n * state, so the same card serves a download, an upload or a sync.\n *\n * ```vue\n * <CnTransferCard\n * title=\"Sync the day\"\n * :done=\"32\"\n * :total=\"48\"\n * unit=\"MB\"\n * remaining-text=\"about 6 minutes left\"\n * :items=\"[{ id: 'cases', label: 'Cases of 4 addresses', state: 'Done' }]\"\n * @resume=\"resume\" />\n * ```\n *\n * @event resume The user pressed Resume on a paused transfer.\n * @spec openspec/changes/transfer-card/specs/transfer-card/spec.md\n */\nexport default {\n\tname: 'CnTransferCard',\n\n\tcomponents: { NcButton, NcProgressBar },\n\n\tprops: {\n\t\t/** Title, already translated. */\n\t\ttitle: { type: String, default: '' },\n\t\t/** A line under the title, already translated. */\n\t\tsubtitle: { type: String, default: '' },\n\t\t/** How much has been transferred. */\n\t\tdone: { type: Number, default: 0 },\n\t\t/** How much there is in total. */\n\t\ttotal: { type: Number, default: 0 },\n\t\t/** The unit of `done` and `total`, such as \"MB\". */\n\t\tunit: { type: String, default: '' },\n\t\t/** The amount line, already translated, with `{done}`, `{total}` and `{unit}`; the library default is \"{done} {unit} of {total} {unit}\". */\n\t\tamountTemplate: { type: String, default: '' },\n\t\t/** How long it will still take, already translated. */\n\t\tremainingText: { type: String, default: '' },\n\t\t/** A line under the bar, already translated. */\n\t\thint: { type: String, default: '' },\n\t\t/** The parts: `{ id?, label, state }`, both already translated. */\n\t\titems: { type: Array, default: () => [] },\n\t\t/** The transfer stopped and can carry on. */\n\t\tpaused: { type: Boolean, default: false },\n\t\t/** Says why it stopped, already translated. */\n\t\tpausedText: { type: String, default: '' },\n\t\t/** Label of the Resume button, already translated. */\n\t\tresumeLabel: { type: String, default: '' },\n\t\t/** A line at the end of the card, already translated. */\n\t\tnote: { type: String, default: '' },\n\t},\n\n\temits: ['resume'],\n\n\tcomputed: {\n\t\t/** @return {number} Progress in percent, from 0 to 100; 0 with no total. */\n\t\tpercent() {\n\t\t\tif (!(this.total > 0)) {\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\treturn Math.min(100, Math.max(0, Math.round((this.done / this.total) * 100)))\n\t\t},\n\n\t\t/** @return {string} The amount in words. */\n\t\tamountText() {\n\t\t\tconst values = { done: String(this.done), total: String(this.total), unit: this.unit }\n\t\t\tif (this.amountTemplate) {\n\t\t\t\treturn this.amountTemplate.replace(/\\{(done|total|unit)\\}/g, (match, key) => values[key])\n\t\t\t}\n\t\t\treturn t('nextcloud-vue', '{done} {unit} of {total} {unit}', values)\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\t},\n}\n</script>\n\n<style scoped>\n.cn-transfer-card {\n\tbackground: var(--color-main-background);\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius-large);\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n\tpadding: 16px 20px;\n}\n\n.cn-transfer-card__header,\n.cn-transfer-card__progress {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n}\n\n.cn-transfer-card__title {\n\tfont-size: 1.1em;\n\tmargin: 0;\n}\n\n.cn-transfer-card__muted {\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-transfer-card__line,\n.cn-transfer-card__item {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 4px 12px;\n\tjustify-content: space-between;\n}\n\n.cn-transfer-card__paused,\n.cn-transfer-card__note {\n\tmargin: 0;\n}\n\n.cn-transfer-card__items {\n\tdisplay: flex;\n\tflex-direction: column;\n\tlist-style: none;\n\tmargin: 0;\n\tpadding: 0;\n}\n\n.cn-transfer-card__item {\n\tborder-top: 1px solid var(--color-border);\n\tpadding: 8px 0;\n}\n\n.cn-transfer-card__actions {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 8px;\n}\n</style>\n"],"names":["t"],"mappings":";;;AA+DA;AACC;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAED,aAAe;AACd,CAAA,IAAI,EAAE,gBAAgB;;AAEtB,CAAA,UAAU,EAAE,EAAE,QAAQ,EAAE,eAAe;;AAEvC,CAAA,KAAK,EAAE;;AAEN,EAAA,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAC,EAAG;AACpC;AACA,EAAA,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI;AACvC;EACA,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA,EAAG;;EAElC,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA,EAAG;AACnC;EACA,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAC,EAAG;;AAEnC,EAAA,cAAc,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI;AAC7C;AACA,EAAA,aAAa,EAAE,EAAE,IAAI,EAAE,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AAC,GAAG,CAAC,CAAA;AACzF,IAAA;GACA,OAAOA,SAAC,CAAC,eAAe,EAAE,iCAAiC,EAAE,MAAM,CAAA;GACnE;EACD;;AAED,CAAA,OAAO,EAAE;KACRA,SAAC;EACD;AACF;;;;"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { resolveComponent, openBlock, createElementBlock, toDisplayString, createCommentVNode, createElementVNode, createVNode, Fragment, renderList, createBlock, withCtx, createTextVNode, renderSlot } from 'vue';
|
|
2
|
+
|
|
3
|
+
const _hoisted_1 = {
|
|
4
|
+
class: "cn-transfer-card",
|
|
5
|
+
"data-testid": "cn-transfer-card"
|
|
6
|
+
};
|
|
7
|
+
const _hoisted_2 = {
|
|
8
|
+
key: 0,
|
|
9
|
+
class: "cn-transfer-card__header"
|
|
10
|
+
};
|
|
11
|
+
const _hoisted_3 = {
|
|
12
|
+
key: 0,
|
|
13
|
+
class: "cn-transfer-card__title"
|
|
14
|
+
};
|
|
15
|
+
const _hoisted_4 = {
|
|
16
|
+
key: 1,
|
|
17
|
+
class: "cn-transfer-card__muted"
|
|
18
|
+
};
|
|
19
|
+
const _hoisted_5 = { class: "cn-transfer-card__progress" };
|
|
20
|
+
const _hoisted_6 = { class: "cn-transfer-card__line" };
|
|
21
|
+
const _hoisted_7 = { "data-testid": "cn-transfer-amount" };
|
|
22
|
+
const _hoisted_8 = {
|
|
23
|
+
key: 0,
|
|
24
|
+
class: "cn-transfer-card__muted",
|
|
25
|
+
"data-testid": "cn-transfer-remaining"
|
|
26
|
+
};
|
|
27
|
+
const _hoisted_9 = {
|
|
28
|
+
key: 0,
|
|
29
|
+
class: "cn-transfer-card__muted",
|
|
30
|
+
"data-testid": "cn-transfer-hint"
|
|
31
|
+
};
|
|
32
|
+
const _hoisted_10 = {
|
|
33
|
+
key: 1,
|
|
34
|
+
class: "cn-transfer-card__paused",
|
|
35
|
+
role: "status",
|
|
36
|
+
"data-testid": "cn-transfer-paused"
|
|
37
|
+
};
|
|
38
|
+
const _hoisted_11 = {
|
|
39
|
+
key: 2,
|
|
40
|
+
class: "cn-transfer-card__items"
|
|
41
|
+
};
|
|
42
|
+
const _hoisted_12 = { class: "cn-transfer-card__muted" };
|
|
43
|
+
const _hoisted_13 = {
|
|
44
|
+
key: 3,
|
|
45
|
+
class: "cn-transfer-card__actions"
|
|
46
|
+
};
|
|
47
|
+
const _hoisted_14 = {
|
|
48
|
+
key: 4,
|
|
49
|
+
class: "cn-transfer-card__muted cn-transfer-card__note",
|
|
50
|
+
"data-testid": "cn-transfer-note"
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
54
|
+
const _component_NcProgressBar = resolveComponent("NcProgressBar");
|
|
55
|
+
const _component_NcButton = resolveComponent("NcButton");
|
|
56
|
+
|
|
57
|
+
return (openBlock(), createElementBlock("section", _hoisted_1, [
|
|
58
|
+
($props.title || $props.subtitle)
|
|
59
|
+
? (openBlock(), createElementBlock("header", _hoisted_2, [
|
|
60
|
+
($props.title)
|
|
61
|
+
? (openBlock(), createElementBlock("h3", _hoisted_3, toDisplayString($props.title), 1 /* TEXT */))
|
|
62
|
+
: createCommentVNode("v-if", true),
|
|
63
|
+
($props.subtitle)
|
|
64
|
+
? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString($props.subtitle), 1 /* TEXT */))
|
|
65
|
+
: createCommentVNode("v-if", true)
|
|
66
|
+
]))
|
|
67
|
+
: createCommentVNode("v-if", true),
|
|
68
|
+
createElementVNode("div", _hoisted_5, [
|
|
69
|
+
createElementVNode("span", _hoisted_6, [
|
|
70
|
+
createElementVNode("strong", _hoisted_7, toDisplayString($options.amountText), 1 /* TEXT */),
|
|
71
|
+
($props.remainingText && !$props.paused)
|
|
72
|
+
? (openBlock(), createElementBlock("span", _hoisted_8, toDisplayString($props.remainingText), 1 /* TEXT */))
|
|
73
|
+
: createCommentVNode("v-if", true)
|
|
74
|
+
]),
|
|
75
|
+
createVNode(_component_NcProgressBar, {
|
|
76
|
+
value: $options.percent,
|
|
77
|
+
"aria-label": $options.amountText,
|
|
78
|
+
"data-testid": "cn-transfer-bar"
|
|
79
|
+
}, null, 8 /* PROPS */, ["value", "aria-label"]),
|
|
80
|
+
($props.hint)
|
|
81
|
+
? (openBlock(), createElementBlock("span", _hoisted_9, toDisplayString($props.hint), 1 /* TEXT */))
|
|
82
|
+
: createCommentVNode("v-if", true)
|
|
83
|
+
]),
|
|
84
|
+
($props.paused)
|
|
85
|
+
? (openBlock(), createElementBlock("p", _hoisted_10, toDisplayString($props.pausedText || $options.t('nextcloud-vue', 'The connection dropped. It carries on from where it stopped.')), 1 /* TEXT */))
|
|
86
|
+
: createCommentVNode("v-if", true),
|
|
87
|
+
($props.items.length > 0)
|
|
88
|
+
? (openBlock(), createElementBlock("ul", _hoisted_11, [
|
|
89
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($props.items, (item) => {
|
|
90
|
+
return (openBlock(), createElementBlock("li", {
|
|
91
|
+
key: item.id ?? item.label,
|
|
92
|
+
class: "cn-transfer-card__item",
|
|
93
|
+
"data-testid": "cn-transfer-item"
|
|
94
|
+
}, [
|
|
95
|
+
createElementVNode("span", null, toDisplayString(item.label), 1 /* TEXT */),
|
|
96
|
+
createElementVNode("span", _hoisted_12, toDisplayString(item.state), 1 /* TEXT */)
|
|
97
|
+
]))
|
|
98
|
+
}), 128 /* KEYED_FRAGMENT */))
|
|
99
|
+
]))
|
|
100
|
+
: createCommentVNode("v-if", true),
|
|
101
|
+
($props.paused || _ctx.$slots.actions)
|
|
102
|
+
? (openBlock(), createElementBlock("div", _hoisted_13, [
|
|
103
|
+
($props.paused)
|
|
104
|
+
? (openBlock(), createBlock(_component_NcButton, {
|
|
105
|
+
key: 0,
|
|
106
|
+
variant: "primary",
|
|
107
|
+
"data-testid": "cn-transfer-resume",
|
|
108
|
+
onClick: _cache[0] || (_cache[0] = $event => (_ctx.$emit('resume')))
|
|
109
|
+
}, {
|
|
110
|
+
default: withCtx(() => [
|
|
111
|
+
createTextVNode(toDisplayString($props.resumeLabel || $options.t('nextcloud-vue', 'Resume')), 1 /* TEXT */)
|
|
112
|
+
]),
|
|
113
|
+
_: 1 /* STABLE */
|
|
114
|
+
}))
|
|
115
|
+
: createCommentVNode("v-if", true),
|
|
116
|
+
renderSlot(_ctx.$slots, "actions")
|
|
117
|
+
]))
|
|
118
|
+
: createCommentVNode("v-if", true),
|
|
119
|
+
($props.note)
|
|
120
|
+
? (openBlock(), createElementBlock("p", _hoisted_14, toDisplayString($props.note), 1 /* TEXT */))
|
|
121
|
+
: createCommentVNode("v-if", true)
|
|
122
|
+
]))
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { render };
|
|
126
|
+
//# sourceMappingURL=CnTransferCard.vue3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CnTransferCard.vue3.js","sources":["../../../../src/components/CnTransferCard/CnTransferCard.vue?vue&type=template&id=1a6d8aba&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<section class=\"cn-transfer-card\" data-testid=\"cn-transfer-card\">\n\t\t<header v-if=\"title || subtitle\" class=\"cn-transfer-card__header\">\n\t\t\t<h3 v-if=\"title\" class=\"cn-transfer-card__title\">\n\t\t\t\t{{ title }}\n\t\t\t</h3>\n\t\t\t<span v-if=\"subtitle\" class=\"cn-transfer-card__muted\">{{ subtitle }}</span>\n\t\t</header>\n\n\t\t<div class=\"cn-transfer-card__progress\">\n\t\t\t<span class=\"cn-transfer-card__line\">\n\t\t\t\t<strong data-testid=\"cn-transfer-amount\">{{ amountText }}</strong>\n\t\t\t\t<span v-if=\"remainingText && !paused\" class=\"cn-transfer-card__muted\" data-testid=\"cn-transfer-remaining\">{{ remainingText }}</span>\n\t\t\t</span>\n\t\t\t<NcProgressBar\n\t\t\t\t:value=\"percent\"\n\t\t\t\t:aria-label=\"amountText\"\n\t\t\t\tdata-testid=\"cn-transfer-bar\" />\n\t\t\t<span v-if=\"hint\" class=\"cn-transfer-card__muted\" data-testid=\"cn-transfer-hint\">{{ hint }}</span>\n\t\t</div>\n\n\t\t<p v-if=\"paused\"\n\t\t\tclass=\"cn-transfer-card__paused\"\n\t\t\trole=\"status\"\n\t\t\tdata-testid=\"cn-transfer-paused\">\n\t\t\t{{ pausedText || t('nextcloud-vue', 'The connection dropped. It carries on from where it stopped.') }}\n\t\t</p>\n\n\t\t<ul v-if=\"items.length > 0\" class=\"cn-transfer-card__items\">\n\t\t\t<li v-for=\"item in items\"\n\t\t\t\t:key=\"item.id ?? item.label\"\n\t\t\t\tclass=\"cn-transfer-card__item\"\n\t\t\t\tdata-testid=\"cn-transfer-item\">\n\t\t\t\t<span>{{ item.label }}</span>\n\t\t\t\t<span class=\"cn-transfer-card__muted\">{{ item.state }}</span>\n\t\t\t</li>\n\t\t</ul>\n\n\t\t<div v-if=\"paused || $slots.actions\" class=\"cn-transfer-card__actions\">\n\t\t\t<NcButton v-if=\"paused\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tdata-testid=\"cn-transfer-resume\"\n\t\t\t\t@click=\"$emit('resume')\">\n\t\t\t\t{{ resumeLabel || t('nextcloud-vue', 'Resume') }}\n\t\t\t</NcButton>\n\t\t\t<!-- @slot actions Further buttons under the card. -->\n\t\t\t<slot name=\"actions\" />\n\t\t</div>\n\n\t\t<p v-if=\"note\" class=\"cn-transfer-card__muted cn-transfer-card__note\" data-testid=\"cn-transfer-note\">\n\t\t\t{{ note }}\n\t\t</p>\n\t</section>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcProgressBar } from '@nextcloud/vue'\n\n/**\n * CnTransferCard: a transfer that takes a while, such as taking a day's work\n * offline (board DqInspectie \"Dag synchroniseren\": \"32 MB van 48 MB gedownload\",\n * \"nog ca. 6 minuten\", a row per part, and resuming after a dropped connection).\n *\n * The host owns the transfer and passes where it stands. The card holds no\n * state, so the same card serves a download, an upload or a sync.\n *\n * ```vue\n * <CnTransferCard\n * title=\"Sync the day\"\n * :done=\"32\"\n * :total=\"48\"\n * unit=\"MB\"\n * remaining-text=\"about 6 minutes left\"\n * :items=\"[{ id: 'cases', label: 'Cases of 4 addresses', state: 'Done' }]\"\n * @resume=\"resume\" />\n * ```\n *\n * @event resume The user pressed Resume on a paused transfer.\n * @spec openspec/changes/transfer-card/specs/transfer-card/spec.md\n */\nexport default {\n\tname: 'CnTransferCard',\n\n\tcomponents: { NcButton, NcProgressBar },\n\n\tprops: {\n\t\t/** Title, already translated. */\n\t\ttitle: { type: String, default: '' },\n\t\t/** A line under the title, already translated. */\n\t\tsubtitle: { type: String, default: '' },\n\t\t/** How much has been transferred. */\n\t\tdone: { type: Number, default: 0 },\n\t\t/** How much there is in total. */\n\t\ttotal: { type: Number, default: 0 },\n\t\t/** The unit of `done` and `total`, such as \"MB\". */\n\t\tunit: { type: String, default: '' },\n\t\t/** The amount line, already translated, with `{done}`, `{total}` and `{unit}`; the library default is \"{done} {unit} of {total} {unit}\". */\n\t\tamountTemplate: { type: String, default: '' },\n\t\t/** How long it will still take, already translated. */\n\t\tremainingText: { type: String, default: '' },\n\t\t/** A line under the bar, already translated. */\n\t\thint: { type: String, default: '' },\n\t\t/** The parts: `{ id?, label, state }`, both already translated. */\n\t\titems: { type: Array, default: () => [] },\n\t\t/** The transfer stopped and can carry on. */\n\t\tpaused: { type: Boolean, default: false },\n\t\t/** Says why it stopped, already translated. */\n\t\tpausedText: { type: String, default: '' },\n\t\t/** Label of the Resume button, already translated. */\n\t\tresumeLabel: { type: String, default: '' },\n\t\t/** A line at the end of the card, already translated. */\n\t\tnote: { type: String, default: '' },\n\t},\n\n\temits: ['resume'],\n\n\tcomputed: {\n\t\t/** @return {number} Progress in percent, from 0 to 100; 0 with no total. */\n\t\tpercent() {\n\t\t\tif (!(this.total > 0)) {\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\treturn Math.min(100, Math.max(0, Math.round((this.done / this.total) * 100)))\n\t\t},\n\n\t\t/** @return {string} The amount in words. */\n\t\tamountText() {\n\t\t\tconst values = { done: String(this.done), total: String(this.total), unit: this.unit }\n\t\t\tif (this.amountTemplate) {\n\t\t\t\treturn this.amountTemplate.replace(/\\{(done|total|unit)\\}/g, (match, key) => values[key])\n\t\t\t}\n\t\t\treturn t('nextcloud-vue', '{done} {unit} of {total} {unit}', values)\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\t},\n}\n</script>\n\n<style scoped>\n.cn-transfer-card {\n\tbackground: var(--color-main-background);\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius-large);\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n\tpadding: 16px 20px;\n}\n\n.cn-transfer-card__header,\n.cn-transfer-card__progress {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n}\n\n.cn-transfer-card__title {\n\tfont-size: 1.1em;\n\tmargin: 0;\n}\n\n.cn-transfer-card__muted {\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-transfer-card__line,\n.cn-transfer-card__item {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 4px 12px;\n\tjustify-content: space-between;\n}\n\n.cn-transfer-card__paused,\n.cn-transfer-card__note {\n\tmargin: 0;\n}\n\n.cn-transfer-card__items {\n\tdisplay: flex;\n\tflex-direction: column;\n\tlist-style: none;\n\tmargin: 0;\n\tpadding: 0;\n}\n\n.cn-transfer-card__item {\n\tborder-top: 1px solid var(--color-border);\n\tpadding: 8px 0;\n}\n\n.cn-transfer-card__actions {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 8px;\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_toDisplayString","_createElementVNode","_createVNode","_Fragment","_renderList","_createBlock","_createTextVNode","_renderSlot"],"mappings":";;;AASO,EAAA,KAAA,EAAA,kBAAA;AAAA,EAAA,aAAA,EAAA,kBAAA;;;;AAC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A,CAAA,CAAA,CAAA;;iCACb,MAAG;AAAA,kBAAAC,eAAA,CAAAN,eAAA,CAAA,MAAA,CAAA,WAAA,IAAA,QAAA,CAAA,CAAA,CAAA,eAAA,EAAA,QAAA,CAAA,CAAA,EAAA,CAAA,YAAA;;;;;UAGJO,UAAS,CAAA,IAAA,CAAA,MAAA,EAAA,SAAA,CAAA;;;;;;;;;;;"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { NcButton } from '@nextcloud/vue';
|
|
2
|
+
import Draggable from '../../node_modules/vuedraggable/dist/vuedraggable.umd.js';
|
|
3
|
+
import DragVertical from 'vue-material-design-icons/DragVertical.vue';
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* CnTreeNode — Recursive tree row used inside CnTreeView. Renders
|
|
3
7
|
* its own row + recurses for children when expanded. Not exported
|
|
@@ -6,6 +10,7 @@
|
|
|
6
10
|
*/
|
|
7
11
|
var script = {
|
|
8
12
|
name: 'CnTreeNode',
|
|
13
|
+
components: { Draggable, DragVertical, NcButton },
|
|
9
14
|
props: {
|
|
10
15
|
/** The node data. */
|
|
11
16
|
node: { type: Object, required: true },
|
|
@@ -33,10 +38,30 @@ var script = {
|
|
|
33
38
|
rowAttrs: { type: Function, default: null },
|
|
34
39
|
/** Rows take focus and select on Enter or Space. */
|
|
35
40
|
focusableRows: { type: Boolean, default: false },
|
|
41
|
+
/** Rows can be moved among their siblings. */
|
|
42
|
+
reorderable: { type: Boolean, default: false },
|
|
43
|
+
/** The texts of the move controls, resolved by CnTreeView. */
|
|
44
|
+
reorderLabels: { type: Object, default: () => ({}) },
|
|
45
|
+
/** The parent's id, or null at the root. */
|
|
46
|
+
parentId: { type: [String, Number], default: null },
|
|
47
|
+
/** This node's index among its siblings. */
|
|
48
|
+
siblingIndex: { type: Number, default: 0 },
|
|
49
|
+
/** How many siblings there are, itself included. */
|
|
50
|
+
siblingCount: { type: Number, default: 1 },
|
|
36
51
|
},
|
|
37
52
|
|
|
38
|
-
emits: ['select', 'toggle'],
|
|
53
|
+
emits: ['select', 'toggle', 'move'],
|
|
39
54
|
computed: {
|
|
55
|
+
/**
|
|
56
|
+
* One entry when the row draws its move controls. A `v-for` leaves no
|
|
57
|
+
* placeholder in the markup when off, which `v-if` would.
|
|
58
|
+
*
|
|
59
|
+
* @return {string[]} The keys.
|
|
60
|
+
*/
|
|
61
|
+
reorderSlots() {
|
|
62
|
+
return this.reorderable ? ['reorder'] : []
|
|
63
|
+
},
|
|
64
|
+
|
|
40
65
|
/**
|
|
41
66
|
* Whether this node has any children at all.
|
|
42
67
|
*
|
|
@@ -99,6 +124,46 @@ var script = {
|
|
|
99
124
|
this.$emit('toggle', this.node[this.idKey]);
|
|
100
125
|
},
|
|
101
126
|
|
|
127
|
+
/**
|
|
128
|
+
* The accessible name of a move button: its visible label and the node's.
|
|
129
|
+
*
|
|
130
|
+
* @param {string} action The visible label.
|
|
131
|
+
* @return {string} The name.
|
|
132
|
+
*/
|
|
133
|
+
moveName(action) {
|
|
134
|
+
return this.reorderLabels.controlName
|
|
135
|
+
.replace('{action}', action)
|
|
136
|
+
.replace('{label}', String(this.node[this.labelKey] ?? ''))
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Move this node one place among its siblings, with a button.
|
|
141
|
+
*
|
|
142
|
+
* @param {number} delta -1 up, 1 down.
|
|
143
|
+
* @return {void}
|
|
144
|
+
*/
|
|
145
|
+
moveBy(delta) {
|
|
146
|
+
this.$emit('move', {
|
|
147
|
+
node: this.node,
|
|
148
|
+
parentId: this.parentId,
|
|
149
|
+
from: this.siblingIndex,
|
|
150
|
+
to: this.siblingIndex + delta,
|
|
151
|
+
byButton: true,
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* A child was dragged to another place.
|
|
157
|
+
*
|
|
158
|
+
* @param {{moved?: {element: object, oldIndex: number, newIndex: number}}} change What the drag changed.
|
|
159
|
+
* @return {void}
|
|
160
|
+
*/
|
|
161
|
+
onDragChange({ moved } = {}) {
|
|
162
|
+
if (moved) {
|
|
163
|
+
this.$emit('move', { node: moved.element, parentId: this.node[this.idKey], from: moved.oldIndex, to: moved.newIndex });
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
|
|
102
167
|
onRowClick() {
|
|
103
168
|
this.$emit('select', this.node);
|
|
104
169
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnTreeNode.vue2.js","sources":["../../../../src/components/CnTreeView/CnTreeNode.vue"],"sourcesContent":["<template>\n\t<li class=\"cn-tree-node\"\n\t\t:class=\"{\n\t\t\t'cn-tree-node--selected': isSelected,\n\t\t\t'cn-tree-node--expanded': isExpanded,\n\t\t}\"\n\t\t:data-node-id=\"node[idKey]\"\n\t\trole=\"treeitem\"\n\t\t:aria-expanded=\"hasChildren ? isExpanded : undefined\"\n\t\t:aria-selected=\"isSelected\">\n\t\t<div class=\"cn-tree-node__row\"\n\t\t\tv-bind=\"extraRowAttrs\"\n\t\t\t:style=\"{ paddingLeft: (depth * indent) + 'px' }\"\n\t\t\t:tabindex=\"focusableRows ? 0 : undefined\"\n\t\t\t@click=\"onRowClick\"\n\t\t\t@keydown=\"onRowKeydown\">\n\t\t\t<button v-if=\"hasChildren\"\n\t\t\t\ttype=\"button\"\n\t\t\t\tv-bind=\"extraToggleAttrs\"\n\t\t\t\tclass=\"cn-tree-node__toggle\"\n\t\t\t\t:aria-label=\"toggleLabel\"\n\t\t\t\t@click.stop=\"toggle\">\n\t\t\t\t<span class=\"cn-tree-node__caret\" :class=\"{ 'cn-tree-node__caret--open': isExpanded }\">▸</span>\n\t\t\t</button>\n\t\t\t<span v-else class=\"cn-tree-node__toggle cn-tree-node__toggle--leaf\" />\n\n\t\t\t<span v-if=\"node.icon\" class=\"cn-tree-node__icon\">{{ node.icon }}</span>\n\t\t\t<span class=\"cn-tree-node__label\">\n\t\t\t\t<!-- @slot label The row's label. Scope: { node, depth, expanded }. Defaults to the node's label text. -->\n\t\t\t\t<slot name=\"label\"\n\t\t\t\t\t:node=\"node\"\n\t\t\t\t\t:depth=\"depth\"\n\t\t\t\t\t:expanded=\"isExpanded\">{{ node[labelKey] }}</slot>\n\t\t\t</span>\n\t\t\t<span v-if=\"node.badge !== undefined\" class=\"cn-tree-node__badge\">{{ node.badge }}</span>\n\n\t\t\t<!-- @slot actions Inline per-row actions slot. Scope:\n\t\t\t { node, depth }. -->\n\t\t\t<slot name=\"actions\" :node=\"node\" :depth=\"depth\" />\n\t\t</div>\n\n\t\t<ul v-if=\"hasChildren && isExpanded\" class=\"cn-tree-node__children\" role=\"group\">\n\t\t\t<CnTreeNode v-for=\"child in node[childrenKey]\"\n\t\t\t\t:key=\"child[idKey]\"\n\t\t\t\t:node=\"child\"\n\t\t\t\t:depth=\"depth + 1\"\n\t\t\t\t:indent=\"indent\"\n\t\t\t\t:expandedIds=\"expandedIds\"\n\t\t\t\t:selectedId=\"selectedId\"\n\t\t\t\t:idKey=\"idKey\"\n\t\t\t\t:labelKey=\"labelKey\"\n\t\t\t\t:childrenKey=\"childrenKey\"\n\t\t\t\t:expandLabel=\"expandLabel\"\n\t\t\t\t:collapseLabel=\"collapseLabel\"\n\t\t\t\t:toggleAttrs=\"toggleAttrs\"\n\t\t\t\t:rowAttrs=\"rowAttrs\"\n\t\t\t\t:focusableRows=\"focusableRows\"\n\t\t\t\t@toggle=\"$emit('toggle', $event)\"\n\t\t\t\t@select=\"$emit('select', $event)\">\n\t\t\t\t<template #actions=\"scope\">\n\t\t\t\t\t<slot name=\"actions\" v-bind=\"scope\" />\n\t\t\t\t</template>\n\t\t\t\t<template v-if=\"$slots.label\" #label=\"scope\">\n\t\t\t\t\t<slot name=\"label\" v-bind=\"scope\" />\n\t\t\t\t</template>\n\t\t\t</CnTreeNode>\n\t\t</ul>\n\t</li>\n</template>\n\n<script>\n/**\n * CnTreeNode — Recursive tree row used inside CnTreeView. Renders\n * its own row + recurses for children when expanded. Not exported\n * as a separate barrel entry — consumers use CnTreeView and the\n * recursion is internal.\n */\nexport default {\n\tname: 'CnTreeNode',\n\tprops: {\n\t\t/** The node data. */\n\t\tnode: { type: Object, required: true },\n\t\t/** Depth (drives indent). */\n\t\tdepth: { type: Number, default: 0 },\n\t\t/** Pixels of padding per depth level. */\n\t\tindent: { type: Number, default: 18 },\n\t\t/** Set of expanded node ids. */\n\t\texpandedIds: { type: Object, required: true },\n\t\t/** Currently selected node id, read off `node[idKey]` (or null). */\n\t\tselectedId: { type: [String, Number], default: null },\n\t\t/** Node-field key for the id. */\n\t\tidKey: { type: String, default: 'id' },\n\t\t/** Node-field key for the display label. */\n\t\tlabelKey: { type: String, default: 'label' },\n\t\t/** Node-field key for the children array. */\n\t\tchildrenKey: { type: String, default: 'children' },\n\t\t/** A11y label for the expand button, or `(node) => string`. */\n\t\texpandLabel: { type: [String, Function], default: 'Expand' },\n\t\t/** A11y label for the collapse button, or `(node) => string`. */\n\t\tcollapseLabel: { type: [String, Function], default: 'Collapse' },\n\t\t/** Extra expand-button attributes per node, `(node, depth) => object`. */\n\t\ttoggleAttrs: { type: Function, default: null },\n\t\t/** Extra row attributes per node, `(node, depth) => object`. */\n\t\trowAttrs: { type: Function, default: null },\n\t\t/** Rows take focus and select on Enter or Space. */\n\t\tfocusableRows: { type: Boolean, default: false },\n\t},\n\n\temits: ['select', 'toggle'],\n\tcomputed: {\n\t\t/**\n\t\t * Whether this node has any children at all.\n\t\t *\n\t\t * @return {boolean}\n\t\t */\n\t\thasChildren() {\n\t\t\tconst c = this.node[this.childrenKey]\n\t\t\treturn Array.isArray(c) && c.length > 0\n\t\t},\n\n\t\t/**\n\t\t * Whether this node is currently expanded.\n\t\t *\n\t\t * @return {boolean}\n\t\t */\n\t\tisExpanded() {\n\t\t\treturn Boolean(this.expandedIds[this.node[this.idKey]])\n\t\t},\n\n\t\t/**\n\t\t * Whether this node is the currently-selected one.\n\t\t *\n\t\t * @return {boolean}\n\t\t */\n\t\tisSelected() {\n\t\t\treturn this.selectedId === this.node[this.idKey]\n\t\t},\n\n\t\t/**\n\t\t * The expand button's accessible name for this node.\n\t\t *\n\t\t * @return {string}\n\t\t */\n\t\ttoggleLabel() {\n\t\t\tconst label = this.isExpanded ? this.collapseLabel : this.expandLabel\n\t\t\treturn typeof label === 'function' ? label(this.node) : label\n\t\t},\n\n\t\t/**\n\t\t * The host's extra attributes for this row.\n\t\t *\n\t\t * @return {object}\n\t\t */\n\t\textraRowAttrs() {\n\t\t\treturn this.rowAttrs ? this.rowAttrs(this.node, this.depth) : {}\n\t\t},\n\n\t\t/**\n\t\t * The host's extra attributes for this row's expand button.\n\t\t *\n\t\t * @return {object}\n\t\t */\n\t\textraToggleAttrs() {\n\t\t\treturn this.toggleAttrs ? this.toggleAttrs(this.node, this.depth) : {}\n\t\t},\n\t},\n\n\tmethods: {\n\t\ttoggle() {\n\t\t\tthis.$emit('toggle', this.node[this.idKey])\n\t\t},\n\n\t\tonRowClick() {\n\t\t\tthis.$emit('select', this.node)\n\t\t},\n\n\t\t/**\n\t\t * Enter or Space on a focusable row selects its node. Keys pressed on\n\t\t * the expand button or an action inside the row are theirs.\n\t\t *\n\t\t * @param {KeyboardEvent} event The key event.\n\t\t */\n\t\tonRowKeydown(event) {\n\t\t\tif (!this.focusableRows || event.target !== event.currentTarget) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (event.key === 'Enter' || event.key === ' ') {\n\t\t\t\tevent.preventDefault()\n\t\t\t\tthis.$emit('select', this.node)\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-tree-node {\n\tlist-style: none;\n}\n\n.cn-tree-node__row {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 6px;\n\tpadding: 4px 6px;\n\tborder-radius: var(--border-radius);\n\tcursor: pointer;\n}\n\n.cn-tree-node__row:hover {\n\tbackground: var(--color-background-hover);\n}\n\n/* A row made focusable by `focusableRows` shows where keyboard focus is (WCAG 2.4.7). */\n.cn-tree-node__row[tabindex]:focus-visible {\n\toutline: 2px solid var(--color-primary-element);\n\toutline-offset: -2px;\n}\n\n.cn-tree-node--selected > .cn-tree-node__row {\n\tbackground: var(--color-primary-element-light);\n\tcolor: var(--color-main-text);\n}\n\n.cn-tree-node__toggle {\n\tbackground: none;\n\tborder: none;\n\tcursor: pointer;\n\tpadding: 0;\n\twidth: 18px;\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n}\n\n.cn-tree-node__toggle--leaf {\n\tcursor: default;\n}\n\n.cn-tree-node__caret {\n\tdisplay: inline-block;\n\ttransition: transform 0.15s ease;\n\tfont-size: 0.9em;\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-tree-node__caret--open {\n\ttransform: rotate(90deg);\n\tcolor: var(--color-main-text);\n}\n\n.cn-tree-node__icon {\n\tfont-size: 0.9em;\n}\n\n.cn-tree-node__label {\n\tflex: 1 1 auto;\n\tmin-width: 0;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\twhite-space: nowrap;\n}\n\n.cn-tree-node__badge {\n\tfont-size: 0.8em;\n\tpadding: 1px 6px;\n\tborder-radius: 9999px;\n\tbackground: var(--color-background-hover);\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-tree-node__children {\n\tmargin: 0;\n\tpadding: 0;\n\tlist-style: none;\n}\n</style>\n"],"names":[],"mappings":"AAuEA;;;;AAIC;;AAED,aAAe;AACd,CAAA,IAAI,EAAE,YAAY;AAClB,CAAA,KAAK,EAAE;AACN;AACA,EAAA,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;EAEtC,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA,EAAG;AACnC;AACA,EAAA,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI;;AAErC,EAAA,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;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,EAAE,IAAI,CAAC,IAAI,EAAA;AAC/B,IAAA;GACA;EACD;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"CnTreeNode.vue2.js","sources":["../../../../src/components/CnTreeView/CnTreeNode.vue"],"sourcesContent":["<template>\n\t<li class=\"cn-tree-node\"\n\t\t:class=\"{\n\t\t\t'cn-tree-node--selected': isSelected,\n\t\t\t'cn-tree-node--expanded': isExpanded,\n\t\t}\"\n\t\t:data-node-id=\"node[idKey]\"\n\t\trole=\"treeitem\"\n\t\t:aria-expanded=\"hasChildren ? isExpanded : undefined\"\n\t\t:aria-selected=\"isSelected\">\n\t\t<div class=\"cn-tree-node__row\"\n\t\t\tv-bind=\"extraRowAttrs\"\n\t\t\t:style=\"{ paddingLeft: (depth * indent) + 'px' }\"\n\t\t\t:tabindex=\"focusableRows ? 0 : undefined\"\n\t\t\t@click=\"onRowClick\"\n\t\t\t@keydown=\"onRowKeydown\">\n\t\t\t<span v-for=\"key in reorderSlots\"\n\t\t\t\t:key=\"key\"\n\t\t\t\tclass=\"cn-tree-node__handle\"\n\t\t\t\t:title=\"reorderLabels.drag\"\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\t@click.stop>\n\t\t\t\t<DragVertical :size=\"18\" />\n\t\t\t</span>\n\t\t\t<button v-if=\"hasChildren\"\n\t\t\t\ttype=\"button\"\n\t\t\t\tv-bind=\"extraToggleAttrs\"\n\t\t\t\tclass=\"cn-tree-node__toggle\"\n\t\t\t\t:aria-label=\"toggleLabel\"\n\t\t\t\t@click.stop=\"toggle\">\n\t\t\t\t<span class=\"cn-tree-node__caret\" :class=\"{ 'cn-tree-node__caret--open': isExpanded }\">▸</span>\n\t\t\t</button>\n\t\t\t<span v-else class=\"cn-tree-node__toggle cn-tree-node__toggle--leaf\" />\n\n\t\t\t<span v-if=\"node.icon\" class=\"cn-tree-node__icon\">{{ node.icon }}</span>\n\t\t\t<span class=\"cn-tree-node__label\">\n\t\t\t\t<!-- @slot label The row's label. Scope: { node, depth, expanded }. Defaults to the node's label text. -->\n\t\t\t\t<slot name=\"label\"\n\t\t\t\t\t:node=\"node\"\n\t\t\t\t\t:depth=\"depth\"\n\t\t\t\t\t:expanded=\"isExpanded\">{{ node[labelKey] }}</slot>\n\t\t\t</span>\n\t\t\t<span v-if=\"node.badge !== undefined\" class=\"cn-tree-node__badge\">{{ node.badge }}</span>\n\n\t\t\t<span v-for=\"key in reorderSlots\"\n\t\t\t\t:key=\"key\"\n\t\t\t\tclass=\"cn-tree-node__move\"\n\t\t\t\t@click.stop>\n\t\t\t\t<NcButton variant=\"tertiary\"\n\t\t\t\t\t:disabled=\"siblingIndex === 0\"\n\t\t\t\t\t:aria-label=\"moveName(reorderLabels.moveUp)\"\n\t\t\t\t\tdata-move=\"up\"\n\t\t\t\t\t@click=\"moveBy(-1)\">\n\t\t\t\t\t{{ reorderLabels.moveUp }}\n\t\t\t\t</NcButton>\n\t\t\t\t<NcButton variant=\"tertiary\"\n\t\t\t\t\t:disabled=\"siblingIndex >= siblingCount - 1\"\n\t\t\t\t\t:aria-label=\"moveName(reorderLabels.moveDown)\"\n\t\t\t\t\tdata-move=\"down\"\n\t\t\t\t\t@click=\"moveBy(1)\">\n\t\t\t\t\t{{ reorderLabels.moveDown }}\n\t\t\t\t</NcButton>\n\t\t\t</span>\n\n\t\t\t<!-- @slot actions Inline per-row actions slot. Scope:\n\t\t\t { node, depth }. -->\n\t\t\t<slot name=\"actions\" :node=\"node\" :depth=\"depth\" />\n\t\t</div>\n\n\t\t<Draggable v-if=\"reorderable && hasChildren && isExpanded\"\n\t\t\t:modelValue=\"node[childrenKey]\"\n\t\t\t:itemKey=\"idKey\"\n\t\t\ttag=\"ul\"\n\t\t\tclass=\"cn-tree-node__children\"\n\t\t\trole=\"group\"\n\t\t\thandle=\".cn-tree-node__handle\"\n\t\t\t@change=\"onDragChange\">\n\t\t\t<template #item=\"{ element: child, index }\">\n\t\t\t\t<CnTreeNode :node=\"child\"\n\t\t\t\t\t:depth=\"depth + 1\"\n\t\t\t\t\t:indent=\"indent\"\n\t\t\t\t\t:expandedIds=\"expandedIds\"\n\t\t\t\t\t:selectedId=\"selectedId\"\n\t\t\t\t\t:idKey=\"idKey\"\n\t\t\t\t\t:labelKey=\"labelKey\"\n\t\t\t\t\t:childrenKey=\"childrenKey\"\n\t\t\t\t\t:expandLabel=\"expandLabel\"\n\t\t\t\t\t:collapseLabel=\"collapseLabel\"\n\t\t\t\t\t:toggleAttrs=\"toggleAttrs\"\n\t\t\t\t\t:rowAttrs=\"rowAttrs\"\n\t\t\t\t\t:focusableRows=\"focusableRows\"\n\t\t\t\t\treorderable\n\t\t\t\t\t:reorderLabels=\"reorderLabels\"\n\t\t\t\t\t:parentId=\"node[idKey]\"\n\t\t\t\t\t:siblingIndex=\"index\"\n\t\t\t\t\t:siblingCount=\"node[childrenKey].length\"\n\t\t\t\t\t@toggle=\"$emit('toggle', $event)\"\n\t\t\t\t\t@select=\"$emit('select', $event)\"\n\t\t\t\t\t@move=\"$emit('move', $event)\">\n\t\t\t\t\t<template #actions=\"scope\">\n\t\t\t\t\t\t<slot name=\"actions\" v-bind=\"scope\" />\n\t\t\t\t\t</template>\n\t\t\t\t\t<template v-if=\"$slots.label\" #label=\"scope\">\n\t\t\t\t\t\t<slot name=\"label\" v-bind=\"scope\" />\n\t\t\t\t\t</template>\n\t\t\t\t</CnTreeNode>\n\t\t\t</template>\n\t\t</Draggable>\n\t\t<ul v-else-if=\"hasChildren && isExpanded\" class=\"cn-tree-node__children\" role=\"group\">\n\t\t\t<CnTreeNode v-for=\"child in node[childrenKey]\"\n\t\t\t\t:key=\"child[idKey]\"\n\t\t\t\t:node=\"child\"\n\t\t\t\t:depth=\"depth + 1\"\n\t\t\t\t:indent=\"indent\"\n\t\t\t\t:expandedIds=\"expandedIds\"\n\t\t\t\t:selectedId=\"selectedId\"\n\t\t\t\t:idKey=\"idKey\"\n\t\t\t\t:labelKey=\"labelKey\"\n\t\t\t\t:childrenKey=\"childrenKey\"\n\t\t\t\t:expandLabel=\"expandLabel\"\n\t\t\t\t:collapseLabel=\"collapseLabel\"\n\t\t\t\t:toggleAttrs=\"toggleAttrs\"\n\t\t\t\t:rowAttrs=\"rowAttrs\"\n\t\t\t\t:focusableRows=\"focusableRows\"\n\t\t\t\t@toggle=\"$emit('toggle', $event)\"\n\t\t\t\t@select=\"$emit('select', $event)\">\n\t\t\t\t<template #actions=\"scope\">\n\t\t\t\t\t<slot name=\"actions\" v-bind=\"scope\" />\n\t\t\t\t</template>\n\t\t\t\t<template v-if=\"$slots.label\" #label=\"scope\">\n\t\t\t\t\t<slot name=\"label\" v-bind=\"scope\" />\n\t\t\t\t</template>\n\t\t\t</CnTreeNode>\n\t\t</ul>\n\t</li>\n</template>\n\n<script>\nimport { NcButton } from '@nextcloud/vue'\nimport Draggable from 'vuedraggable'\nimport DragVertical from 'vue-material-design-icons/DragVertical.vue'\n\n/**\n * CnTreeNode — Recursive tree row used inside CnTreeView. Renders\n * its own row + recurses for children when expanded. Not exported\n * as a separate barrel entry — consumers use CnTreeView and the\n * recursion is internal.\n */\nexport default {\n\tname: 'CnTreeNode',\n\tcomponents: { Draggable, DragVertical, NcButton },\n\tprops: {\n\t\t/** The node data. */\n\t\tnode: { type: Object, required: true },\n\t\t/** Depth (drives indent). */\n\t\tdepth: { type: Number, default: 0 },\n\t\t/** Pixels of padding per depth level. */\n\t\tindent: { type: Number, default: 18 },\n\t\t/** Set of expanded node ids. */\n\t\texpandedIds: { type: Object, required: true },\n\t\t/** Currently selected node id, read off `node[idKey]` (or null). */\n\t\tselectedId: { type: [String, Number], default: null },\n\t\t/** Node-field key for the id. */\n\t\tidKey: { type: String, default: 'id' },\n\t\t/** Node-field key for the display label. */\n\t\tlabelKey: { type: String, default: 'label' },\n\t\t/** Node-field key for the children array. */\n\t\tchildrenKey: { type: String, default: 'children' },\n\t\t/** A11y label for the expand button, or `(node) => string`. */\n\t\texpandLabel: { type: [String, Function], default: 'Expand' },\n\t\t/** A11y label for the collapse button, or `(node) => string`. */\n\t\tcollapseLabel: { type: [String, Function], default: 'Collapse' },\n\t\t/** Extra expand-button attributes per node, `(node, depth) => object`. */\n\t\ttoggleAttrs: { type: Function, default: null },\n\t\t/** Extra row attributes per node, `(node, depth) => object`. */\n\t\trowAttrs: { type: Function, default: null },\n\t\t/** Rows take focus and select on Enter or Space. */\n\t\tfocusableRows: { type: Boolean, default: false },\n\t\t/** Rows can be moved among their siblings. */\n\t\treorderable: { type: Boolean, default: false },\n\t\t/** The texts of the move controls, resolved by CnTreeView. */\n\t\treorderLabels: { type: Object, default: () => ({}) },\n\t\t/** The parent's id, or null at the root. */\n\t\tparentId: { type: [String, Number], default: null },\n\t\t/** This node's index among its siblings. */\n\t\tsiblingIndex: { type: Number, default: 0 },\n\t\t/** How many siblings there are, itself included. */\n\t\tsiblingCount: { type: Number, default: 1 },\n\t},\n\n\temits: ['select', 'toggle', 'move'],\n\tcomputed: {\n\t\t/**\n\t\t * One entry when the row draws its move controls. A `v-for` leaves no\n\t\t * placeholder in the markup when off, which `v-if` would.\n\t\t *\n\t\t * @return {string[]} The keys.\n\t\t */\n\t\treorderSlots() {\n\t\t\treturn this.reorderable ? ['reorder'] : []\n\t\t},\n\n\t\t/**\n\t\t * Whether this node has any children at all.\n\t\t *\n\t\t * @return {boolean}\n\t\t */\n\t\thasChildren() {\n\t\t\tconst c = this.node[this.childrenKey]\n\t\t\treturn Array.isArray(c) && c.length > 0\n\t\t},\n\n\t\t/**\n\t\t * Whether this node is currently expanded.\n\t\t *\n\t\t * @return {boolean}\n\t\t */\n\t\tisExpanded() {\n\t\t\treturn Boolean(this.expandedIds[this.node[this.idKey]])\n\t\t},\n\n\t\t/**\n\t\t * Whether this node is the currently-selected one.\n\t\t *\n\t\t * @return {boolean}\n\t\t */\n\t\tisSelected() {\n\t\t\treturn this.selectedId === this.node[this.idKey]\n\t\t},\n\n\t\t/**\n\t\t * The expand button's accessible name for this node.\n\t\t *\n\t\t * @return {string}\n\t\t */\n\t\ttoggleLabel() {\n\t\t\tconst label = this.isExpanded ? this.collapseLabel : this.expandLabel\n\t\t\treturn typeof label === 'function' ? label(this.node) : label\n\t\t},\n\n\t\t/**\n\t\t * The host's extra attributes for this row.\n\t\t *\n\t\t * @return {object}\n\t\t */\n\t\textraRowAttrs() {\n\t\t\treturn this.rowAttrs ? this.rowAttrs(this.node, this.depth) : {}\n\t\t},\n\n\t\t/**\n\t\t * The host's extra attributes for this row's expand button.\n\t\t *\n\t\t * @return {object}\n\t\t */\n\t\textraToggleAttrs() {\n\t\t\treturn this.toggleAttrs ? this.toggleAttrs(this.node, this.depth) : {}\n\t\t},\n\t},\n\n\tmethods: {\n\t\ttoggle() {\n\t\t\tthis.$emit('toggle', this.node[this.idKey])\n\t\t},\n\n\t\t/**\n\t\t * The accessible name of a move button: its visible label and the node's.\n\t\t *\n\t\t * @param {string} action The visible label.\n\t\t * @return {string} The name.\n\t\t */\n\t\tmoveName(action) {\n\t\t\treturn this.reorderLabels.controlName\n\t\t\t\t.replace('{action}', action)\n\t\t\t\t.replace('{label}', String(this.node[this.labelKey] ?? ''))\n\t\t},\n\n\t\t/**\n\t\t * Move this node one place among its siblings, with a button.\n\t\t *\n\t\t * @param {number} delta -1 up, 1 down.\n\t\t * @return {void}\n\t\t */\n\t\tmoveBy(delta) {\n\t\t\tthis.$emit('move', {\n\t\t\t\tnode: this.node,\n\t\t\t\tparentId: this.parentId,\n\t\t\t\tfrom: this.siblingIndex,\n\t\t\t\tto: this.siblingIndex + delta,\n\t\t\t\tbyButton: true,\n\t\t\t})\n\t\t},\n\n\t\t/**\n\t\t * A child was dragged to another place.\n\t\t *\n\t\t * @param {{moved?: {element: object, oldIndex: number, newIndex: number}}} change What the drag changed.\n\t\t * @return {void}\n\t\t */\n\t\tonDragChange({ moved } = {}) {\n\t\t\tif (moved) {\n\t\t\t\tthis.$emit('move', { node: moved.element, parentId: this.node[this.idKey], from: moved.oldIndex, to: moved.newIndex })\n\t\t\t}\n\t\t},\n\n\t\tonRowClick() {\n\t\t\tthis.$emit('select', this.node)\n\t\t},\n\n\t\t/**\n\t\t * Enter or Space on a focusable row selects its node. Keys pressed on\n\t\t * the expand button or an action inside the row are theirs.\n\t\t *\n\t\t * @param {KeyboardEvent} event The key event.\n\t\t */\n\t\tonRowKeydown(event) {\n\t\t\tif (!this.focusableRows || event.target !== event.currentTarget) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (event.key === 'Enter' || event.key === ' ') {\n\t\t\t\tevent.preventDefault()\n\t\t\t\tthis.$emit('select', this.node)\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-tree-node {\n\tlist-style: none;\n}\n\n.cn-tree-node__row {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 6px;\n\tpadding: 4px 6px;\n\tborder-radius: var(--border-radius);\n\tcursor: pointer;\n}\n\n.cn-tree-node__row:hover {\n\tbackground: var(--color-background-hover);\n}\n\n/* A row made focusable by `focusableRows` shows where keyboard focus is (WCAG 2.4.7). */\n.cn-tree-node__row[tabindex]:focus-visible {\n\toutline: 2px solid var(--color-primary-element);\n\toutline-offset: -2px;\n}\n\n.cn-tree-node--selected > .cn-tree-node__row {\n\tbackground: var(--color-primary-element-light);\n\tcolor: var(--color-main-text);\n}\n\n.cn-tree-node__toggle {\n\tbackground: none;\n\tborder: none;\n\tcursor: pointer;\n\tpadding: 0;\n\twidth: 18px;\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n}\n\n.cn-tree-node__toggle--leaf {\n\tcursor: default;\n}\n\n.cn-tree-node__caret {\n\tdisplay: inline-block;\n\ttransition: transform 0.15s ease;\n\tfont-size: 0.9em;\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-tree-node__caret--open {\n\ttransform: rotate(90deg);\n\tcolor: var(--color-main-text);\n}\n\n.cn-tree-node__icon {\n\tfont-size: 0.9em;\n}\n\n.cn-tree-node__label {\n\tflex: 1 1 auto;\n\tmin-width: 0;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\twhite-space: nowrap;\n}\n\n.cn-tree-node__handle {\n\tcolor: var(--color-text-maxcontrast);\n\tcursor: grab;\n\tdisplay: inline-flex;\n}\n\n.cn-tree-node__move {\n\tdisplay: inline-flex;\n\tgap: 4px;\n}\n\n.cn-tree-node__badge {\n\tfont-size: 0.8em;\n\tpadding: 1px 6px;\n\tborder-radius: 9999px;\n\tbackground: var(--color-background-hover);\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-tree-node__children {\n\tmargin: 0;\n\tpadding: 0;\n\tlist-style: none;\n}\n</style>\n"],"names":[],"mappings":";;;;AA8IA;;;;AAIC;;AAED,aAAe;AACd,CAAA,IAAI,EAAE,YAAY;AAClB,CAAA,UAAU,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU;AACjD,CAAA,KAAK,EAAE;AACN;AACA,EAAA,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;EAEtC,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA,EAAG;AACnC;AACA,EAAA,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI;;AAErC,EAAA,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;EAE7C,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM;;AAErD,EAAA,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;AACtC;AACA,EAAA,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS;AAC5C;AACA,EAAA,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY;;EAElD,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE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