@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.
Files changed (180) 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 +257 -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 +162 -9
  40. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js.map +1 -1
  41. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js +63 -23
  42. package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js.map +1 -1
  43. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js +9 -0
  44. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js.map +1 -0
  45. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js +175 -0
  46. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js.map +1 -0
  47. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js +114 -0
  48. package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js.map +1 -0
  49. package/dist/esm/components/CnDurationField/CnDurationField.vue.js +1 -1
  50. package/dist/esm/components/CnDurationField/CnDurationField.vue2.js +218 -4
  51. package/dist/esm/components/CnDurationField/CnDurationField.vue2.js.map +1 -1
  52. package/dist/esm/components/CnDurationField/CnDurationField.vue3.js +133 -44
  53. package/dist/esm/components/CnDurationField/CnDurationField.vue3.js.map +1 -1
  54. package/dist/esm/components/CnFormDialog/CnFormDialog.vue.js +1 -1
  55. package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js.map +1 -1
  56. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js +5 -1
  57. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
  58. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js +9 -0
  59. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js.map +1 -0
  60. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js +113 -0
  61. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js.map +1 -0
  62. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js +43 -0
  63. package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js.map +1 -0
  64. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue.js +1 -1
  65. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js +110 -1
  66. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js.map +1 -1
  67. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js +60 -18
  68. package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js.map +1 -1
  69. package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js +2 -2
  70. package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js.map +1 -1
  71. package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js +2 -2
  72. package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js.map +1 -1
  73. package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js +2 -2
  74. package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js.map +1 -1
  75. package/dist/esm/components/CnQrCode/CnQrCode.vue.js +9 -0
  76. package/dist/esm/components/CnQrCode/CnQrCode.vue.js.map +1 -0
  77. package/dist/esm/components/CnQrCode/CnQrCode.vue2.js +241 -0
  78. package/dist/esm/components/CnQrCode/CnQrCode.vue2.js.map +1 -0
  79. package/dist/esm/components/CnQrCode/CnQrCode.vue3.js +75 -0
  80. package/dist/esm/components/CnQrCode/CnQrCode.vue3.js.map +1 -0
  81. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue.js +1 -1
  82. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js +34 -3
  83. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js.map +1 -1
  84. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js +81 -19
  85. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js.map +1 -1
  86. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +1 -1
  87. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +11 -0
  88. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -1
  89. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js +112 -88
  90. package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -1
  91. package/dist/esm/components/CnRevealField/CnRevealField.vue.js +9 -0
  92. package/dist/esm/components/CnRevealField/CnRevealField.vue.js.map +1 -0
  93. package/dist/esm/components/CnRevealField/CnRevealField.vue2.js +157 -0
  94. package/dist/esm/components/CnRevealField/CnRevealField.vue2.js.map +1 -0
  95. package/dist/esm/components/CnRevealField/CnRevealField.vue3.js +116 -0
  96. package/dist/esm/components/CnRevealField/CnRevealField.vue3.js.map +1 -0
  97. package/dist/esm/components/CnTextWidget/CnTextWidget.vue.js +1 -1
  98. package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js +43 -3
  99. package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js.map +1 -1
  100. package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js +19 -12
  101. package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js.map +1 -1
  102. package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js +9 -0
  103. package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js.map +1 -0
  104. package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js +87 -0
  105. package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js.map +1 -0
  106. package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js +126 -0
  107. package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js.map +1 -0
  108. package/dist/esm/components/CnTreeView/CnTreeNode.vue.js +1 -1
  109. package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js +66 -1
  110. package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js.map +1 -1
  111. package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js +129 -29
  112. package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js.map +1 -1
  113. package/dist/esm/components/CnTreeView/CnTreeView.vue.js +1 -1
  114. package/dist/esm/components/CnTreeView/CnTreeView.vue2.js +158 -6
  115. package/dist/esm/components/CnTreeView/CnTreeView.vue2.js.map +1 -1
  116. package/dist/esm/components/CnTreeView/CnTreeView.vue3.js +100 -39
  117. package/dist/esm/components/CnTreeView/CnTreeView.vue3.js.map +1 -1
  118. package/dist/esm/index.js +8 -0
  119. package/dist/esm/index.js.map +1 -1
  120. package/dist/esm/l10n/en.json.js +63 -1
  121. package/dist/esm/l10n/en.json.js.map +1 -1
  122. package/dist/esm/l10n/nl.json.js +63 -1
  123. package/dist/esm/l10n/nl.json.js.map +1 -1
  124. package/dist/esm/library-style.js +1 -1
  125. package/dist/esm/nextcloud-vue.css +1134 -499
  126. package/dist/esm/node_modules/vuedraggable/dist/vuedraggable.umd.js +2 -2
  127. package/dist/esm/utils/captureLocation.js +32 -0
  128. package/dist/esm/utils/captureLocation.js.map +1 -0
  129. package/dist/esm/utils/childRecordTotals.js +157 -0
  130. package/dist/esm/utils/childRecordTotals.js.map +1 -0
  131. package/dist/esm/utils/isoDuration.js +51 -1
  132. package/dist/esm/utils/isoDuration.js.map +1 -1
  133. package/dist/esm/utils/qr.js +649 -0
  134. package/dist/esm/utils/qr.js.map +1 -0
  135. package/dist/esm/utils/schema.js +3 -0
  136. package/dist/esm/utils/schema.js.map +1 -1
  137. package/dist/esm/utils/templateVariables.js +54 -0
  138. package/dist/esm/utils/templateVariables.js.map +1 -0
  139. package/dist/nextcloud-vue.cjs.js +20307 -14544
  140. package/dist/nextcloud-vue.cjs.js.map +2 -2
  141. package/dist/nextcloud-vue.css +1134 -499
  142. package/l10n/en.json +63 -1
  143. package/l10n/nl.json +63 -1
  144. package/package.json +1 -1
  145. package/src/components/CnActionDialog/CnActionDialog.vue +156 -9
  146. package/src/components/CnBlockListEditor/CnBlockListEditor.vue +615 -0
  147. package/src/components/CnBlockListEditor/index.js +9 -0
  148. package/src/components/CnChecklistRunWidget/CnChecklistRunWidget.vue +311 -10
  149. package/src/components/CnChildRecordsField/CnChildRecordsField.vue +306 -15
  150. package/src/components/CnChoiceMatrix/CnChoiceMatrix.vue +710 -0
  151. package/src/components/CnChoiceMatrix/index.js +9 -0
  152. package/src/components/CnCountdownWidget/CnCountdownWidget.vue +223 -28
  153. package/src/components/CnCreateFormWidget/CnCreateFormWidget.vue +97 -6
  154. package/src/components/CnDataMatrix/CnDataMatrix.vue +199 -13
  155. package/src/components/CnDisplayScreen/CnDisplayScreen.vue +308 -0
  156. package/src/components/CnDisplayScreen/index.js +9 -0
  157. package/src/components/CnDurationField/CnDurationField.vue +330 -5
  158. package/src/components/CnFormDialog/CnFormDialog.vue +4 -0
  159. package/src/components/CnGeoCaptureField/CnGeoCaptureField.vue +148 -0
  160. package/src/components/CnGeoCaptureField/index.js +9 -0
  161. package/src/components/CnMarkdownEditor/CnMarkdownEditor.vue +139 -1
  162. package/src/components/CnQrCode/CnQrCode.vue +321 -0
  163. package/src/components/CnQrCode/index.js +9 -0
  164. package/src/components/CnReadinessChecklist/CnReadinessChecklist.vue +80 -3
  165. package/src/components/CnRecordListWidget/CnRecordListWidget.vue +34 -1
  166. package/src/components/CnRevealField/CnRevealField.vue +273 -0
  167. package/src/components/CnRevealField/index.js +9 -0
  168. package/src/components/CnTextWidget/CnTextWidget.vue +62 -3
  169. package/src/components/CnTransferCard/CnTransferCard.vue +205 -0
  170. package/src/components/CnTransferCard/index.js +9 -0
  171. package/src/components/CnTreeView/CnTreeNode.vue +145 -2
  172. package/src/components/CnTreeView/CnTreeView.vue +210 -6
  173. package/src/components/index.js +7 -0
  174. package/src/index.js +8 -0
  175. package/src/utils/captureLocation.js +29 -0
  176. package/src/utils/childRecordTotals.js +153 -0
  177. package/src/utils/isoDuration.js +50 -0
  178. package/src/utils/qr.js +681 -0
  179. package/src/utils/schema.js +3 -0
  180. package/src/utils/templateVariables.js +51 -0
