@conduction/nextcloud-vue 2.174.0 → 2.176.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/dist/esm/components/CnActionDialog/CnActionDialog.vue.js +1 -1
  2. package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js +114 -11
  3. package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js.map +1 -1
  4. package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js +67 -17
  5. package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js.map +1 -1
  6. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js +9 -0
  7. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js.map +1 -0
  8. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js +352 -0
  9. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js.map +1 -0
  10. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js +266 -0
  11. package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js.map +1 -0
  12. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue.js +1 -1
  13. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js +323 -7
  14. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js.map +1 -1
  15. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js +113 -59
  16. package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js.map +1 -1
  17. package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue.js +1 -1
  18. package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js +210 -5
  19. package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js.map +1 -1
  20. package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js +134 -46
  21. package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js.map +1 -1
  22. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js +9 -0
  23. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js.map +1 -0
  24. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js +385 -0
  25. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js.map +1 -0
  26. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js +277 -0
  27. package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js.map +1 -0
  28. package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue.js +1 -1
  29. package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js +175 -20
  30. package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js.map +1 -1
  31. package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js +30 -8
  32. package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js.map +1 -1
  33. package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue.js +1 -1
  34. package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js +72 -6
  35. package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js.map +1 -1
  36. package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js +48 -14
  37. package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js.map +1 -1
  38. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue.js +1 -1
  39. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js +255 -10
  40. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js.map +1 -1
  41. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js +70 -28
  42. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js.map +1 -1
  43. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js +55 -6
  44. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js.map +1 -1
  45. package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js.map +1 -1
  46. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js +9 -0
  47. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js.map +1 -0
  48. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js +175 -0
  49. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js.map +1 -0
  50. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js +114 -0
  51. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js.map +1 -0
  52. package/dist/esm/components/CnDurationField/CnDurationField.vue.js +1 -1
  53. package/dist/esm/components/CnDurationField/CnDurationField.vue2.js +218 -4
  54. package/dist/esm/components/CnDurationField/CnDurationField.vue2.js.map +1 -1
  55. package/dist/esm/components/CnDurationField/CnDurationField.vue3.js +133 -44
  56. package/dist/esm/components/CnDurationField/CnDurationField.vue3.js.map +1 -1
  57. package/dist/esm/components/CnFormDialog/CnFormDialog.vue.js +1 -1
  58. package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js.map +1 -1
  59. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js +5 -1
  60. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
  61. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js +9 -0
  62. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js.map +1 -0
  63. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js +113 -0
  64. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js.map +1 -0
  65. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js +43 -0
  66. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js.map +1 -0
  67. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +40 -1
  68. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
  69. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
  70. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue.js +1 -1
  71. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js +110 -1
  72. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js.map +1 -1
  73. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js +60 -18
  74. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js.map +1 -1
  75. package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js +2 -2
  76. package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js.map +1 -1
  77. package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js +2 -2
  78. package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js.map +1 -1
  79. package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js +2 -2
  80. package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js.map +1 -1
  81. package/dist/esm/components/CnQrCode/CnQrCode.vue.js +9 -0
  82. package/dist/esm/components/CnQrCode/CnQrCode.vue.js.map +1 -0
  83. package/dist/esm/components/CnQrCode/CnQrCode.vue2.js +241 -0
  84. package/dist/esm/components/CnQrCode/CnQrCode.vue2.js.map +1 -0
  85. package/dist/esm/components/CnQrCode/CnQrCode.vue3.js +75 -0
  86. package/dist/esm/components/CnQrCode/CnQrCode.vue3.js.map +1 -0
  87. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue.js +1 -1
  88. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js +34 -3
  89. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js.map +1 -1
  90. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js +81 -19
  91. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js.map +1 -1
  92. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +1 -1
  93. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +11 -0
  94. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -1
  95. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js +112 -88
  96. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -1
  97. package/dist/esm/components/CnRevealField/CnRevealField.vue.js +9 -0
  98. package/dist/esm/components/CnRevealField/CnRevealField.vue.js.map +1 -0
  99. package/dist/esm/components/CnRevealField/CnRevealField.vue2.js +157 -0
  100. package/dist/esm/components/CnRevealField/CnRevealField.vue2.js.map +1 -0
  101. package/dist/esm/components/CnRevealField/CnRevealField.vue3.js +116 -0
  102. package/dist/esm/components/CnRevealField/CnRevealField.vue3.js.map +1 -0
  103. package/dist/esm/components/CnStorePage/CnStorePage.vue.js +1 -1
  104. package/dist/esm/components/CnStorePage/CnStorePage.vue2.js +3 -3
  105. package/dist/esm/components/CnStorePage/CnStorePage.vue2.js.map +1 -1
  106. package/dist/esm/components/CnStorePage/CnStorePage.vue3.js +5 -5
  107. package/dist/esm/components/CnStorePage/CnStorePage.vue3.js.map +1 -1
  108. package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue.js +1 -1
  109. package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue2.js +6 -6
  110. package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue2.js.map +1 -1
  111. package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue3.js +1 -1
  112. package/dist/esm/components/CnStorePage/CnStorePublishDialog.vue3.js.map +1 -1
  113. package/dist/esm/components/CnTextWidget/CnTextWidget.vue.js +1 -1
  114. package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js +43 -3
  115. package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js.map +1 -1
  116. package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js +19 -12
  117. package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js.map +1 -1
  118. package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js +9 -0
  119. package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js.map +1 -0
  120. package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js +87 -0
  121. package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js.map +1 -0
  122. package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js +126 -0
  123. package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js.map +1 -0
  124. package/dist/esm/components/CnTreeView/CnTreeNode.vue.js +1 -1
  125. package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js +66 -1
  126. package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js.map +1 -1
  127. package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js +129 -29
  128. package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js.map +1 -1
  129. package/dist/esm/components/CnTreeView/CnTreeView.vue.js +1 -1
  130. package/dist/esm/components/CnTreeView/CnTreeView.vue2.js +158 -6
  131. package/dist/esm/components/CnTreeView/CnTreeView.vue2.js.map +1 -1
  132. package/dist/esm/components/CnTreeView/CnTreeView.vue3.js +100 -39
  133. package/dist/esm/components/CnTreeView/CnTreeView.vue3.js.map +1 -1
  134. package/dist/esm/index.js +8 -0
  135. package/dist/esm/index.js.map +1 -1
  136. package/dist/esm/l10n/en.json.js +79 -14
  137. package/dist/esm/l10n/en.json.js.map +1 -1
  138. package/dist/esm/l10n/nl.json.js +79 -14
  139. package/dist/esm/l10n/nl.json.js.map +1 -1
  140. package/dist/esm/library-style.js +1 -1
  141. package/dist/esm/nextcloud-vue.css +1162 -523
  142. package/dist/esm/node_modules/vuedraggable/dist/vuedraggable.umd.js +2 -2
  143. package/dist/esm/utils/captureLocation.js +32 -0
  144. package/dist/esm/utils/captureLocation.js.map +1 -0
  145. package/dist/esm/utils/childRecordTotals.js +157 -0
  146. package/dist/esm/utils/childRecordTotals.js.map +1 -0
  147. package/dist/esm/utils/isoDuration.js +51 -1
  148. package/dist/esm/utils/isoDuration.js.map +1 -1
  149. package/dist/esm/utils/parentCrumb.js +86 -0
  150. package/dist/esm/utils/parentCrumb.js.map +1 -0
  151. package/dist/esm/utils/qr.js +649 -0
  152. package/dist/esm/utils/qr.js.map +1 -0
  153. package/dist/esm/utils/schema.js +3 -0
  154. package/dist/esm/utils/schema.js.map +1 -1
  155. package/dist/esm/utils/templateVariables.js +54 -0
  156. package/dist/esm/utils/templateVariables.js.map +1 -0
  157. package/dist/nextcloud-vue.cjs.js +21125 -15025
  158. package/dist/nextcloud-vue.cjs.js.map +2 -2
  159. package/dist/nextcloud-vue.css +1162 -523
  160. package/l10n/en.json +79 -14
  161. package/l10n/nl.json +79 -14
  162. package/package.json +1 -1
  163. package/src/components/CnActionDialog/CnActionDialog.vue +156 -9
  164. package/src/components/CnBlockListEditor/CnBlockListEditor.vue +615 -0
  165. package/src/components/CnBlockListEditor/index.js +9 -0
  166. package/src/components/CnChecklistRunWidget/CnChecklistRunWidget.vue +377 -10
  167. package/src/components/CnChildRecordsField/CnChildRecordsField.vue +306 -15
  168. package/src/components/CnChoiceMatrix/CnChoiceMatrix.vue +710 -0
  169. package/src/components/CnChoiceMatrix/index.js +9 -0
  170. package/src/components/CnCountdownWidget/CnCountdownWidget.vue +223 -28
  171. package/src/components/CnCreateFormWidget/CnCreateFormWidget.vue +97 -6
  172. package/src/components/CnDataMatrix/CnDataMatrix.vue +304 -17
  173. package/src/components/CnDetailPage/CnDetailPage.vue +55 -6
  174. package/src/components/CnDisplayScreen/CnDisplayScreen.vue +308 -0
  175. package/src/components/CnDisplayScreen/index.js +9 -0
  176. package/src/components/CnDurationField/CnDurationField.vue +330 -5
  177. package/src/components/CnFormDialog/CnFormDialog.vue +4 -0
  178. package/src/components/CnGeoCaptureField/CnGeoCaptureField.vue +148 -0
  179. package/src/components/CnGeoCaptureField/index.js +9 -0
  180. package/src/components/CnIndexPage/CnIndexPage.vue +40 -1
  181. package/src/components/CnMarkdownEditor/CnMarkdownEditor.vue +139 -1
  182. package/src/components/CnQrCode/CnQrCode.vue +321 -0
  183. package/src/components/CnQrCode/index.js +9 -0
  184. package/src/components/CnReadinessChecklist/CnReadinessChecklist.vue +80 -3
  185. package/src/components/CnRecordListWidget/CnRecordListWidget.vue +34 -1
  186. package/src/components/CnRevealField/CnRevealField.vue +273 -0
  187. package/src/components/CnRevealField/index.js +9 -0
  188. package/src/components/CnStorePage/CnStorePage.vue +8 -8
  189. package/src/components/CnStorePage/CnStorePublishDialog.vue +7 -7
  190. package/src/components/CnTextWidget/CnTextWidget.vue +62 -3
  191. package/src/components/CnTransferCard/CnTransferCard.vue +205 -0
  192. package/src/components/CnTransferCard/index.js +9 -0
  193. package/src/components/CnTreeView/CnTreeNode.vue +145 -2
  194. package/src/components/CnTreeView/CnTreeView.vue +210 -6
  195. package/src/components/index.js +7 -0
  196. package/src/index.js +8 -0
  197. package/src/utils/captureLocation.js +29 -0
  198. package/src/utils/childRecordTotals.js +153 -0
  199. package/src/utils/isoDuration.js +50 -0
  200. package/src/utils/parentCrumb.js +83 -0
  201. package/src/utils/qr.js +681 -0
  202. package/src/utils/schema.js +3 -0
  203. package/src/utils/templateVariables.js +51 -0
