@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
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
- SPDX-FileCopyrightText: 2026 Conduction B.V.
|
|
3
|
+
- SPDX-License-Identifier: EUPL-1.2
|
|
4
|
+
-->
|
|
5
|
+
<template>
|
|
6
|
+
<section class="cn-block-list-editor" data-testid="cn-block-list-editor">
|
|
7
|
+
<p class="hidden-visually"
|
|
8
|
+
role="status"
|
|
9
|
+
aria-live="polite"
|
|
10
|
+
data-testid="cn-block-list-live">
|
|
11
|
+
{{ announcement }}
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<NcNoteCard v-if="draftPositions.length > 0"
|
|
15
|
+
type="warning"
|
|
16
|
+
data-testid="cn-block-list-draft-notice">
|
|
17
|
+
{{ draftNoticeText }}
|
|
18
|
+
</NcNoteCard>
|
|
19
|
+
|
|
20
|
+
<p v-if="modelValue.length === 0" class="cn-block-list-editor__empty" data-testid="cn-block-list-empty">
|
|
21
|
+
{{ text.empty }}
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
<Draggable v-else
|
|
25
|
+
:modelValue="modelValue"
|
|
26
|
+
:itemKey="idKey"
|
|
27
|
+
:disabled="disabled"
|
|
28
|
+
:move="canDragOver"
|
|
29
|
+
tag="ol"
|
|
30
|
+
class="cn-block-list-editor__list"
|
|
31
|
+
handle=".cn-block-list-editor__handle"
|
|
32
|
+
:aria-label="text.list"
|
|
33
|
+
@update:modelValue="onDragged"
|
|
34
|
+
@change="onDragChange">
|
|
35
|
+
<template #item="{ element: block, index }">
|
|
36
|
+
<li class="cn-block-list-editor__block"
|
|
37
|
+
:class="{ 'cn-block-list-editor__block--draft': block.draft }"
|
|
38
|
+
data-testid="cn-block-list-block">
|
|
39
|
+
<div class="cn-block-list-editor__row">
|
|
40
|
+
<span v-if="!block.pinned && !disabled"
|
|
41
|
+
class="cn-block-list-editor__handle"
|
|
42
|
+
:title="text.drag"
|
|
43
|
+
aria-hidden="true">
|
|
44
|
+
<DragVertical :size="20" />
|
|
45
|
+
</span>
|
|
46
|
+
<button v-if="collapsible"
|
|
47
|
+
type="button"
|
|
48
|
+
class="cn-block-list-editor__toggle"
|
|
49
|
+
:aria-expanded="isOpen(block) ? 'true' : 'false'"
|
|
50
|
+
data-testid="cn-block-list-toggle"
|
|
51
|
+
@click="toggle(block)">
|
|
52
|
+
<strong>{{ typeLabel(block) }}</strong>
|
|
53
|
+
</button>
|
|
54
|
+
<strong v-else>{{ typeLabel(block) }}</strong>
|
|
55
|
+
<span class="cn-block-list-editor__summary">
|
|
56
|
+
<!-- @slot summary One line about the block. Props: `block`, `index`, `position`. -->
|
|
57
|
+
<slot name="summary"
|
|
58
|
+
:block="block"
|
|
59
|
+
:index="index"
|
|
60
|
+
:position="index + 1" />
|
|
61
|
+
</span>
|
|
62
|
+
<span class="cn-block-list-editor__actions">
|
|
63
|
+
<template v-if="!block.pinned">
|
|
64
|
+
<NcButton variant="tertiary"
|
|
65
|
+
:disabled="!canMove(index, -1)"
|
|
66
|
+
:aria-label="controlName(text.moveUp, block, index)"
|
|
67
|
+
data-move="up"
|
|
68
|
+
@click="move(index, -1)">
|
|
69
|
+
{{ text.moveUp }}
|
|
70
|
+
</NcButton>
|
|
71
|
+
<NcButton variant="tertiary"
|
|
72
|
+
:disabled="!canMove(index, 1)"
|
|
73
|
+
:aria-label="controlName(text.moveDown, block, index)"
|
|
74
|
+
data-move="down"
|
|
75
|
+
@click="move(index, 1)">
|
|
76
|
+
{{ text.moveDown }}
|
|
77
|
+
</NcButton>
|
|
78
|
+
</template>
|
|
79
|
+
<!-- @slot block-actions Further buttons on the row. Props: `block`, `index`, `position`. -->
|
|
80
|
+
<slot name="block-actions"
|
|
81
|
+
:block="block"
|
|
82
|
+
:index="index"
|
|
83
|
+
:position="index + 1" />
|
|
84
|
+
<NcButton v-if="!block.pinned"
|
|
85
|
+
variant="tertiary"
|
|
86
|
+
:disabled="disabled"
|
|
87
|
+
:aria-label="controlName(text.remove, block, index)"
|
|
88
|
+
data-action="remove"
|
|
89
|
+
@click="remove(index)">
|
|
90
|
+
{{ text.remove }}
|
|
91
|
+
</NcButton>
|
|
92
|
+
</span>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<div v-if="block.draft"
|
|
96
|
+
class="cn-block-list-editor__draft"
|
|
97
|
+
role="group"
|
|
98
|
+
:aria-label="controlName(text.draft, block, index)"
|
|
99
|
+
data-testid="cn-block-list-draft">
|
|
100
|
+
<p class="cn-block-list-editor__draft-text">
|
|
101
|
+
<strong>{{ text.draft }}</strong>
|
|
102
|
+
{{ draftNote(block) }}
|
|
103
|
+
</p>
|
|
104
|
+
<span class="cn-block-list-editor__draft-actions">
|
|
105
|
+
<NcButton variant="primary"
|
|
106
|
+
:aria-label="controlName(text.keep, block, index)"
|
|
107
|
+
data-action="keep"
|
|
108
|
+
@click="keepDraft(index)">
|
|
109
|
+
{{ text.keep }}
|
|
110
|
+
</NcButton>
|
|
111
|
+
<NcButton :aria-label="controlName(text.discard, block, index)"
|
|
112
|
+
data-action="discard"
|
|
113
|
+
@click="discardDraft(index)">
|
|
114
|
+
{{ text.discard }}
|
|
115
|
+
</NcButton>
|
|
116
|
+
</span>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<div v-if="isOpen(block)" class="cn-block-list-editor__body">
|
|
120
|
+
<!-- @slot block-<type> The editor of one block type. Props: `block`, `index`, `position`, `update`. -->
|
|
121
|
+
<slot :name="`block-${block.type}`"
|
|
122
|
+
:block="block"
|
|
123
|
+
:index="index"
|
|
124
|
+
:position="index + 1"
|
|
125
|
+
:update="(changes) => update(index, changes)">
|
|
126
|
+
<!-- @slot block The editor of a type without its own slot. Props: `block`, `index`, `position`, `update`. -->
|
|
127
|
+
<slot name="block"
|
|
128
|
+
:block="block"
|
|
129
|
+
:index="index"
|
|
130
|
+
:position="index + 1"
|
|
131
|
+
:update="(changes) => update(index, changes)" />
|
|
132
|
+
</slot>
|
|
133
|
+
</div>
|
|
134
|
+
</li>
|
|
135
|
+
</template>
|
|
136
|
+
</Draggable>
|
|
137
|
+
|
|
138
|
+
<div v-if="!disabled && types.length > 0"
|
|
139
|
+
class="cn-block-list-editor__palette"
|
|
140
|
+
role="group"
|
|
141
|
+
:aria-label="text.add"
|
|
142
|
+
data-testid="cn-block-list-palette">
|
|
143
|
+
<template v-if="palette === 'select'">
|
|
144
|
+
<NcSelect v-model="pickedType"
|
|
145
|
+
class="cn-block-list-editor__picker"
|
|
146
|
+
:options="types"
|
|
147
|
+
:inputLabel="text.type"
|
|
148
|
+
:clearable="false"
|
|
149
|
+
label="label" />
|
|
150
|
+
<NcButton :disabled="!pickedType"
|
|
151
|
+
data-action="add"
|
|
152
|
+
@click="add(pickedType.type)">
|
|
153
|
+
{{ text.add }}
|
|
154
|
+
</NcButton>
|
|
155
|
+
</template>
|
|
156
|
+
<template v-else>
|
|
157
|
+
<span class="cn-block-list-editor__palette-label">{{ text.add }}</span>
|
|
158
|
+
<NcButton v-for="option in types"
|
|
159
|
+
:key="option.type"
|
|
160
|
+
:data-add="option.type"
|
|
161
|
+
@click="add(option.type)">
|
|
162
|
+
{{ option.label }}
|
|
163
|
+
</NcButton>
|
|
164
|
+
</template>
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
<!-- @slot preview What the blocks look like together. Props: `blocks`. -->
|
|
168
|
+
<slot name="preview" :blocks="modelValue" />
|
|
169
|
+
</section>
|
|
170
|
+
</template>
|
|
171
|
+
|
|
172
|
+
<script>
|
|
173
|
+
import { translate as t } from '@nextcloud/l10n'
|
|
174
|
+
import { NcButton, NcNoteCard, NcSelect } from '@nextcloud/vue'
|
|
175
|
+
import Draggable from 'vuedraggable'
|
|
176
|
+
import DragVertical from 'vue-material-design-icons/DragVertical.vue'
|
|
177
|
+
|
|
178
|
+
let lastId = 0
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* CnBlockListEditor: an ordered list of typed blocks, each with its own editor
|
|
182
|
+
* (boards LqLesMaken, PqNieuwsbriefWizard, PqProduct).
|
|
183
|
+
*
|
|
184
|
+
* A user adds a block from the palette, and orders the list by dragging or with
|
|
185
|
+
* Move up and Move down. Both say the new position to a screen reader, and the
|
|
186
|
+
* buttons keep focus, so the list works without a pointer (WCAG 2.2 SC 2.1.1,
|
|
187
|
+
* 2.5.7). A block with `draft` waits until the user keeps or discards it, and a
|
|
188
|
+
* block with `pinned` stays where it is.
|
|
189
|
+
*
|
|
190
|
+
* The host owns the list through `v-model` and draws each type's editor in a
|
|
191
|
+
* `block-<type>` slot, so the component knows nothing about what a block holds.
|
|
192
|
+
*
|
|
193
|
+
* ```vue
|
|
194
|
+
* <CnBlockListEditor
|
|
195
|
+
* v-model="blocks"
|
|
196
|
+
* :types="[{ type: 'text', label: 'Text', create: () => ({ text: '' }) }]">
|
|
197
|
+
* <template #block-text="{ block, update }">
|
|
198
|
+
* <NcTextArea :model-value="block.text" label="Text" @update:model-value="update({ text: $event })" />
|
|
199
|
+
* </template>
|
|
200
|
+
* </CnBlockListEditor>
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @event update:modelValue The new list of blocks.
|
|
204
|
+
* @event add A block was added: `{ block, index }`.
|
|
205
|
+
* @event remove A block was removed: `{ block, index }`.
|
|
206
|
+
* @event move A block moved: `{ block, from, to }`.
|
|
207
|
+
* @event keep-draft The user kept a draft: `{ block, index }`.
|
|
208
|
+
* @event discard-draft The user discarded a draft: `{ block, index }`.
|
|
209
|
+
* @event pending-drafts The 1-based positions of the blocks still in draft, on mount and on every change. A host holds its save back while the list is not empty.
|
|
210
|
+
* @spec openspec/changes/block-list-editor/specs/block-list-editor/spec.md
|
|
211
|
+
*/
|
|
212
|
+
export default {
|
|
213
|
+
name: 'CnBlockListEditor',
|
|
214
|
+
|
|
215
|
+
components: { Draggable, DragVertical, NcButton, NcNoteCard, NcSelect },
|
|
216
|
+
|
|
217
|
+
props: {
|
|
218
|
+
/** The blocks: `{ <idKey>, type, draft?, pinned?, ... }`. `draft` is `true`, a note, or `{ note }`. */
|
|
219
|
+
modelValue: { type: Array, default: () => [] },
|
|
220
|
+
/** The block types a user can add: `{ type, label, create? }`; `create()` returns the fields of a new block. */
|
|
221
|
+
types: { type: Array, default: () => [] },
|
|
222
|
+
/** The field that holds a block's id. */
|
|
223
|
+
idKey: { type: String, default: 'id' },
|
|
224
|
+
/** How the palette offers the types: `buttons`, one per type, or `select`, a field with an add button. */
|
|
225
|
+
palette: {
|
|
226
|
+
type: String,
|
|
227
|
+
default: 'buttons',
|
|
228
|
+
validator: (value) => ['buttons', 'select'].includes(value),
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
/** Open a block's editor by pressing its name, rather than showing every editor. */
|
|
232
|
+
collapsible: { type: Boolean, default: false },
|
|
233
|
+
/** Read only: no palette, no moving, no removing. */
|
|
234
|
+
disabled: { type: Boolean, default: false },
|
|
235
|
+
/**
|
|
236
|
+
* Replacement texts, already translated: `add`, `type`, `list`, `empty`, `drag`, `moveUp`, `moveDown`, `remove`,
|
|
237
|
+
* `draft`, `keep`, `discard`, `kept`, `discarded`, `removed`, `added` (`{type}`, `{position}`), `moved`
|
|
238
|
+
* (`{position}`, `{total}`), `draftNotice` (`{position}`), `controlName` (`{action}`, `{type}`, `{position}`).
|
|
239
|
+
*/
|
|
240
|
+
labels: { type: Object, default: () => ({}) },
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
emits: ['update:modelValue', 'add', 'remove', 'move', 'keep-draft', 'discard-draft', 'pending-drafts'],
|
|
244
|
+
|
|
245
|
+
data() {
|
|
246
|
+
return {
|
|
247
|
+
announcement: '',
|
|
248
|
+
openIds: [],
|
|
249
|
+
pickedType: this.types[0] ?? null,
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
computed: {
|
|
254
|
+
/** @return {object} The texts, with library defaults. */
|
|
255
|
+
text() {
|
|
256
|
+
return {
|
|
257
|
+
add: t('nextcloud-vue', 'Add block'),
|
|
258
|
+
type: t('nextcloud-vue', 'Block type'),
|
|
259
|
+
list: t('nextcloud-vue', 'Blocks'),
|
|
260
|
+
empty: t('nextcloud-vue', 'No blocks yet.'),
|
|
261
|
+
drag: t('nextcloud-vue', 'Drag to change the order'),
|
|
262
|
+
moveUp: t('nextcloud-vue', 'Move up'),
|
|
263
|
+
moveDown: t('nextcloud-vue', 'Move down'),
|
|
264
|
+
remove: t('nextcloud-vue', 'Remove'),
|
|
265
|
+
draft: t('nextcloud-vue', 'Draft'),
|
|
266
|
+
keep: t('nextcloud-vue', 'Keep'),
|
|
267
|
+
discard: t('nextcloud-vue', 'Discard'),
|
|
268
|
+
kept: t('nextcloud-vue', 'Draft kept.'),
|
|
269
|
+
discarded: t('nextcloud-vue', 'Draft discarded.'),
|
|
270
|
+
removed: t('nextcloud-vue', 'Block removed.'),
|
|
271
|
+
added: t('nextcloud-vue', '{type} block added at position {position}.'),
|
|
272
|
+
moved: t('nextcloud-vue', 'Block moved to position {position} of {total}.'),
|
|
273
|
+
draftNotice: t('nextcloud-vue', 'Block {position} is still a draft. Keep or discard it first.'),
|
|
274
|
+
controlName: t('nextcloud-vue', '{action}: {type} block {position}'),
|
|
275
|
+
...this.labels,
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
/** @return {number[]} 1-based positions of the blocks still in draft. */
|
|
280
|
+
draftPositions() {
|
|
281
|
+
return this.modelValue.flatMap((block, index) => (block.draft ? [index + 1] : []))
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
/** @return {string} The notice over the list while a draft is pending. */
|
|
285
|
+
draftNoticeText() {
|
|
286
|
+
return this.fill(this.text.draftNotice, { position: this.draftPositions[0] })
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
watch: {
|
|
291
|
+
draftPositions: {
|
|
292
|
+
immediate: true,
|
|
293
|
+
handler(positions, previous) {
|
|
294
|
+
if (!previous || positions.join() !== previous.join()) {
|
|
295
|
+
this.$emit('pending-drafts', positions)
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
methods: {
|
|
302
|
+
t,
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* @param {string} template A text with `{name}` placeholders.
|
|
306
|
+
* @param {object} values The values.
|
|
307
|
+
* @return {string} The text with the values in it.
|
|
308
|
+
*/
|
|
309
|
+
fill(template, values) {
|
|
310
|
+
return template.replace(/\{(\w+)\}/g, (match, key) => (key in values ? String(values[key]) : match))
|
|
311
|
+
},
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* @param {object} block A block.
|
|
315
|
+
* @return {string} The label of its type.
|
|
316
|
+
*/
|
|
317
|
+
typeLabel(block) {
|
|
318
|
+
return this.types.find((option) => option.type === block.type)?.label ?? block.type
|
|
319
|
+
},
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* The accessible name of a control on a block. It starts with the visible label and
|
|
323
|
+
* holds the position, because two blocks of one type would otherwise read the same.
|
|
324
|
+
*
|
|
325
|
+
* @param {string} action The visible label.
|
|
326
|
+
* @param {object} block The block.
|
|
327
|
+
* @param {number} index Its index.
|
|
328
|
+
* @return {string} The name.
|
|
329
|
+
*/
|
|
330
|
+
controlName(action, block, index) {
|
|
331
|
+
return this.fill(this.text.controlName, { action, type: this.typeLabel(block), position: index + 1 })
|
|
332
|
+
},
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* @param {object} block A block in draft.
|
|
336
|
+
* @return {string} What the host wants to say about the draft.
|
|
337
|
+
*/
|
|
338
|
+
draftNote(block) {
|
|
339
|
+
if (typeof block.draft === 'string') {
|
|
340
|
+
return block.draft
|
|
341
|
+
}
|
|
342
|
+
return block.draft?.note ?? ''
|
|
343
|
+
},
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* @param {object} block A block.
|
|
347
|
+
* @return {boolean} Whether its editor shows.
|
|
348
|
+
*/
|
|
349
|
+
isOpen(block) {
|
|
350
|
+
return !this.collapsible || this.openIds.includes(block[this.idKey])
|
|
351
|
+
},
|
|
352
|
+
|
|
353
|
+
/** @param {object} block The block to open or close. */
|
|
354
|
+
toggle(block) {
|
|
355
|
+
const id = block[this.idKey]
|
|
356
|
+
this.openIds = this.openIds.includes(id)
|
|
357
|
+
? this.openIds.filter((other) => other !== id)
|
|
358
|
+
: [...this.openIds, id]
|
|
359
|
+
},
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* @param {number} index A block.
|
|
363
|
+
* @param {number} delta -1 up, 1 down.
|
|
364
|
+
* @return {boolean} Whether it can move that way: a pinned block neither moves nor gives way.
|
|
365
|
+
*/
|
|
366
|
+
canMove(index, delta) {
|
|
367
|
+
const target = this.modelValue[index + delta]
|
|
368
|
+
return !this.disabled && Boolean(target) && !target.pinned && !this.modelValue[index].pinned
|
|
369
|
+
},
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* @param {{relatedContext?: {element?: object}}} event The sortable move event.
|
|
373
|
+
* @return {boolean} Whether a drag may pass this block.
|
|
374
|
+
*/
|
|
375
|
+
canDragOver(event) {
|
|
376
|
+
return !event?.relatedContext?.element?.pinned
|
|
377
|
+
},
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Move a block with a button, say where it landed and keep focus on the button.
|
|
381
|
+
*
|
|
382
|
+
* @param {number} index The block.
|
|
383
|
+
* @param {number} delta -1 up, 1 down.
|
|
384
|
+
*/
|
|
385
|
+
move(index, delta) {
|
|
386
|
+
if (!this.canMove(index, delta)) {
|
|
387
|
+
return
|
|
388
|
+
}
|
|
389
|
+
const next = [...this.modelValue]
|
|
390
|
+
const to = index + delta
|
|
391
|
+
const block = next[index]
|
|
392
|
+
next[index] = next[to]
|
|
393
|
+
next[to] = block
|
|
394
|
+
this.$emit('update:modelValue', next)
|
|
395
|
+
this.$emit('move', { block, from: index, to })
|
|
396
|
+
this.announceMove(to)
|
|
397
|
+
this.$nextTick(() => {
|
|
398
|
+
const used = delta < 0 ? 'up' : 'down'
|
|
399
|
+
const other = delta < 0 ? 'down' : 'up'
|
|
400
|
+
this.focusIn(to, `[data-move="${used}"]:not(:disabled), [data-move="${other}"]:not(:disabled)`, used)
|
|
401
|
+
})
|
|
402
|
+
},
|
|
403
|
+
|
|
404
|
+
/** @param {number} to The index a block landed on. */
|
|
405
|
+
announceMove(to) {
|
|
406
|
+
this.announcement = this.fill(this.text.moved, { position: to + 1, total: this.modelValue.length })
|
|
407
|
+
},
|
|
408
|
+
|
|
409
|
+
/** @param {object[]} blocks The list after a drag. */
|
|
410
|
+
onDragged(blocks) {
|
|
411
|
+
this.$emit('update:modelValue', blocks)
|
|
412
|
+
},
|
|
413
|
+
|
|
414
|
+
/** @param {{moved?: {element: object, oldIndex: number, newIndex: number}}} change What a drag changed. */
|
|
415
|
+
onDragChange({ moved } = {}) {
|
|
416
|
+
if (moved) {
|
|
417
|
+
this.$emit('move', { block: moved.element, from: moved.oldIndex, to: moved.newIndex })
|
|
418
|
+
this.announceMove(moved.newIndex)
|
|
419
|
+
}
|
|
420
|
+
},
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Focus a control of a block: the first match, preferring `prefer` as data-move value.
|
|
424
|
+
*
|
|
425
|
+
* @param {number} index The block.
|
|
426
|
+
* @param {string} selector What to focus.
|
|
427
|
+
* @param {string} [prefer] The data-move value to try first.
|
|
428
|
+
*/
|
|
429
|
+
focusIn(index, selector, prefer) {
|
|
430
|
+
const row = this.$el.querySelectorAll('.cn-block-list-editor__block')[index]
|
|
431
|
+
const matches = row ? [...row.querySelectorAll(selector)] : []
|
|
432
|
+
const target = matches.find((element) => element.dataset?.move === prefer) ?? matches[0]
|
|
433
|
+
target?.focus()
|
|
434
|
+
},
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Put focus on the block that took a removed block's place, or else on the palette.
|
|
438
|
+
*
|
|
439
|
+
* @param {number} index The place of the removed block.
|
|
440
|
+
*/
|
|
441
|
+
focusAfterRemove(index) {
|
|
442
|
+
this.$nextTick(() => {
|
|
443
|
+
const blocks = this.$el.querySelectorAll('.cn-block-list-editor__block')
|
|
444
|
+
const row = blocks[Math.min(index, blocks.length - 1)]
|
|
445
|
+
const target = row?.querySelector('button:not(:disabled)')
|
|
446
|
+
?? this.$el.querySelector('.cn-block-list-editor__palette button:not(:disabled)')
|
|
447
|
+
target?.focus()
|
|
448
|
+
})
|
|
449
|
+
},
|
|
450
|
+
|
|
451
|
+
/** @param {string} type The block type to add, above any pinned blocks at the end. */
|
|
452
|
+
add(type) {
|
|
453
|
+
const option = this.types.find((candidate) => candidate.type === type)
|
|
454
|
+
lastId += 1
|
|
455
|
+
const block = {
|
|
456
|
+
[this.idKey]: `block-${Date.now().toString(36)}-${lastId}`,
|
|
457
|
+
type,
|
|
458
|
+
...(option?.create?.() ?? {}),
|
|
459
|
+
}
|
|
460
|
+
let index = this.modelValue.length
|
|
461
|
+
while (index > 0 && this.modelValue[index - 1].pinned) {
|
|
462
|
+
index -= 1
|
|
463
|
+
}
|
|
464
|
+
const next = [...this.modelValue]
|
|
465
|
+
next.splice(index, 0, block)
|
|
466
|
+
if (this.collapsible) {
|
|
467
|
+
this.openIds = [...this.openIds, block[this.idKey]]
|
|
468
|
+
}
|
|
469
|
+
this.$emit('update:modelValue', next)
|
|
470
|
+
this.$emit('add', { block, index })
|
|
471
|
+
this.announcement = this.fill(this.text.added, { type: this.typeLabel(block), position: index + 1 })
|
|
472
|
+
},
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Drop a block from the list.
|
|
476
|
+
*
|
|
477
|
+
* @param {number} index The block.
|
|
478
|
+
* @return {object} The block that left.
|
|
479
|
+
*/
|
|
480
|
+
drop(index) {
|
|
481
|
+
const next = [...this.modelValue]
|
|
482
|
+
const [block] = next.splice(index, 1)
|
|
483
|
+
this.$emit('update:modelValue', next)
|
|
484
|
+
this.focusAfterRemove(index)
|
|
485
|
+
return block
|
|
486
|
+
},
|
|
487
|
+
|
|
488
|
+
/** @param {number} index The block to remove. */
|
|
489
|
+
remove(index) {
|
|
490
|
+
const block = this.drop(index)
|
|
491
|
+
this.$emit('remove', { block, index })
|
|
492
|
+
this.announcement = this.text.removed
|
|
493
|
+
},
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Merge changed fields into a block.
|
|
497
|
+
*
|
|
498
|
+
* @param {number} index The block.
|
|
499
|
+
* @param {object} changes The fields.
|
|
500
|
+
*/
|
|
501
|
+
update(index, changes) {
|
|
502
|
+
this.$emit('update:modelValue', this.modelValue.map((block, position) => (position === index ? { ...block, ...changes } : block)))
|
|
503
|
+
},
|
|
504
|
+
|
|
505
|
+
/** @param {number} index The draft block the user keeps; it stops being a draft. */
|
|
506
|
+
keepDraft(index) {
|
|
507
|
+
const { draft, ...block } = this.modelValue[index]
|
|
508
|
+
this.$emit('update:modelValue', this.modelValue.map((other, position) => (position === index ? block : other)))
|
|
509
|
+
this.$emit('keep-draft', { block, index })
|
|
510
|
+
this.announcement = this.text.kept
|
|
511
|
+
this.$nextTick(() => this.focusIn(index, 'button:not(:disabled)'))
|
|
512
|
+
},
|
|
513
|
+
|
|
514
|
+
/** @param {number} index The draft block the user throws away. */
|
|
515
|
+
discardDraft(index) {
|
|
516
|
+
const block = this.drop(index)
|
|
517
|
+
this.$emit('discard-draft', { block, index })
|
|
518
|
+
this.announcement = this.text.discarded
|
|
519
|
+
},
|
|
520
|
+
},
|
|
521
|
+
}
|
|
522
|
+
</script>
|
|
523
|
+
|
|
524
|
+
<style scoped>
|
|
525
|
+
.cn-block-list-editor {
|
|
526
|
+
display: flex;
|
|
527
|
+
flex-direction: column;
|
|
528
|
+
gap: 12px;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
.cn-block-list-editor__list {
|
|
532
|
+
display: flex;
|
|
533
|
+
flex-direction: column;
|
|
534
|
+
gap: 8px;
|
|
535
|
+
list-style: none;
|
|
536
|
+
margin: 0;
|
|
537
|
+
padding: 0;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.cn-block-list-editor__block {
|
|
541
|
+
background: var(--color-main-background);
|
|
542
|
+
border: 1px solid var(--color-border);
|
|
543
|
+
border-radius: var(--border-radius-large);
|
|
544
|
+
display: flex;
|
|
545
|
+
flex-direction: column;
|
|
546
|
+
gap: 8px;
|
|
547
|
+
padding: 8px 12px;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
.cn-block-list-editor__block--draft {
|
|
551
|
+
border-color: var(--color-warning);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
.cn-block-list-editor__row {
|
|
555
|
+
align-items: center;
|
|
556
|
+
display: flex;
|
|
557
|
+
flex-wrap: wrap;
|
|
558
|
+
gap: 4px 8px;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
.cn-block-list-editor__handle {
|
|
562
|
+
color: var(--color-text-maxcontrast);
|
|
563
|
+
cursor: grab;
|
|
564
|
+
display: inline-flex;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
.cn-block-list-editor__toggle {
|
|
568
|
+
background: none;
|
|
569
|
+
border: 0;
|
|
570
|
+
color: var(--color-main-text);
|
|
571
|
+
cursor: pointer;
|
|
572
|
+
margin: 0;
|
|
573
|
+
padding: 4px;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
.cn-block-list-editor__summary {
|
|
577
|
+
color: var(--color-text-maxcontrast);
|
|
578
|
+
flex: 1 1 120px;
|
|
579
|
+
min-width: 0;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
.cn-block-list-editor__actions,
|
|
583
|
+
.cn-block-list-editor__draft-actions,
|
|
584
|
+
.cn-block-list-editor__palette {
|
|
585
|
+
align-items: center;
|
|
586
|
+
display: flex;
|
|
587
|
+
flex-wrap: wrap;
|
|
588
|
+
gap: 8px;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
.cn-block-list-editor__draft {
|
|
592
|
+
align-items: center;
|
|
593
|
+
background: var(--color-background-hover);
|
|
594
|
+
border-radius: var(--border-radius-large);
|
|
595
|
+
display: flex;
|
|
596
|
+
flex-wrap: wrap;
|
|
597
|
+
gap: 8px;
|
|
598
|
+
justify-content: space-between;
|
|
599
|
+
padding: 8px 12px;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
.cn-block-list-editor__draft-text,
|
|
603
|
+
.cn-block-list-editor__empty {
|
|
604
|
+
margin: 0;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.cn-block-list-editor__empty,
|
|
608
|
+
.cn-block-list-editor__palette-label {
|
|
609
|
+
color: var(--color-text-maxcontrast);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
.cn-block-list-editor__picker {
|
|
613
|
+
min-width: 220px;
|
|
614
|
+
}
|
|
615
|
+
</style>
|