@@ -21,18 +21,27 @@
21
21
  class="cn-data-matrix__col-header"
22
22
  :style="col.width ? { width: col.width } : null">
23
23
  {{ col.label || col.key }}
24
+ <span v-if="weightText(col)" class="cn-data-matrix__weight">{{ weightText(col) }}</span>
24
25
  </th>
25
26
  <th v-if="showRowTotals" class="cn-data-matrix__total-header">
26
27
  {{ rowTotalsLabel }}
27
28
  </th>
29
+ <th v-if="showRank" class="cn-data-matrix__total-header cn-data-matrix__rank-header">
30
+ {{ resolvedRankLabel }}
31
+ </th>
28
32
  </tr>
29
33
  </thead>
30
34
  <tbody>
31
35
  <tr v-for="row in rows"
32
36
  :key="row[rowIdKey]"
33
- class="cn-data-matrix__row">
34
- <th v-if="rowHeader" class="cn-data-matrix__row-header" :title="row[rowLabelKey]">
37
+ class="cn-data-matrix__row"
38
+ :class="{ 'cn-data-matrix__row--top': highlightTopRank && ranks.get(row[rowIdKey]) === 1 }">
39
+ <th v-if="rowHeader"
40
+ scope="row"
41
+ class="cn-data-matrix__row-header"
42
+ :title="row[rowLabelKey]">
35
43
  {{ row[rowLabelKey] }}