@@ -0,0 +1,710 @@
1
+ <!--
2
+ - SPDX-FileCopyrightText: 2026 Conduction B.V.
3
+ - SPDX-License-Identifier: EUPL-1.2
4
+ -->
5
+ <template>
6
+ <section class="cn-choice-matrix" data-testid="cn-choice-matrix" tabindex="-1">
7
+ <header v-if="title || description" class="cn-choice-matrix__header">
8
+ <h3 v-if="title" class="cn-choice-matrix__title">
9
+ {{ title }}
10
+ </h3>
11
+ <p v-if="description" class="cn-choice-matrix__description">
12
+ {{ description }}
13
+ </p>
14
+ </header>
15
+
16
+ <p v-if="isEmpty"
17
+ class="cn-choice-matrix__empty"
18
+ data-testid="cn-choice-matrix-empty">
19
+ {{ emptyLabel || t('nextcloud-vue', 'Nothing to set yet.') }}
20
+ </p>
21
+
22
+ <template v-else-if="pickPerRow">
23
+ <fieldset v-for="row in rows"
24
+ :key="rowId(row)"
25
+ class="cn-choice-matrix__row"
26
+ role="radiogroup"
27
+ :aria-invalid="rowError(row) ? 'true' : undefined"
28
+ :aria-describedby="rowError(row) ? errorId(row) : undefined"
29
+ :data-testid="`cn-choice-matrix-row-${rowId(row)}`">
30
+ <legend class="cn-choice-matrix__legend">
31
+ {{ row[rowLabelKey] }}
32
+ <span v-if="weightText(row)" class="cn-choice-matrix__weight">{{ weightText(row) }}</span>
33
+ </legend>
34
+ <div class="cn-choice-matrix__options">
35
+ <label v-for="option in optionsOf(row)"
36
+ :key="option.key"
37
+ class="cn-choice-matrix__option"
38
+ :class="{ 'cn-choice-matrix__option--picked': pickedKey(row) === option.key }">
39
+ <input type="radio"
40
+ :name="`${uid}-${rowId(row)}`"
41
+ :value="option.key"
42
+ :checked="pickedKey(row) === option.key"
43
+ :disabled="readOnly || Boolean(row.readOnly)"
44
+ :data-testid="`cn-choice-matrix-option-${rowId(row)}-${option.key}`"
45
+ @change="pick(row, option)">
46
+ <span class="cn-choice-matrix__option-text">
47
+ <span>{{ option.label }}</span>
48
+ <span v-if="option.description" class="cn-choice-matrix__option-detail">{{ option.description }}</span>
49
+ <span v-if="pointsText(option)" class="cn-choice-matrix__option-detail">{{ pointsText(option) }}</span>
50
+ </span>
51
+ </label>
52
+ </div>
53
+ <p v-if="rowError(row)"
54
+ :id="errorId(row)"
55
+ class="cn-choice-matrix__error"
56
+ data-testid="cn-choice-matrix-row-error">
57
+ {{ rowError(row) }}
58
+ </p>
59
+ <NcButton v-if="removable(row)"
60
+ variant="tertiary"
61
+ class="cn-choice-matrix__remove"
62
+ :aria-label="removeLabel(row)"
63
+ :data-testid="`cn-choice-matrix-remove-${rowId(row)}`"
64
+ @click="removeRow(row)">
65
+ {{ t('nextcloud-vue', 'Remove') }}
66
+ </NcButton>
67
+ </fieldset>
68
+ <div v-if="scoreLine || $slots.scoreNote" class="cn-choice-matrix__score" data-testid="cn-choice-matrix-score">
69
+ <strong role="status">{{ scoreLine }}</strong>
70
+ <!-- @slot scoreNote A remark beside the score. -->
71
+ <slot name="scoreNote" />
72
+ </div>
73
+ </template>
74
+
75
+ <div v-else class="cn-choice-matrix__scroller">
76
+ <table class="cn-choice-matrix__table">
77
+ <caption v-if="title" class="cn-choice-matrix__caption">
78
+ {{ title }}
79
+ </caption>
80
+ <thead>
81
+ <tr>
82
+ <th scope="col" class="cn-choice-matrix__corner">
83
+ {{ rowHeader }}
84
+ </th>
85
+ <th v-for="column in columns"
86
+ :key="column.key"
87
+ scope="col"
88
+ class="cn-choice-matrix__col-header"
89
+ :data-testid="`cn-choice-matrix-col-${column.key}`">
90
+ <span>{{ column.label }}</span>
91
+ <span v-if="column.description" class="cn-choice-matrix__col-description">{{ column.description }}</span>
92
+ </th>
93
+ <th v-if="hasRemovable" scope="col" class="cn-choice-matrix__actions">
94
+ <span class="cn-choice-matrix__sr">{{ t('nextcloud-vue', 'Row actions') }}</span>
95
+ </th>
96
+ </tr>
97
+ </thead>
98
+ <tbody>
99
+ <tr v-for="row in rows" :key="rowId(row)">
100
+ <th scope="row" class="cn-choice-matrix__row-header">
101
+ {{ row[rowLabelKey] }}
102
+ <span v-if="rowError(row)" class="cn-choice-matrix__error" data-testid="cn-choice-matrix-row-error">{{ rowError(row) }}</span>
103
+ </th>
104
+ <td v-for="column in columns"
105
+ :key="column.key"
106
+ class="cn-choice-matrix__cell"
107
+ :data-testid="`cn-choice-matrix-cell-${rowId(row)}-${column.key}`">
108
+ <NcSelect v-if="editable(row, column)"
109
+ :modelValue="choiceOf(row, column)"
110
+ :options="choices"
111
+ :clearable="false"
112
+ :searchable="false"
113
+ :ariaLabelCombobox="cellLabel(row, column)"
114
+ label="label"
115
+ @update:modelValue="(choice) => setCell(row, column, choice)" />
116
+ <span v-else
117
+ class="cn-choice-matrix__value"
118
+ :class="toneClass(row, column)"
119
+ data-testid="cn-choice-matrix-value">{{ valueText(row, column) }}</span>
120
+ </td>
121
+ <td v-if="hasRemovable" class="cn-choice-matrix__actions">
122
+ <NcButton v-if="removable(row)"
123
+ variant="tertiary"
124
+ :aria-label="removeLabel(row)"
125
+ :data-testid="`cn-choice-matrix-remove-${rowId(row)}`"
126
+ @click="removeRow(row)">
127
+ {{ t('nextcloud-vue', 'Remove') }}
128
+ </NcButton>
129
+ </td>
130
+ </tr>
131
+ </tbody>
132
+ </table>
133
+ </div>
134
+ <p class="cn-choice-matrix__sr" aria-live="polite" data-testid="cn-choice-matrix-status">
135
+ {{ status }}
136
+ </p>
137
+ </section>
138
+ </template>
139
+
140
+ <script>
141
+ import { translate as t } from '@nextcloud/l10n'
142
+ import { NcButton, NcSelect } from '@nextcloud/vue'
143
+ import { userLocale } from '../../utils/userLocale.js'
144
+
145
+ let lastUid = 0
146
+
147
+ /**
148
+ * CnChoiceMatrix: rows against columns, every cell one choice out of the same
149
+ * closed set (board DqZaaktypeVelden: fields against role and status, each
150
+ * cell hidden, required or read only). `CnDataMatrix` is the grid for free
151
+ * values, `CnActionAuthMatrix` the one for ticks.
152
+ *
153
+ * The value is a map `{ [rowId]: { [columnKey]: choiceValue } }`. A cell with
154
+ * no stored value shows `defaultValue`. A change emits the whole new map, so
155
+ * the host saves it or a single cell as it likes, and refusing a save is only
156
+ * a matter of not passing the new map back in.
157
+ *
158
+ * ```vue
159
+ * <CnChoiceMatrix
160
+ * row-header="Field"
161
+ * :rows="[{ id: 'costs', label: 'Building costs' }]"
162
+ * :columns="[{ key: 'intake', label: 'Intake', description: 'received' }]"
163
+ * :choices="[
164
+ * { value: 'hidden', label: 'Hidden', tone: 'muted' },
165
+ * { value: 'required', label: 'Required', tone: 'strong' },
166
+ * { value: 'readonly', label: 'Read only' },
167
+ * ]"
168
+ * :model-value="rights"
169
+ * default-value="readonly"
170
+ * @update:model-value="rights = $event" />
171
+ * ```
172
+ *
173
+ * With `pickPerRow` a row holds one pick rather than a value per column, as a
174
+ * rubric does (boards LqInleveringNakijken, LqLlInleveren): radio buttons per
175
+ * row, each with its text and points, and a running score. The value is then
176
+ * `{ [rowId]: optionKey }`. The options are the `columns`, or a row's own
177
+ * `options` when its levels differ.
178
+ *
179
+ * @event update:modelValue The whole new map after a cell changed.
180
+ * @event cell-change One changed cell: `{ rowId, columnKey, value, previous }`.
181
+ * @event score-change With `pickPerRow`, on mount and on every change: `{ score, max, complete }`.
182
+ *
183
+ * @spec openspec/changes/choice-matrix/specs/choice-matrix/spec.md
184
+ */
185
+ export default {
186
+ name: 'CnChoiceMatrix',
187
+
188
+ components: { NcButton, NcSelect },
189
+
190
+ props: {
191
+ /**
192
+ * The rows: objects with an id (`rowIdKey`), a label (`rowLabelKey`) and an optional `readOnly`.
193
+ * With `pickPerRow` also `weight` and `options`: `{ key, label, description?, points? }`.
194
+ */
195
+ rows: { type: Array, default: () => [] },
196
+ /** The columns: `{ key, label, description?, readOnly?, points? }`. */
197
+ columns: { type: Array, default: () => [] },
198
+ /** The closed set every cell picks from: `{ value, label, tone? }`, `tone` being `muted` or `strong`. */
199
+ choices: { type: Array, default: () => [] },
200
+ /** The stored choices: `{ [rowId]: { [columnKey]: value } }`, or with `pickPerRow` `{ [rowId]: optionKey }`. */
201
+ modelValue: { type: Object, default: () => ({}) },
202
+ /** The choice value a cell shows while nothing is stored for it. */
203
+ defaultValue: { type: String, default: '' },
204
+ /** Key of a row's id. */
205
+ rowIdKey: { type: String, default: 'id' },
206
+ /** Key of a row's label. */
207
+ rowLabelKey: { type: String, default: 'label' },
208
+ /** Heading of the row column, already translated. */
209
+ rowHeader: { type: String, default: '' },
210
+ /** Title above the grid, already translated. */
211
+ title: { type: String, default: '' },
212
+ /** A line under the title, already translated. */
213
+ description: { type: String, default: '' },
214
+ /** Text when there are no rows or columns; the library default is "Nothing to set yet.". */
215
+ emptyLabel: { type: String, default: '' },
216
+ /** Draw every cell as text. */
217
+ readOnly: { type: Boolean, default: false },
218
+ /** A row holds one pick, drawn as radio buttons, rather than a choice per column. */
219
+ pickPerRow: { type: Boolean, default: false },
220
+ /** Show the score: `true` for the library's words, or a text with `{score}` and `{max}`, already translated. */
221
+ scoreLabel: { type: [Boolean, String], default: false },
222
+ /** The most a user can score; the sum of each row's highest points when null. */
223
+ scoreMax: { type: Number, default: null },
224
+ /** How picks add up: `sum` adds the points, `weighted` multiplies each by its row's `weight` first. */
225
+ scoreMode: { type: String, default: 'sum', validator: (value) => ['sum', 'weighted'].includes(value) },
226
+ /** A row's weight in words, already translated, with `{weight}`. */
227
+ weightTemplate: { type: String, default: '' },
228
+ /** Errors per row, already translated: `{ [rowId]: text }`. */
229
+ rowErrors: { type: Object, default: () => ({}) },
230
+ /** A Remove button per row; a row with `removable: false` keeps none. Ignored when `readOnly`. */
231
+ removableRows: { type: Boolean, default: false },
232
+ },
233
+
234
+ emits: ['update:modelValue', 'cell-change', 'score-change', 'remove-row'],
235
+
236
+ data() {
237
+ lastUid += 1
238
+ return { uid: `cn-choice-matrix-${lastUid}`, status: '' }
239
+ },
240
+
241
+ computed: {
242
+ /** @return {boolean} Whether there is nothing to draw. */
243
+ /**
244
+ * @return {boolean} Whether any row shows a Remove button, which adds the actions column.
245
+ */
246
+ hasRemovable() {
247
+ return this.rows.some((row) => this.removable(row))
248
+ },
249
+
250
+ isEmpty() {
251
+ if (this.rows.length === 0) {
252
+ return true
253
+ }
254
+ return this.pickPerRow
255
+ ? this.rows.every((row) => this.optionsOf(row).length === 0)
256
+ : this.columns.length === 0
257
+ },
258
+
259
+ /** @return {{score: number, max: number, complete: boolean}} The running score. */
260
+ score() {
261
+ let score = 0
262
+ let max = 0
263
+ let complete = true
264
+ for (const row of this.rows) {
265
+ const factor = this.scoreMode === 'weighted' ? (Number(row.weight) || 0) : 1
266
+ const options = this.optionsOf(row)
267
+ const picked = options.find((option) => option.key === this.pickedKey(row))
268
+ max += Math.max(0, ...options.map((option) => Number(option.points) || 0)) * factor
269
+ score += (Number(picked?.points) || 0) * factor
270
+ complete = complete && (Boolean(picked) || Boolean(row.readOnly))
271
+ }
272
+ return { score, max: this.scoreMax ?? max, complete }
273
+ },
274
+
275
+ /** @return {string} The score in words, or ''. */
276
+ scoreLine() {
277
+ if (!this.scoreLabel) {
278
+ return ''
279
+ }
280
+ const score = this.formatNumber(this.score.score)
281
+ const max = this.formatNumber(this.score.max)
282
+ return typeof this.scoreLabel === 'string'
283
+ ? this.scoreLabel.replace('{score}', score).replace('{max}', max)
284
+ : t('nextcloud-vue', 'Score: {score} of {max}', { score, max })
285
+ },
286
+ },
287
+
288
+ watch: {
289
+ score: {
290
+ immediate: true,
291
+ handler(next, previous) {
292
+ if (this.pickPerRow && JSON.stringify(next) !== JSON.stringify(previous)) {
293
+ this.$emit('score-change', next)
294
+ }
295
+ },
296
+ },
297
+ },
298
+
299
+ methods: {
300
+ t,
301
+
302
+ /**
303
+ * @param {number} value A number.
304
+ * @return {string} The number in the user's locale, with at most two decimals.
305
+ */
306
+ formatNumber(value) {
307
+ return value.toLocaleString(userLocale(), { maximumFractionDigits: 2 })
308
+ },
309
+
310
+ /**
311
+ * @param {object} row A row.
312
+ * @return {object[]} What the row picks from: its own options, else the columns.
313
+ */
314
+ optionsOf(row) {
315
+ return Array.isArray(row.options) ? row.options : this.columns
316
+ },
317
+
318
+ /**
319
+ * @param {object} row A row.
320
+ * @return {string|undefined} The key of the option the row holds.
321
+ */
322
+ pickedKey(row) {
323
+ return this.modelValue?.[this.rowId(row)]
324
+ },
325
+
326
+ /**
327
+ * @param {object} row A row.
328
+ * @return {string} The row's weight in words, or ''.
329
+ */
330
+ weightText(row) {
331
+ if (row.weight === undefined || row.weight === null || row.weight === '') {
332
+ return ''
333
+ }
334
+ const weight = String(row.weight)
335
+ return this.weightTemplate
336
+ ? this.weightTemplate.replace('{weight}', weight)
337
+ : t('nextcloud-vue', '(weight {weight})', { weight })
338
+ },
339
+
340
+ /**
341
+ * @param {object} option An option.
342
+ * @return {string} Its points in words, or ''.
343
+ */
344
+ pointsText(option) {
345
+ if (option.points === undefined || option.points === null) {
346
+ return ''
347
+ }
348
+ const points = this.formatNumber(Number(option.points))
349
+ return Number(option.points) === 1
350
+ ? t('nextcloud-vue', '{points} point', { points })
351
+ : t('nextcloud-vue', '{points} points', { points })
352
+ },
353
+
354
+ /**
355
+ * @param {object} row A row.
356
+ * @return {string} The row's error, or ''.
357
+ */
358
+ rowError(row) {
359
+ return this.rowErrors?.[this.rowId(row)] ?? ''
360
+ },
361
+
362
+ /**
363
+ * @param {object} row A row.
364
+ * @return {string} The id of the row's error line.
365
+ */
366
+ errorId(row) {
367
+ return `${this.uid}-error-${this.rowId(row)}`
368
+ },
369
+
370
+ /**
371
+ * Emit the new map for a picked option.
372
+ *
373
+ * @param {object} row A row.
374
+ * @param {object} option The picked option.
375
+ * @return {void}
376
+ */
377
+ pick(row, option) {
378
+ const rowId = this.rowId(row)
379
+ const previous = this.pickedKey(row)
380
+ this.$emit('update:modelValue', { ...this.modelValue, [rowId]: option.key })
381
+ this.$emit('cell-change', { rowId, columnKey: option.key, value: option.key, previous })
382
+ },
383
+
384
+ /**
385
+ * @param {object} row A row.
386
+ * @return {boolean} Whether the row shows a Remove button.
387
+ * @spec openspec/changes/choice-matrix-removable-rows/tasks.md#task-1
388
+ */
389
+ removable(row) {
390
+ return this.removableRows && !this.readOnly && row.removable !== false
391
+ },
392
+
393
+ /**
394
+ * @param {object} row A row.
395
+ * @return {string} The accessible name of its Remove button.
396
+ */
397
+ removeLabel(row) {
398
+ return t('nextcloud-vue', 'Remove {row}', { row: String(row[this.rowLabelKey] ?? '') })
399
+ },
400
+
401
+ /**
402
+ * Remove a row: emit the map without it and `remove-row`, so the host
403
+ * drops it from `rows`, and say so to a screen reader.
404
+ *
405
+ * @param {object} row A row.
406
+ * @return {void}
407
+ * @spec openspec/changes/choice-matrix-removable-rows/tasks.md#task-1
408
+ */
409
+ removeRow(row) {
410
+ const rowId = this.rowId(row)
411
+ const next = { ...this.modelValue }
412
+ delete next[rowId]
413
+ this.$emit('update:modelValue', next)
414
+ this.$emit('remove-row', { rowId, row })
415
+ this.status = t('nextcloud-vue', 'Removed {row}.', { row: String(row[this.rowLabelKey] ?? '') })
416
+ const index = this.rows.indexOf(row)
417
+ this.$nextTick(() => this.focusAfterRemove(index))
418
+ },
419
+
420
+ /**
421
+ * Keep the keyboard in the grid after a row is gone: the Remove button
422
+ * now at the removed row's place, else the last one, else the grid.
423
+ *
424
+ * @param {number} index Where the removed row was.
425
+ * @return {void}
426
+ */
427
+ focusAfterRemove(index) {
428
+ const buttons = this.$el.querySelectorAll('[data-testid^="cn-choice-matrix-remove-"]')
429
+ const target = buttons[Math.min(index, buttons.length - 1)] || this.$el
430
+ target.focus()
431
+ },
432
+
433
+ /**
434
+ * @param {object} row A row.
435
+ * @return {string} The row's id as a string.
436
+ */
437
+ rowId(row) {
438
+ return String(row[this.rowIdKey])
439
+ },
440
+
441
+ /**
442
+ * @param {object} row A row.
443
+ * @param {object} column A column.
444
+ * @return {boolean} Whether this cell offers a choice.
445
+ */
446
+ editable(row, column) {
447
+ return !this.readOnly && !row.readOnly && !column.readOnly
448
+ },
449
+
450
+ /**
451
+ * @param {object} row A row.
452
+ * @param {object} column A column.
453
+ * @return {string} The stored value, else `defaultValue`.
454
+ */
455
+ valueOf(row, column) {
456
+ return this.modelValue?.[this.rowId(row)]?.[column.key] ?? this.defaultValue
457
+ },
458
+
459
+ /**
460
+ * @param {object} row A row.
461
+ * @param {object} column A column.
462
+ * @return {object|null} The choice the cell holds, null when it matches none.
463
+ */
464
+ choiceOf(row, column) {
465
+ const value = this.valueOf(row, column)
466
+ return this.choices.find((choice) => choice.value === value) ?? null
467
+ },
468
+
469
+ /**
470
+ * The cell as text. A stored value outside the set shows as it is, so
471
+ * it is seen rather than read as empty.
472
+ *
473
+ * @param {object} row A row.
474
+ * @param {object} column A column.
475
+ * @return {string} What a read-only cell says.
476
+ */
477
+ valueText(row, column) {
478
+ return this.choiceOf(row, column)?.label ?? String(this.valueOf(row, column))
479
+ },
480
+
481
+ /**
482
+ * @param {object} row A row.
483
+ * @param {object} column A column.
484
+ * @return {string} The class of the cell's tone, or ''.
485
+ */
486
+ toneClass(row, column) {
487
+ const tone = this.choiceOf(row, column)?.tone
488
+ return tone ? `cn-choice-matrix__value--${tone}` : ''
489
+ },
490
+
491
+ /**
492
+ * @param {object} row A row.
493
+ * @param {object} column A column.
494
+ * @return {string} A name for the cell's control, naming both axes.
495
+ */
496
+ cellLabel(row, column) {
497
+ return `${row[this.rowLabelKey]}, ${column.label}`
498
+ },
499
+
500
+ /**
501
+ * Emit the new map for a picked choice. Picking what the cell already
502
+ * holds, or nothing, changes nothing.
503
+ *
504
+ * @param {object} row A row.
505
+ * @param {object} column A column.
506
+ * @param {object|null} choice The picked choice.
507
+ * @return {void}
508
+ */
509
+ setCell(row, column, choice) {
510
+ const previous = this.valueOf(row, column)
511
+ if (!choice || choice.value === previous) {
512
+ return
513
+ }
514
+ const rowId = this.rowId(row)
515
+ this.$emit('update:modelValue', {
516
+ ...this.modelValue,
517
+ [rowId]: { ...(this.modelValue?.[rowId] ?? {}), [column.key]: choice.value },
518
+ })
519
+ this.$emit('cell-change', { rowId, columnKey: column.key, value: choice.value, previous })
520
+ },
521
+ },
522
+ }
523
+ </script>
524
+
525
+ <style scoped>
526
+ .cn-choice-matrix {
527
+ display: flex;
528
+ flex-direction: column;
529
+ gap: 8px;
530
+ }
531
+
532
+ .cn-choice-matrix__title {
533
+ font-size: 1.1em;
534
+ margin: 0;
535
+ }
536
+
537
+ .cn-choice-matrix__description,
538
+ .cn-choice-matrix__empty,
539
+ .cn-choice-matrix__col-description {
540
+ color: var(--color-text-maxcontrast);
541
+ }
542
+
543
+ .cn-choice-matrix__description,
544
+ .cn-choice-matrix__empty {
545
+ margin: 0;
546
+ }
547
+
548
+ .cn-choice-matrix__row {
549
+ border: 0;
550
+ border-top: 1px solid var(--color-border);
551
+ display: flex;
552
+ flex-direction: column;
553
+ gap: 8px;
554
+ margin: 0;
555
+ min-width: 0;
556
+ padding: 12px 0 0;
557
+ }
558
+
559
+ .cn-choice-matrix__legend {
560
+ font-weight: 600;
561
+ padding: 0;
562
+ }
563
+
564
+ .cn-choice-matrix__weight {
565
+ color: var(--color-text-maxcontrast);
566
+ font-size: 0.9em;
567
+ font-weight: normal;
568
+ }
569
+
570
+ .cn-choice-matrix__options {
571
+ display: grid;
572
+ gap: 8px;
573
+ grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
574
+ }
575
+
576
+ .cn-choice-matrix__option {
577
+ align-items: flex-start;
578
+ border: 1px solid var(--color-border);
579
+ border-radius: var(--border-radius-large);
580
+ cursor: pointer;
581
+ display: flex;
582
+ gap: 8px;
583
+ padding: 8px 12px;
584
+ }
585
+
586
+ .cn-choice-matrix__option--picked {
587
+ background: var(--color-primary-element-light);
588
+ border-color: var(--color-primary-element);
589
+ color: var(--color-primary-element-light-text);
590
+ }
591
+
592
+ .cn-choice-matrix__option input {
593
+ accent-color: var(--color-primary-element);
594
+ flex: none;
595
+ margin: 2px 0 0;
596
+ }
597
+
598
+ .cn-choice-matrix__option-text {
599
+ display: flex;
600
+ flex-direction: column;
601
+ gap: 2px;
602
+ min-width: 0;
603
+ }
604
+
605
+ .cn-choice-matrix__option-detail {
606
+ font-size: 0.9em;
607
+ }
608
+
609
+ .cn-choice-matrix__actions {
610
+ width: 1%;
611
+ white-space: nowrap;
612
+ }
613
+
614
+ .cn-choice-matrix__remove {
615
+ margin-top: 4px;
616
+ }
617
+
618
+ .cn-choice-matrix__sr {
619
+ position: absolute;
620
+ width: 1px;
621
+ height: 1px;
622
+ overflow: hidden;
623
+ clip-path: inset(50%);
624
+ white-space: nowrap;
625
+ }
626
+
627
+ .cn-choice-matrix__error {
628
+ color: var(--color-error-text, var(--color-error));
629
+ display: block;
630
+ font-weight: normal;
631
+ margin: 0;
632
+ white-space: normal;
633
+ }
634
+
635
+ .cn-choice-matrix__score {
636
+ align-items: center;
637
+ background: var(--color-background-hover);
638
+ border-radius: var(--border-radius-large);
639
+ display: flex;
640
+ flex-wrap: wrap;
641
+ gap: 8px 16px;
642
+ justify-content: space-between;
643
+ padding: 12px 16px;
644
+ }
645
+
646
+ .cn-choice-matrix__scroller {
647
+ border: 1px solid var(--color-border);
648
+ border-radius: var(--border-radius-large);
649
+ overflow-x: auto;
650
+ }
651
+
652
+ .cn-choice-matrix__table {
653
+ border-collapse: collapse;
654
+ width: 100%;
655
+ }
656
+
657
+ .cn-choice-matrix__caption {
658
+ block-size: 1px;
659
+ clip-path: inset(50%);
660
+ inline-size: 1px;
661
+ overflow: hidden;
662
+ position: absolute;
663
+ white-space: nowrap;
664
+ }
665
+
666
+ .cn-choice-matrix__corner,
667
+ .cn-choice-matrix__col-header {
668
+ background: var(--color-background-hover);
669
+ border-bottom: 1px solid var(--color-border);
670
+ font-weight: 600;
671
+ padding: 8px 12px;
672
+ text-align: start;
673
+ vertical-align: top;
674
+ }
675
+
676
+ .cn-choice-matrix__col-header > span {
677
+ display: block;
678
+ }
679
+
680
+ .cn-choice-matrix__col-description {
681
+ font-size: 0.9em;
682
+ font-weight: normal;
683
+ }
684
+
685
+ .cn-choice-matrix__row-header {
686
+ border-bottom: 1px solid var(--color-border);
687
+ font-weight: 500;
688
+ padding: 6px 12px;
689
+ text-align: start;
690
+ white-space: nowrap;
691
+ }
692
+
693
+ .cn-choice-matrix__cell {
694
+ border-bottom: 1px solid var(--color-border);
695
+ min-width: 160px;
696
+ padding: 6px 12px;
697
+ }
698
+
699
+ tbody tr:last-child > * {
700
+ border-bottom: 0;
701
+ }
702
+
703
+ .cn-choice-matrix__value--muted {
704
+ color: var(--color-text-maxcontrast);
705
+ }
706
+
707
+ .cn-choice-matrix__value--strong {
708
+ font-weight: 600;
709
+ }
710
+ </style>