44
+ <span v-if="rowSublabelKey && row[rowSublabelKey]" class="cn-data-matrix__row-sublabel">{{ row[rowSublabelKey] }}</span>
36
45
  </th>
37
46
  <td v-for="col in columns"
38
47
  :key="col.key"
@@ -56,7 +65,10 @@
56
65
  </span>
57
66
  </td>
58
67
  <td v-if="showRowTotals" class="cn-data-matrix__total-cell">
59
- {{ formatCell(rowTotal(row), { type: 'number' }) }}
68
+ {{ formatTotal(rowTotal(row)) }}
69
+ </td>
70
+ <td v-if="showRank" class="cn-data-matrix__total-cell cn-data-matrix__rank-cell">
71
+ {{ ranks.has(row[rowIdKey]) ? ranks.get(row[rowIdKey]) : '' }}
60
72
  </td>
61
73
  </tr>
62
74
  <tr v-if="showColumnTotals" class="cn-data-matrix__totals-row">
@@ -69,8 +81,9 @@
69
81
  {{ formatCell(columnTotal(col), { type: 'number' }) }}
70
82
  </td>
71
83
  <td v-if="showRowTotals" class="cn-data-matrix__total-cell cn-data-matrix__grand-total">
72
- {{ formatCell(grandTotal, { type: 'number' }) }}
84
+ {{ formatTotal(grandTotal) }}
73
85
  </td>
86
+ <td v-if="showRank" class="cn-data-matrix__total-cell" />
74
87
  </tr>
75
88
  </tbody>
76
89
  </table>
@@ -83,7 +96,22 @@
83
96
  </template>
84
97
 
85
98
  <script>
99
+ import { translate as t } from '@nextcloud/l10n'
100
+ import { evalFormula } from '../../utils/evalFormula.js'
86
101
  import { userLocale } from '../../utils/userLocale.js'
102
+
103
+ const ROUNDERS = Object.freeze({ round: Math.round, ceil: Math.ceil, floor: Math.floor })
104
+
105
+ /**
106
+ * The number a cell holds; an empty cell is no number, rather than zero.
107
+ *
108
+ * @param {unknown} raw The cell.
109
+ * @return {number|null} The number, or null.
110
+ */
111
+ function numberIn(raw) {
112
+ return raw === null || raw === undefined || raw === '' || !Number.isFinite(Number(raw)) ? null : Number(raw)
113
+ }
114
+
87
115
  /**
88
116
  * CnDataMatrix — Inline-edit data grid for matrix-shaped data
89
117
  * (rows × columns). Each cell is click-to-edit; commits emit
@@ -95,8 +123,19 @@ import { userLocale } from '../../utils/userLocale.js'
95
123
  * rubrics — the "spreadsheet" shape where cells are independently
96
124
  * editable values rather than a row/object form.
97
125
  *
98
- * Not a full spreadsheet engine — there's no formula language, no
99
- * cell-range references, no charts. Consumers wanting that should
126
+ * A column with `formula` computes its cells from the other columns and is
127
+ * read only: `now*(rate/100)`, with `prev_now` for the row above and `round`
128
+ * set to `round`, `ceil` or `floor`. A row where the formula has no answer shows
129
+ * its own stored value. Formulas are arithmetic only, through `evalFormula`.
130
+ *
131
+ * A scoring matrix weighs its columns: give each column a `weight` (and an
132
+ * optional `weightLabel` such as "40%"), set `rowTotalsMode="weighted"` and
133
+ * the row total is the weighted mean of the row's scores. `showRank` ranks
134
+ * the rows by that total, highest first, and `highlightTopRank` tints the
135
+ * leading row.
136
+ *
137
+ * Not a full spreadsheet engine — there are no cell-range references, no
138
+ * charts. Consumers wanting that should
100
139
  * embed a dedicated library (e.g. handsontable) and use this for
101
140
  * the simpler cases.
102
141
  *
@@ -128,7 +167,7 @@ export default {
128
167
  /**
129
168
  * Column declarations.
130
169
  *
131
- * @type {Array<{key:string,label?:string,type?:'number'|'string',readOnly?:boolean,formatter?:(value: unknown) => string,aggregate?:'sum'|'avg'|'count'|'none',width?:string}>}
170
+ * @type {Array<{key:string,label?:string,type?:'number'|'string',readOnly?:boolean,formula?:string,round?:'round'|'ceil'|'floor',formatter?:(value: unknown) => string,aggregate?:'sum'|'avg'|'count'|'none',width?:string,weight?:number,weightLabel?:string}>}
132
171
  */
133
172
  columns: { type: Array, default: () => [] },
134
173
  /** Field on each row carrying its id. */
@@ -153,6 +192,22 @@ export default {
153
192
  rowTotalsLabel: { type: String, default: 'Total' },
154
193
  /** Label preceding the column-totals row. */
155
194
  columnTotalsLabel: { type: String, default: 'Total' },
195
+ /**
196
+ * How a row total is computed: `sum` adds the number columns,
197
+ * `weighted` takes the mean of the number columns weighted by each
198
+ * column's `weight`, leaving out a cell without a value.
199
+ */
200
+ rowTotalsMode: { type: String, default: 'sum', validator: (v) => ['sum', 'weighted'].includes(v) },
201
+ /** Fraction digits of the totals; null keeps the locale default. */
202
+ totalsFractionDigits: { type: Number, default: null },
203
+ /** Render a rank column: the rows ranked by their row total, highest first, ties sharing a rank. */
204
+ showRank: { type: Boolean, default: false },
205
+ /** Header of the rank column, already translated; the library default is "Rank". */
206
+ rankLabel: { type: String, default: '' },
207
+ /** Tint the row ranked first. */
208
+ highlightTopRank: { type: Boolean, default: false },
209
+ /** Field on each row with a second line under its label, such as a price. */
210
+ rowSublabelKey: { type: String, default: '' },
156
211
  },
157
212
 
158
213
  emits: ['cell-edit'],
@@ -163,6 +218,69 @@ export default {
163
218
  },
164
219
 
165
220
  computed: {
221
+ /** @return {string} The rank column header. */
222
+ resolvedRankLabel() {
223
+ return this.rankLabel || t('nextcloud-vue', 'Rank')
224
+ },
225
+
226
+ /**
227
+ * The rank of every row with a row total: highest total first, rows
228
+ * with an equal total sharing a rank (1, 2, 2, 4).
229
+ *
230
+ * @return {Map<unknown, number>} Rank per row id.
231
+ */
232
+ ranks() {
233
+ const totals = this.rows
234
+ .map((row) => ({ id: row[this.rowIdKey], total: this.rowTotal(row) }))
235
+ .filter((entry) => Number.isFinite(entry.total))
236
+ .sort((a, b) => b.total - a.total)
237
+ const ranks = new Map()
238
+ totals.forEach((entry, index) => {
239
+ const previous = totals[index - 1]
240
+ ranks.set(entry.id, previous && previous.total === entry.total ? ranks.get(previous.id) : index + 1)
241
+ })
242
+ return ranks
243
+ },
244
+
245
+ /**
246
+ * The computed cells of every row, in order. A formula reads the row's
247
+ * numbers by column key and the previous row's as `prev_<key>`, and sees
248
+ * formula columns to its left. A formula without an answer has no entry
249
+ * here, so the cell shows what the row itself holds.
250
+ *
251
+ * @return {Map<object, Record<string, number>>} Computed values per row.
252
+ */
253
+ formulaValues() {
254
+ const values = new Map()
255
+ if (!this.columns.some((col) => col.formula)) {
256
+ return values
257
+ }
258
+ let previous = {}
259
+ for (const row of this.rows) {
260
+ const vars = { ...previous }
261
+ for (const col of this.columns) {
262
+ if (!col.formula && numberIn(row[col.key]) !== null) {
263
+ vars[col.key] = numberIn(row[col.key])
264
+ }
265
+ }
266
+ const computed = {}
267
+ for (const col of this.columns) {
268
+ if (col.formula) {
269
+ const answer = evalFormula(col.formula, vars)
270
+ if (answer !== null) {
271
+ computed[col.key] = (ROUNDERS[col.round] ?? Number)(answer)
272
+ vars[col.key] = computed[col.key]
273
+ } else if (numberIn(row[col.key]) !== null) {
274
+ vars[col.key] = numberIn(row[col.key])
275
+ }
276
+ }
277
+ }
278
+ values.set(row, computed)
279
+ previous = Object.fromEntries(Object.entries(vars).filter(([key]) => !key.startsWith('prev_')).map(([key, value]) => [`prev_${key}`, value]))
280
+ }
281
+ return values
282
+ },
283
+
166
284
  /**
167
285
  * Grand total (sum of every numeric cell). Shown in the
168
286
  * bottom-right corner when both totals are enabled.
@@ -174,7 +292,7 @@ export default {
174
292
  for (const row of this.rows) {
175
293
  for (const col of this.columns) {
176
294
  if (col.type === 'number') {
177
- const v = Number(row[col.key])
295
+ const v = Number(this.cellValue(row, col))
178
296
  if (Number.isFinite(v)) {
179
297
  total += v
180
298
  }
@@ -205,7 +323,7 @@ export default {
205
323
  * @return {boolean}
206
324
  */
207
325
  isCellReadOnly(row, col) {
208
- return Boolean(col.readOnly)
326
+ return Boolean(col.readOnly || col.formula)
209
327
  },
210
328
 
211
329
  /**
@@ -216,6 +334,9 @@ export default {
216
334
  * @return {unknown} The raw value.
217
335
  */
218
336
  cellValue(row, col) {
337
+ if (col.formula && this.formulaValues.get(row)?.[col.key] !== undefined) {
338
+ return this.formulaValues.get(row)[col.key]
339
+ }
219
340
  return row[col.key]
220
341
  },
221
342
 
@@ -321,16 +442,62 @@ export default {
321
442
  },
322
443
 
323
444
  /**
324
- * Per-row total — sum of every numeric column.
445
+ * The weight shown beside a column label: `weightLabel`, else the
446
+ * `weight` itself, or '' for an unweighted column.
447
+ *
448
+ * @param {object} col Column definition.
449
+ * @return {string} The weight text.
450
+ */
451
+ weightText(col) {
452
+ if (typeof col.weightLabel === 'string' && col.weightLabel !== '') {
453
+ return col.weightLabel
454
+ }
455
+ return Number.isFinite(col.weight) ? String(col.weight) : ''
456
+ },
457
+
458
+ /**
459
+ * Format a total with `totalsFractionDigits` when set.
460
+ *
461
+ * @param {number|null} value The total.
462
+ * @return {string} The display string.
463
+ */
464
+ formatTotal(value) {
465
+ if (!Number.isFinite(value)) {
466
+ return ''
467
+ }
468
+ if (this.totalsFractionDigits === null) {
469
+ return this.formatCell(value, { type: 'number' })
470
+ }
471
+ const digits = this.totalsFractionDigits
472
+ return value.toLocaleString(userLocale(), { minimumFractionDigits: digits, maximumFractionDigits: digits })
473
+ },
474
+
475
+ /**
476
+ * Per-row total: the sum of every numeric column, or in `weighted`
477
+ * mode the weighted mean over the weighted columns that hold a value
478
+ * (null when none does).
325
479
  *
326
480
  * @param {object} row Row record.
327
- * @return {number}
481
+ * @return {number|null}
328
482
  */
329
483
  rowTotal(row) {
484
+ if (this.rowTotalsMode === 'weighted') {
485
+ let weighted = 0
486
+ let weights = 0
487
+ for (const col of this.columns) {
488
+ const raw = this.cellValue(row, col)
489
+ const v = Number(raw)
490
+ if (col.type === 'number' && Number.isFinite(col.weight) && col.weight > 0 && raw !== null && raw !== undefined && raw !== '' && Number.isFinite(v)) {
491
+ weighted += v * col.weight
492
+ weights += col.weight
493
+ }
494
+ }
495
+ return weights > 0 ? weighted / weights : null
496
+ }
330
497
  let total = 0
331
498
  for (const col of this.columns) {
332
499
  if (col.type === 'number') {
333
- const v = Number(row[col.key])
500
+ const v = Number(this.cellValue(row, col))
334
501
  if (Number.isFinite(v)) {
335
502
  total += v
336
503
  }
@@ -358,7 +525,7 @@ export default {
358
525
  // `Number(null)` is `0`, which would otherwise be counted and
359
526
  // summed as a real zero value.
360
527
  const values = this.rows
361
- .map((r) => r[col.key])
528
+ .map((r) => this.cellValue(r, col))
362
529
  .filter((v) => v !== null && v !== undefined && v !== '')
363
530
  .map((v) => Number(v))
364
531
  .filter((v) => Number.isFinite(v))
@@ -482,6 +649,25 @@ export default {
482
649
  background: var(--color-primary-element-light);
483
650
  }
484
651
 
652
+ .cn-data-matrix__weight {
653
+ color: var(--color-text-maxcontrast);
654
+ font-weight: 400;
655
+ white-space: nowrap;
656
+ }
657
+
658
+ .cn-data-matrix__row-sublabel {
659
+ display: block;
660
+ color: var(--color-text-maxcontrast);
661
+ font-size: 0.85em;
662
+ font-weight: 400;
663
+ }
664
+
665
+ .cn-data-matrix__row--top > th,
666
+ .cn-data-matrix__row--top > td {
667
+ background: var(--color-primary-element-light);
668
+ color: var(--color-primary-element-light-text);
669
+ }
670
+
485
671
  .cn-data-matrix__empty {
486
672
  color: var(--color-text-maxcontrast);
487
673
  font-style: italic;
@@ -0,0 +1,308 @@
1
+ <!--
2
+ - SPDX-FileCopyrightText: 2026 Conduction B.V.
3
+ - SPDX-License-Identifier: EUPL-1.2
4
+ -->
5
+ <template>
6
+ <Teleport to="body" :disabled="!overlay">
7
+ <NcThemeProvider :dark="dark" :class="rootClasses" data-testid="cn-display-screen">
8
+ <component :is="overlay ? 'section' : 'main'"
9
+ ref="screen"
10
+ class="cn-display-screen__page"
11
+ :role="overlay ? 'dialog' : undefined"
12
+ :aria-modal="overlay ? 'true' : undefined"
13
+ :aria-label="overlay ? title : undefined"
14
+ :tabindex="overlay ? -1 : undefined"
15
+ @keydown.esc="onEscape">
16
+ <header class="cn-display-screen__header">
17
+ <div class="cn-display-screen__titles">
18
+ <span v-if="subtitle" class="cn-display-screen__muted" data-testid="cn-display-subtitle">{{ subtitle }}</span>
19
+ <h1 class="cn-display-screen__title">
20
+ {{ title }}
21
+ </h1>
22
+ </div>
23
+ <div v-if="clock || updatedText" class="cn-display-screen__time">
24
+ <span v-if="clock" class="cn-display-screen__clock" data-testid="cn-display-clock">{{ clockText }}</span>
25
+ <span v-if="updatedText" class="cn-display-screen__muted" data-testid="cn-display-updated">{{ updatedText }}</span>
26
+ </div>
27
+ </header>
28
+
29
+ <p v-if="stale"
30
+ class="cn-display-screen__stale"
31
+ role="status"
32
+ data-testid="cn-display-stale">
33
+ {{ staleMessage }}
34
+ </p>
35
+
36
+ <div class="cn-display-screen__body">
37
+ <!-- @slot default The rows of the screen. -->
38
+ <slot />
39
+ </div>
40
+
41
+ <footer v-if="footer || $slots.footer || $slots.actions" class="cn-display-screen__footer">
42
+ <!-- @slot footer The bottom line of the screen; replaces `footer`. -->
43
+ <slot name="footer">
44
+ <span class="cn-display-screen__muted" data-testid="cn-display-footer">{{ footer }}</span>
45
+ </slot>
46
+ <span v-if="$slots.actions" class="cn-display-screen__actions">
47
+ <!-- @slot actions Buttons at the end of the bottom line. -->
48
+ <slot name="actions" />
49
+ </span>
50
+ </footer>
51
+ </component>
52
+ </NcThemeProvider>
53
+ </Teleport>
54
+ </template>
55
+
56
+ <script>
57
+ import { translate as t } from '@nextcloud/l10n'
58
+ import { NcThemeProvider } from '@nextcloud/vue'
59
+ import { formatTimeOfDay } from '../../utils/boardDate.js'
60
+ import { parseDateValue } from '../../utils/dateVariant.js'
61
+
62
+ const TICK_MS = 1000
63
+
64
+ /**
65
+ * CnDisplayScreen: a full page without a menu, read from a distance on a hall
66
+ * screen or a classroom board (boards LqInfoscherm "Infoscherm bij de aula", LqLes
67
+ * "Zelf inchecken, op het bord").
68
+ *
69
+ * A title, a clock, when the content was last updated, the host's rows and a
70
+ * bottom line. The host owns the content and its refresh, and sets `stale` when a
71
+ * refresh failed. With `overlay` the screen covers the whole app: the rest of the
72
+ * page goes inert, Escape emits `close`, and focus returns on unmount.
73
+ *
74
+ * ```vue
75
+ * <CnDisplayScreen title="Today" clock dark footer="No names, no reasons." :updated-at="updatedAt" :stale="failed">
76
+ * <CnDataTable :rows="rows" />
77
+ * </CnDisplayScreen>
78
+ * ```
79
+ *
80
+ * @event close The user pressed Escape on an overlay.
81
+ * @spec openspec/changes/display-screen/specs/display-screen/spec.md
82
+ */
83
+ export default {
84
+ name: 'CnDisplayScreen',
85
+
86
+ components: { NcThemeProvider },
87
+
88
+ props: {
89
+ /** The heading, already translated. */
90
+ title: { type: String, required: true },
91
+ /** A line over the title, already translated. */
92
+ subtitle: { type: String, default: '' },
93
+ /** Show a clock that keeps time. */
94
+ clock: { type: Boolean, default: false },
95
+ /** When the content was last updated: an ISO string, a Date or a timestamp. */
96
+ updatedAt: { type: [String, Number, Date], default: '' },
97
+ /** The update line, already translated, with `{time}`. */
98
+ updatedTemplate: { type: String, default: '' },
99
+ /** The content could not be refreshed and shows what it last had. */
100
+ stale: { type: Boolean, default: false },
101
+ /** Says the content is old, already translated, with `{time}`. */
102
+ staleText: { type: String, default: '' },
103
+ /** The bottom line, already translated. */
104
+ footer: { type: String, default: '' },
105
+ /** Use the dark theme, whatever the user's theme is. */
106
+ dark: { type: Boolean, default: false },
107
+ /** Cover the whole app. */
108
+ overlay: { type: Boolean, default: false },
109
+ },
110
+
111
+ emits: ['close'],
112
+
113
+ data() {
114
+ return {
115
+ now: new Date(),
116
+ timer: null,
117
+ inerted: [],
118
+ returnFocusTo: null,
119
+ }
120
+ },
121
+
122
+ computed: {
123
+ /** @return {object} The classes of the outer element. */
124
+ rootClasses() {
125
+ return { 'cn-display-screen': true, 'cn-display-screen--overlay': this.overlay }
126
+ },
127
+
128
+ /** @return {string} The clock. */
129
+ clockText() {
130
+ return formatTimeOfDay(this.now)
131
+ },
132
+
133
+ /** @return {string} The time of the last update, or '' without one. */
134
+ updatedTime() {
135
+ const date = parseDateValue(this.updatedAt)
136
+ return date ? formatTimeOfDay(date) : ''
137
+ },
138
+
139
+ /** @return {string} The update line. */
140
+ updatedText() {
141
+ if (!this.updatedTime) {
142
+ return ''
143
+ }
144
+ if (this.updatedTemplate) {
145
+ return this.updatedTemplate.replace('{time}', this.updatedTime)
146
+ }
147
+ return t('nextcloud-vue', 'updated at {time}', { time: this.updatedTime })
148
+ },
149
+
150
+ /** @return {string} What the stale line says. */
151
+ staleMessage() {
152
+ if (this.staleText) {
153
+ return this.staleText.replace('{time}', this.updatedTime)
154
+ }
155
+ return this.updatedTime
156
+ ? t('nextcloud-vue', 'Cannot reach the server. This shows what it knew at {time}.', { time: this.updatedTime })
157
+ : t('nextcloud-vue', 'Cannot reach the server. This may be out of date.')
158
+ },
159
+ },
160
+
161
+ watch: {
162
+ clock() {
163
+ this.startClock()
164
+ },
165
+
166
+ overlay(on) {
167
+ if (on) {
168
+ this.$nextTick(this.enterOverlay)
169
+ } else {
170
+ this.leaveOverlay()
171
+ }
172
+ },
173
+ },
174
+
175
+ mounted() {
176
+ this.startClock()
177
+ if (this.overlay) {
178
+ this.enterOverlay()
179
+ }
180
+ },
181
+
182
+ beforeUnmount() {
183
+ clearInterval(this.timer)
184
+ this.leaveOverlay()
185
+ },
186
+
187
+ methods: {
188
+ /** Keep the clock on time while it shows. */
189
+ startClock() {
190
+ clearInterval(this.timer)
191
+ this.timer = null
192
+ if (this.clock) {
193
+ this.now = new Date()
194
+ this.timer = setInterval(() => {
195
+ this.now = new Date()
196
+ }, TICK_MS)
197
+ }
198
+ },
199
+
200
+ /** Make the rest of the page inert and take focus. */
201
+ enterOverlay() {
202
+ const root = this.$refs.screen?.closest('.cn-display-screen')
203
+ this.returnFocusTo = document.activeElement
204
+ this.inerted = [...document.body.children].filter((element) => element !== root && !element.inert)
205
+ this.inerted.forEach((element) => {
206
+ element.inert = true
207
+ })
208
+ this.$refs.screen?.focus()
209
+ },
210
+
211
+ /** Give the rest of the page and the focus back. */
212
+ leaveOverlay() {
213
+ this.inerted.forEach((element) => {
214
+ element.inert = false
215
+ })
216
+ this.inerted = []
217
+ this.returnFocusTo?.focus?.()
218
+ this.returnFocusTo = null
219
+ },
220
+
221
+ /** Ask the host to close an overlay. */
222
+ onEscape() {
223
+ if (this.overlay) {
224
+ this.$emit('close')
225
+ }
226
+ },
227
+ },
228
+ }
229
+ </script>
230
+
231
+ <style scoped>
232
+ .cn-display-screen {
233
+ background: var(--color-main-background);
234
+ color: var(--color-main-text);
235
+ }
236
+
237
+ .cn-display-screen--overlay {
238
+ inset: 0;
239
+ overflow: auto;
240
+ position: fixed;
241
+ z-index: 10000;
242
+ }
243
+
244
+ .cn-display-screen__page {
245
+ display: flex;
246
+ flex-direction: column;
247
+ font-size: 1.6rem;
248
+ gap: 16px;
249
+ min-height: 100vh;
250
+ outline: none;
251
+ padding: 24px 32px;
252
+ }
253
+
254
+ .cn-display-screen__header,
255
+ .cn-display-screen__footer {
256
+ align-items: flex-end;
257
+ display: flex;
258
+ flex-wrap: wrap;
259
+ gap: 8px 24px;
260
+ justify-content: space-between;
261
+ }
262
+
263
+ .cn-display-screen__titles,
264
+ .cn-display-screen__time {
265
+ display: flex;
266
+ flex-direction: column;
267
+ gap: 4px;
268
+ }
269
+
270
+ .cn-display-screen__time {
271
+ align-items: flex-end;
272
+ }
273
+
274
+ .cn-display-screen__title {
275
+ font-size: 1.6em;
276
+ font-weight: 700;
277
+ margin: 0;
278
+ }
279
+
280
+ .cn-display-screen__clock {
281
+ font-size: 2.2em;
282
+ font-variant-numeric: tabular-nums;
283
+ font-weight: 700;
284
+ line-height: 1;
285
+ }
286
+
287
+ .cn-display-screen__muted {
288
+ color: var(--color-text-maxcontrast);
289
+ }
290
+
291
+ .cn-display-screen__stale {
292
+ background: var(--color-background-hover);
293
+ border-inline-start: 6px solid var(--color-warning);
294
+ margin: 0;
295
+ padding: 8px 12px;
296
+ }
297
+
298
+ .cn-display-screen__body {
299
+ flex: 1 1 auto;
300
+ min-height: 0;
301
+ }
302
+
303
+ .cn-display-screen__actions {
304
+ display: flex;
305
+ flex-wrap: wrap;
306
+ gap: 8px;
307
+ }
308
+ </style>
@@ -0,0 +1,9 @@
1
+ /**
2
+ * SPDX-FileCopyrightText: 2026 Conduction B.V.
3
+ * SPDX-License-Identifier: EUPL-1.2
4
+ */
5
+
6
+ import CnDisplayScreen from './CnDisplayScreen.vue'
7
+
8
+ export { CnDisplayScreen }
9
+ export default CnDisplayScreen