@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,9 @@
1
+ import script from './CnDisplayScreen.vue2.js';
2
+ import { render } from './CnDisplayScreen.vue3.js';
3
+
4
+ script.render = render;
5
+ script.__scopeId = "data-v-02d5bc1a";
6
+ const __sfc_main = script;
7
+
8
+ export { __sfc_main as default };
9
+ //# sourceMappingURL=CnDisplayScreen.vue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CnDisplayScreen.vue.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
@@ -0,0 +1,175 @@
1
+ import { translate } from '@nextcloud/l10n';
2
+ import { NcThemeProvider } from '@nextcloud/vue';
3
+ import { formatTimeOfDay } from '../../utils/boardDate.js';
4
+ import { parseDateValue } from '../../utils/dateVariant.js';
5
+
6
+ const TICK_MS = 1000;
7
+
8
+ /**
9
+ * CnDisplayScreen: a full page without a menu, read from a distance on a hall
10
+ * screen or a classroom board (boards LqInfoscherm "Infoscherm bij de aula", LqLes
11
+ * "Zelf inchecken, op het bord").
12
+ *
13
+ * A title, a clock, when the content was last updated, the host's rows and a
14
+ * bottom line. The host owns the content and its refresh, and sets `stale` when a
15
+ * refresh failed. With `overlay` the screen covers the whole app: the rest of the
16
+ * page goes inert, Escape emits `close`, and focus returns on unmount.
17
+ *
18
+ * ```vue
19
+ * <CnDisplayScreen title="Today" clock dark footer="No names, no reasons." :updated-at="updatedAt" :stale="failed">
20
+ * <CnDataTable :rows="rows" />
21
+ * </CnDisplayScreen>
22
+ * ```
23
+ *
24
+ * @event close The user pressed Escape on an overlay.
25
+ * @spec openspec/changes/display-screen/specs/display-screen/spec.md
26
+ */
27
+ var script = {
28
+ name: 'CnDisplayScreen',
29
+
30
+ components: { NcThemeProvider },
31
+
32
+ props: {
33
+ /** The heading, already translated. */
34
+ title: { type: String, required: true },
35
+ /** A line over the title, already translated. */
36
+ subtitle: { type: String, default: '' },
37
+ /** Show a clock that keeps time. */
38
+ clock: { type: Boolean, default: false },
39
+ /** When the content was last updated: an ISO string, a Date or a timestamp. */
40
+ updatedAt: { type: [String, Number, Date], default: '' },
41
+ /** The update line, already translated, with `{time}`. */
42
+ updatedTemplate: { type: String, default: '' },
43
+ /** The content could not be refreshed and shows what it last had. */
44
+ stale: { type: Boolean, default: false },
45
+ /** Says the content is old, already translated, with `{time}`. */
46
+ staleText: { type: String, default: '' },
47
+ /** The bottom line, already translated. */
48
+ footer: { type: String, default: '' },
49
+ /** Use the dark theme, whatever the user's theme is. */
50
+ dark: { type: Boolean, default: false },
51
+ /** Cover the whole app. */
52
+ overlay: { type: Boolean, default: false },
53
+ },
54
+
55
+ emits: ['close'],
56
+
57
+ data() {
58
+ return {
59
+ now: new Date(),
60
+ timer: null,
61
+ inerted: [],
62
+ returnFocusTo: null,
63
+ }
64
+ },
65
+
66
+ computed: {
67
+ /** @return {object} The classes of the outer element. */
68
+ rootClasses() {
69
+ return { 'cn-display-screen': true, 'cn-display-screen--overlay': this.overlay }
70
+ },
71
+
72
+ /** @return {string} The clock. */
73
+ clockText() {
74
+ return formatTimeOfDay(this.now)
75
+ },
76
+
77
+ /** @return {string} The time of the last update, or '' without one. */
78
+ updatedTime() {
79
+ const date = parseDateValue(this.updatedAt);
80
+ return date ? formatTimeOfDay(date) : ''
81
+ },
82
+
83
+ /** @return {string} The update line. */
84
+ updatedText() {
85
+ if (!this.updatedTime) {
86
+ return ''
87
+ }
88
+ if (this.updatedTemplate) {
89
+ return this.updatedTemplate.replace('{time}', this.updatedTime)
90
+ }
91
+ return translate('nextcloud-vue', 'updated at {time}', { time: this.updatedTime })
92
+ },
93
+
94
+ /** @return {string} What the stale line says. */
95
+ staleMessage() {
96
+ if (this.staleText) {
97
+ return this.staleText.replace('{time}', this.updatedTime)
98
+ }
99
+ return this.updatedTime
100
+ ? translate('nextcloud-vue', 'Cannot reach the server. This shows what it knew at {time}.', { time: this.updatedTime })
101
+ : translate('nextcloud-vue', 'Cannot reach the server. This may be out of date.')
102
+ },
103
+ },
104
+
105
+ watch: {
106
+ clock() {
107
+ this.startClock();
108
+ },
109
+
110
+ overlay(on) {
111
+ if (on) {
112
+ this.$nextTick(this.enterOverlay);
113
+ } else {
114
+ this.leaveOverlay();
115
+ }
116
+ },
117
+ },
118
+
119
+ mounted() {
120
+ this.startClock();
121
+ if (this.overlay) {
122
+ this.enterOverlay();
123
+ }
124
+ },
125
+
126
+ beforeUnmount() {
127
+ clearInterval(this.timer);
128
+ this.leaveOverlay();
129
+ },
130
+
131
+ methods: {
132
+ /** Keep the clock on time while it shows. */
133
+ startClock() {
134
+ clearInterval(this.timer);
135
+ this.timer = null;
136
+ if (this.clock) {
137
+ this.now = new Date();
138
+ this.timer = setInterval(() => {
139
+ this.now = new Date();
140
+ }, TICK_MS);
141
+ }
142
+ },
143
+
144
+ /** Make the rest of the page inert and take focus. */
145
+ enterOverlay() {
146
+ const root = this.$refs.screen?.closest('.cn-display-screen');
147
+ this.returnFocusTo = document.activeElement;
148
+ this.inerted = [...document.body.children].filter((element) => element !== root && !element.inert);
149
+ this.inerted.forEach((element) => {
150
+ element.inert = true;
151
+ });
152
+ this.$refs.screen?.focus();
153
+ },
154
+
155
+ /** Give the rest of the page and the focus back. */
156
+ leaveOverlay() {
157
+ this.inerted.forEach((element) => {
158
+ element.inert = false;
159
+ });
160
+ this.inerted = [];
161
+ this.returnFocusTo?.focus?.();
162
+ this.returnFocusTo = null;
163
+ },
164
+
165
+ /** Ask the host to close an overlay. */
166
+ onEscape() {
167
+ if (this.overlay) {
168
+ this.$emit('close');
169
+ }
170
+ },
171
+ },
172
+ };
173
+
174
+ export { script as default };
175
+ //# sourceMappingURL=CnDisplayScreen.vue2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CnDisplayScreen.vue2.js","sources":["../../../../src/components/CnDisplayScreen/CnDisplayScreen.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<Teleport to=\"body\" :disabled=\"!overlay\">\n\t\t<NcThemeProvider :dark=\"dark\" :class=\"rootClasses\" data-testid=\"cn-display-screen\">\n\t\t\t<component :is=\"overlay ? 'section' : 'main'\"\n\t\t\t\tref=\"screen\"\n\t\t\t\tclass=\"cn-display-screen__page\"\n\t\t\t\t:role=\"overlay ? 'dialog' : undefined\"\n\t\t\t\t:aria-modal=\"overlay ? 'true' : undefined\"\n\t\t\t\t:aria-label=\"overlay ? title : undefined\"\n\t\t\t\t:tabindex=\"overlay ? -1 : undefined\"\n\t\t\t\t@keydown.esc=\"onEscape\">\n\t\t\t\t<header class=\"cn-display-screen__header\">\n\t\t\t\t\t<div class=\"cn-display-screen__titles\">\n\t\t\t\t\t\t<span v-if=\"subtitle\" class=\"cn-display-screen__muted\" data-testid=\"cn-display-subtitle\">{{ subtitle }}</span>\n\t\t\t\t\t\t<h1 class=\"cn-display-screen__title\">\n\t\t\t\t\t\t\t{{ title }}\n\t\t\t\t\t\t</h1>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div v-if=\"clock || updatedText\" class=\"cn-display-screen__time\">\n\t\t\t\t\t\t<span v-if=\"clock\" class=\"cn-display-screen__clock\" data-testid=\"cn-display-clock\">{{ clockText }}</span>\n\t\t\t\t\t\t<span v-if=\"updatedText\" class=\"cn-display-screen__muted\" data-testid=\"cn-display-updated\">{{ updatedText }}</span>\n\t\t\t\t\t</div>\n\t\t\t\t</header>\n\n\t\t\t\t<p v-if=\"stale\"\n\t\t\t\t\tclass=\"cn-display-screen__stale\"\n\t\t\t\t\trole=\"status\"\n\t\t\t\t\tdata-testid=\"cn-display-stale\">\n\t\t\t\t\t{{ staleMessage }}\n\t\t\t\t</p>\n\n\t\t\t\t<div class=\"cn-display-screen__body\">\n\t\t\t\t\t<!-- @slot default The rows of the screen. -->\n\t\t\t\t\t<slot />\n\t\t\t\t</div>\n\n\t\t\t\t<footer v-if=\"footer || $slots.footer || $slots.actions\" class=\"cn-display-screen__footer\">\n\t\t\t\t\t<!-- @slot footer The bottom line of the screen; replaces `footer`. -->\n\t\t\t\t\t<slot name=\"footer\">\n\t\t\t\t\t\t<span class=\"cn-display-screen__muted\" data-testid=\"cn-display-footer\">{{ footer }}</span>\n\t\t\t\t\t</slot>\n\t\t\t\t\t<span v-if=\"$slots.actions\" class=\"cn-display-screen__actions\">\n\t\t\t\t\t\t<!-- @slot actions Buttons at the end of the bottom line. -->\n\t\t\t\t\t\t<slot name=\"actions\" />\n\t\t\t\t\t</span>\n\t\t\t\t</footer>\n\t\t\t</component>\n\t\t</NcThemeProvider>\n\t</Teleport>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcThemeProvider } from '@nextcloud/vue'\nimport { formatTimeOfDay } from '../../utils/boardDate.js'\nimport { parseDateValue } from '../../utils/dateVariant.js'\n\nconst TICK_MS = 1000\n\n/**\n * CnDisplayScreen: a full page without a menu, read from a distance on a hall\n * screen or a classroom board (boards LqInfoscherm \"Infoscherm bij de aula\", LqLes\n * \"Zelf inchecken, op het bord\").\n *\n * A title, a clock, when the content was last updated, the host's rows and a\n * bottom line. The host owns the content and its refresh, and sets `stale` when a\n * refresh failed. With `overlay` the screen covers the whole app: the rest of the\n * page goes inert, Escape emits `close`, and focus returns on unmount.\n *\n * ```vue\n * <CnDisplayScreen title=\"Today\" clock dark footer=\"No names, no reasons.\" :updated-at=\"updatedAt\" :stale=\"failed\">\n * <CnDataTable :rows=\"rows\" />\n * </CnDisplayScreen>\n * ```\n *\n * @event close The user pressed Escape on an overlay.\n * @spec openspec/changes/display-screen/specs/display-screen/spec.md\n */\nexport default {\n\tname: 'CnDisplayScreen',\n\n\tcomponents: { NcThemeProvider },\n\n\tprops: {\n\t\t/** The heading, already translated. */\n\t\ttitle: { type: String, required: true },\n\t\t/** A line over the title, already translated. */\n\t\tsubtitle: { type: String, default: '' },\n\t\t/** Show a clock that keeps time. */\n\t\tclock: { type: Boolean, default: false },\n\t\t/** When the content was last updated: an ISO string, a Date or a timestamp. */\n\t\tupdatedAt: { type: [String, Number, Date], default: '' },\n\t\t/** The update line, already translated, with `{time}`. */\n\t\tupdatedTemplate: { type: String, default: '' },\n\t\t/** The content could not be refreshed and shows what it last had. */\n\t\tstale: { type: Boolean, default: false },\n\t\t/** Says the content is old, already translated, with `{time}`. */\n\t\tstaleText: { type: String, default: '' },\n\t\t/** The bottom line, already translated. */\n\t\tfooter: { type: String, default: '' },\n\t\t/** Use the dark theme, whatever the user's theme is. */\n\t\tdark: { type: Boolean, default: false },\n\t\t/** Cover the whole app. */\n\t\toverlay: { type: Boolean, default: false },\n\t},\n\n\temits: ['close'],\n\n\tdata() {\n\t\treturn {\n\t\t\tnow: new Date(),\n\t\t\ttimer: null,\n\t\t\tinerted: [],\n\t\t\treturnFocusTo: null,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** @return {object} The classes of the outer element. */\n\t\trootClasses() {\n\t\t\treturn { 'cn-display-screen': true, 'cn-display-screen--overlay': this.overlay }\n\t\t},\n\n\t\t/** @return {string} The clock. */\n\t\tclockText() {\n\t\t\treturn formatTimeOfDay(this.now)\n\t\t},\n\n\t\t/** @return {string} The time of the last update, or '' without one. */\n\t\tupdatedTime() {\n\t\t\tconst date = parseDateValue(this.updatedAt)\n\t\t\treturn date ? formatTimeOfDay(date) : ''\n\t\t},\n\n\t\t/** @return {string} The update line. */\n\t\tupdatedText() {\n\t\t\tif (!this.updatedTime) {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tif (this.updatedTemplate) {\n\t\t\t\treturn this.updatedTemplate.replace('{time}', this.updatedTime)\n\t\t\t}\n\t\t\treturn t('nextcloud-vue', 'updated at {time}', { time: this.updatedTime })\n\t\t},\n\n\t\t/** @return {string} What the stale line says. */\n\t\tstaleMessage() {\n\t\t\tif (this.staleText) {\n\t\t\t\treturn this.staleText.replace('{time}', this.updatedTime)\n\t\t\t}\n\t\t\treturn this.updatedTime\n\t\t\t\t? t('nextcloud-vue', 'Cannot reach the server. This shows what it knew at {time}.', { time: this.updatedTime })\n\t\t\t\t: t('nextcloud-vue', 'Cannot reach the server. This may be out of date.')\n\t\t},\n\t},\n\n\twatch: {\n\t\tclock() {\n\t\t\tthis.startClock()\n\t\t},\n\n\t\toverlay(on) {\n\t\t\tif (on) {\n\t\t\t\tthis.$nextTick(this.enterOverlay)\n\t\t\t} else {\n\t\t\t\tthis.leaveOverlay()\n\t\t\t}\n\t\t},\n\t},\n\n\tmounted() {\n\t\tthis.startClock()\n\t\tif (this.overlay) {\n\t\t\tthis.enterOverlay()\n\t\t}\n\t},\n\n\tbeforeUnmount() {\n\t\tclearInterval(this.timer)\n\t\tthis.leaveOverlay()\n\t},\n\n\tmethods: {\n\t\t/** Keep the clock on time while it shows. */\n\t\tstartClock() {\n\t\t\tclearInterval(this.timer)\n\t\t\tthis.timer = null\n\t\t\tif (this.clock) {\n\t\t\t\tthis.now = new Date()\n\t\t\t\tthis.timer = setInterval(() => {\n\t\t\t\t\tthis.now = new Date()\n\t\t\t\t}, TICK_MS)\n\t\t\t}\n\t\t},\n\n\t\t/** Make the rest of the page inert and take focus. */\n\t\tenterOverlay() {\n\t\t\tconst root = this.$refs.screen?.closest('.cn-display-screen')\n\t\t\tthis.returnFocusTo = document.activeElement\n\t\t\tthis.inerted = [...document.body.children].filter((element) => element !== root && !element.inert)\n\t\t\tthis.inerted.forEach((element) => {\n\t\t\t\telement.inert = true\n\t\t\t})\n\t\t\tthis.$refs.screen?.focus()\n\t\t},\n\n\t\t/** Give the rest of the page and the focus back. */\n\t\tleaveOverlay() {\n\t\t\tthis.inerted.forEach((element) => {\n\t\t\t\telement.inert = false\n\t\t\t})\n\t\t\tthis.inerted = []\n\t\t\tthis.returnFocusTo?.focus?.()\n\t\t\tthis.returnFocusTo = null\n\t\t},\n\n\t\t/** Ask the host to close an overlay. */\n\t\tonEscape() {\n\t\t\tif (this.overlay) {\n\t\t\t\tthis.$emit('close')\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-display-screen {\n\tbackground: var(--color-main-background);\n\tcolor: var(--color-main-text);\n}\n\n.cn-display-screen--overlay {\n\tinset: 0;\n\toverflow: auto;\n\tposition: fixed;\n\tz-index: 10000;\n}\n\n.cn-display-screen__page {\n\tdisplay: flex;\n\tflex-direction: column;\n\tfont-size: 1.6rem;\n\tgap: 16px;\n\tmin-height: 100vh;\n\toutline: none;\n\tpadding: 24px 32px;\n}\n\n.cn-display-screen__header,\n.cn-display-screen__footer {\n\talign-items: flex-end;\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 8px 24px;\n\tjustify-content: space-between;\n}\n\n.cn-display-screen__titles,\n.cn-display-screen__time {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n}\n\n.cn-display-screen__time {\n\talign-items: flex-end;\n}\n\n.cn-display-screen__title {\n\tfont-size: 1.6em;\n\tfont-weight: 700;\n\tmargin: 0;\n}\n\n.cn-display-screen__clock {\n\tfont-size: 2.2em;\n\tfont-variant-numeric: tabular-nums;\n\tfont-weight: 700;\n\tline-height: 1;\n}\n\n.cn-display-screen__muted {\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-display-screen__stale {\n\tbackground: var(--color-background-hover);\n\tborder-inline-start: 6px solid var(--color-warning);\n\tmargin: 0;\n\tpadding: 8px 12px;\n}\n\n.cn-display-screen__body {\n\tflex: 1 1 auto;\n\tmin-height: 0;\n}\n\n.cn-display-screen__actions {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 8px;\n}\n</style>\n"],"names":["t"],"mappings":";;;;;AA6DA,MAAM,OAAM,GAAI,KAAG;;AAEnB;AACC;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAED,aAAe;CACd,IAAI,EAAE,iBAAiB;;CAEvB,UAAU,EAAE,EAAE,eAAc,EAAG;;AAE/B,CAAA,KAAK,EAAE;AACN;AACA,EAAA,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;AACvC;AACA,EAAA,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI;;AAEvC,EAAA,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO;AACxC;EACA,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,EAAC,EAAG;;AAExD,EAAA,eAAe,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI;;AAE9C,EAAA,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO;;AAExC,EAAA,SAAS,EAAE,EAAE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AAA;GACA;;AAED;AACA,EAAA,YAAY,GAAG;GACd,MAAM,IAAG,GAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,EAAA;AAC5D,GAAA,IAAI,CAAC,gBAAgB,QAAQ,CAAC,cAAY;AAC1C,GAAA,IAAI,CAAC,OAAM,GAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,KAAK,OAAQ,KAAI,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAA;AACjG,GAAA,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,KAAK;AACjC,IAAA,OAAO,CAAC,KAAI,GAAI,KAAG;IACnB,EAAA;GACD,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,GAAC;GACzB;;AAED;AACA,EAAA,YAAY,GAAG;AACd,GAAA,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,KAAK;AACjC,IAAA,OAAO,CAAC,KAAM,GAAE,MAAI;IACpB,EAAA;AACD,GAAA,IAAI,CAAC,OAAQ,GAAE,GAAC;GAChB,IAAI,CAAC,aAAa,EAAE,KAAK,KAAG;GAC5B,IAAI,CAAC,gBAAgB,KAAG;GACxB;;AAED;EACA,QAAQ,GAAG;AACV,GAAA,IAAI,IAAI,CAAC,OAAO,EAAE;AACjB,IAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAA;AACnB,IAAA;GACA;EACD;AACF;;;;"}
@@ -0,0 +1,114 @@
1
+ import { resolveComponent, openBlock, createBlock, Teleport, createVNode, normalizeClass, withCtx, resolveDynamicComponent, withKeys, createElementVNode, createElementBlock, toDisplayString, createCommentVNode, renderSlot } from 'vue';
2
+
3
+ const _hoisted_1 = { class: "cn-display-screen__header" };
4
+ const _hoisted_2 = { class: "cn-display-screen__titles" };
5
+ const _hoisted_3 = {
6
+ key: 0,
7
+ class: "cn-display-screen__muted",
8
+ "data-testid": "cn-display-subtitle"
9
+ };
10
+ const _hoisted_4 = { class: "cn-display-screen__title" };
11
+ const _hoisted_5 = {
12
+ key: 0,
13
+ class: "cn-display-screen__time"
14
+ };
15
+ const _hoisted_6 = {
16
+ key: 0,
17
+ class: "cn-display-screen__clock",
18
+ "data-testid": "cn-display-clock"
19
+ };
20
+ const _hoisted_7 = {
21
+ key: 1,
22
+ class: "cn-display-screen__muted",
23
+ "data-testid": "cn-display-updated"
24
+ };
25
+ const _hoisted_8 = {
26
+ key: 0,
27
+ class: "cn-display-screen__stale",
28
+ role: "status",
29
+ "data-testid": "cn-display-stale"
30
+ };
31
+ const _hoisted_9 = { class: "cn-display-screen__body" };
32
+ const _hoisted_10 = {
33
+ key: 1,
34
+ class: "cn-display-screen__footer"
35
+ };
36
+ const _hoisted_11 = {
37
+ class: "cn-display-screen__muted",
38
+ "data-testid": "cn-display-footer"
39
+ };
40
+ const _hoisted_12 = {
41
+ key: 0,
42
+ class: "cn-display-screen__actions"
43
+ };
44
+
45
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
46
+ const _component_NcThemeProvider = resolveComponent("NcThemeProvider");
47
+
48
+ return (openBlock(), createBlock(Teleport, {
49
+ to: "body",
50
+ disabled: !$props.overlay
51
+ }, [
52
+ createVNode(_component_NcThemeProvider, {
53
+ dark: $props.dark,
54
+ class: normalizeClass($options.rootClasses),
55
+ "data-testid": "cn-display-screen"
56
+ }, {
57
+ default: withCtx(() => [
58
+ (openBlock(), createBlock(resolveDynamicComponent($props.overlay ? 'section' : 'main'), {
59
+ ref: "screen",
60
+ class: "cn-display-screen__page",
61
+ role: $props.overlay ? 'dialog' : undefined,
62
+ "aria-modal": $props.overlay ? 'true' : undefined,
63
+ "aria-label": $props.overlay ? $props.title : undefined,
64
+ tabindex: $props.overlay ? -1 : undefined,
65
+ onKeydown: withKeys($options.onEscape, ["esc"])
66
+ }, {
67
+ default: withCtx(() => [
68
+ createElementVNode("header", _hoisted_1, [
69
+ createElementVNode("div", _hoisted_2, [
70
+ ($props.subtitle)
71
+ ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString($props.subtitle), 1 /* TEXT */))
72
+ : createCommentVNode("v-if", true),
73
+ createElementVNode("h1", _hoisted_4, toDisplayString($props.title), 1 /* TEXT */)
74
+ ]),
75
+ ($props.clock || $options.updatedText)
76
+ ? (openBlock(), createElementBlock("div", _hoisted_5, [
77
+ ($props.clock)
78
+ ? (openBlock(), createElementBlock("span", _hoisted_6, toDisplayString($options.clockText), 1 /* TEXT */))
79
+ : createCommentVNode("v-if", true),
80
+ ($options.updatedText)
81
+ ? (openBlock(), createElementBlock("span", _hoisted_7, toDisplayString($options.updatedText), 1 /* TEXT */))
82
+ : createCommentVNode("v-if", true)
83
+ ]))
84
+ : createCommentVNode("v-if", true)
85
+ ]),
86
+ ($props.stale)
87
+ ? (openBlock(), createElementBlock("p", _hoisted_8, toDisplayString($options.staleMessage), 1 /* TEXT */))
88
+ : createCommentVNode("v-if", true),
89
+ createElementVNode("div", _hoisted_9, [
90
+ renderSlot(_ctx.$slots, "default")
91
+ ]),
92
+ ($props.footer || _ctx.$slots.footer || _ctx.$slots.actions)
93
+ ? (openBlock(), createElementBlock("footer", _hoisted_10, [
94
+ renderSlot(_ctx.$slots, "footer", {}, () => [
95
+ createElementVNode("span", _hoisted_11, toDisplayString($props.footer), 1 /* TEXT */)
96
+ ]),
97
+ (_ctx.$slots.actions)
98
+ ? (openBlock(), createElementBlock("span", _hoisted_12, [
99
+ renderSlot(_ctx.$slots, "actions")
100
+ ]))
101
+ : createCommentVNode("v-if", true)
102
+ ]))
103
+ : createCommentVNode("v-if", true)
104
+ ]),
105
+ _: 3 /* FORWARDED */
106
+ }, 40 /* PROPS, NEED_HYDRATION */, ["role", "aria-modal", "aria-label", "tabindex", "onKeydown"]))
107
+ ]),
108
+ _: 3 /* FORWARDED */
109
+ }, 8 /* PROPS */, ["dark", "class"])
110
+ ], 8 /* PROPS */, ["disabled"]))
111
+ }
112
+
113
+ export { render };
114
+ //# sourceMappingURL=CnDisplayScreen.vue3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CnDisplayScreen.vue3.js","sources":["../../../../src/components/CnDisplayScreen/CnDisplayScreen.vue?vue&type=template&id=02d5bc1a&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<Teleport to=\"body\" :disabled=\"!overlay\">\n\t\t<NcThemeProvider :dark=\"dark\" :class=\"rootClasses\" data-testid=\"cn-display-screen\">\n\t\t\t<component :is=\"overlay ? 'section' : 'main'\"\n\t\t\t\tref=\"screen\"\n\t\t\t\tclass=\"cn-display-screen__page\"\n\t\t\t\t:role=\"overlay ? 'dialog' : undefined\"\n\t\t\t\t:aria-modal=\"overlay ? 'true' : undefined\"\n\t\t\t\t:aria-label=\"overlay ? title : undefined\"\n\t\t\t\t:tabindex=\"overlay ? -1 : undefined\"\n\t\t\t\t@keydown.esc=\"onEscape\">\n\t\t\t\t<header class=\"cn-display-screen__header\">\n\t\t\t\t\t<div class=\"cn-display-screen__titles\">\n\t\t\t\t\t\t<span v-if=\"subtitle\" class=\"cn-display-screen__muted\" data-testid=\"cn-display-subtitle\">{{ subtitle }}</span>\n\t\t\t\t\t\t<h1 class=\"cn-display-screen__title\">\n\t\t\t\t\t\t\t{{ title }}\n\t\t\t\t\t\t</h1>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div v-if=\"clock || updatedText\" class=\"cn-display-screen__time\">\n\t\t\t\t\t\t<span v-if=\"clock\" class=\"cn-display-screen__clock\" data-testid=\"cn-display-clock\">{{ clockText }}</span>\n\t\t\t\t\t\t<span v-if=\"updatedText\" class=\"cn-display-screen__muted\" data-testid=\"cn-display-updated\">{{ updatedText }}</span>\n\t\t\t\t\t</div>\n\t\t\t\t</header>\n\n\t\t\t\t<p v-if=\"stale\"\n\t\t\t\t\tclass=\"cn-display-screen__stale\"\n\t\t\t\t\trole=\"status\"\n\t\t\t\t\tdata-testid=\"cn-display-stale\">\n\t\t\t\t\t{{ staleMessage }}\n\t\t\t\t</p>\n\n\t\t\t\t<div class=\"cn-display-screen__body\">\n\t\t\t\t\t<!-- @slot default The rows of the screen. -->\n\t\t\t\t\t<slot />\n\t\t\t\t</div>\n\n\t\t\t\t<footer v-if=\"footer || $slots.footer || $slots.actions\" class=\"cn-display-screen__footer\">\n\t\t\t\t\t<!-- @slot footer The bottom line of the screen; replaces `footer`. -->\n\t\t\t\t\t<slot name=\"footer\">\n\t\t\t\t\t\t<span class=\"cn-display-screen__muted\" data-testid=\"cn-display-footer\">{{ footer }}</span>\n\t\t\t\t\t</slot>\n\t\t\t\t\t<span v-if=\"$slots.actions\" class=\"cn-display-screen__actions\">\n\t\t\t\t\t\t<!-- @slot actions Buttons at the end of the bottom line. -->\n\t\t\t\t\t\t<slot name=\"actions\" />\n\t\t\t\t\t</span>\n\t\t\t\t</footer>\n\t\t\t</component>\n\t\t</NcThemeProvider>\n\t</Teleport>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcThemeProvider } from '@nextcloud/vue'\nimport { formatTimeOfDay } from '../../utils/boardDate.js'\nimport { parseDateValue } from '../../utils/dateVariant.js'\n\nconst TICK_MS = 1000\n\n/**\n * CnDisplayScreen: a full page without a menu, read from a distance on a hall\n * screen or a classroom board (boards LqInfoscherm \"Infoscherm bij de aula\", LqLes\n * \"Zelf inchecken, op het bord\").\n *\n * A title, a clock, when the content was last updated, the host's rows and a\n * bottom line. The host owns the content and its refresh, and sets `stale` when a\n * refresh failed. With `overlay` the screen covers the whole app: the rest of the\n * page goes inert, Escape emits `close`, and focus returns on unmount.\n *\n * ```vue\n * <CnDisplayScreen title=\"Today\" clock dark footer=\"No names, no reasons.\" :updated-at=\"updatedAt\" :stale=\"failed\">\n * <CnDataTable :rows=\"rows\" />\n * </CnDisplayScreen>\n * ```\n *\n * @event close The user pressed Escape on an overlay.\n * @spec openspec/changes/display-screen/specs/display-screen/spec.md\n */\nexport default {\n\tname: 'CnDisplayScreen',\n\n\tcomponents: { NcThemeProvider },\n\n\tprops: {\n\t\t/** The heading, already translated. */\n\t\ttitle: { type: String, required: true },\n\t\t/** A line over the title, already translated. */\n\t\tsubtitle: { type: String, default: '' },\n\t\t/** Show a clock that keeps time. */\n\t\tclock: { type: Boolean, default: false },\n\t\t/** When the content was last updated: an ISO string, a Date or a timestamp. */\n\t\tupdatedAt: { type: [String, Number, Date], default: '' },\n\t\t/** The update line, already translated, with `{time}`. */\n\t\tupdatedTemplate: { type: String, default: '' },\n\t\t/** The content could not be refreshed and shows what it last had. */\n\t\tstale: { type: Boolean, default: false },\n\t\t/** Says the content is old, already translated, with `{time}`. */\n\t\tstaleText: { type: String, default: '' },\n\t\t/** The bottom line, already translated. */\n\t\tfooter: { type: String, default: '' },\n\t\t/** Use the dark theme, whatever the user's theme is. */\n\t\tdark: { type: Boolean, default: false },\n\t\t/** Cover the whole app. */\n\t\toverlay: { type: Boolean, default: false },\n\t},\n\n\temits: ['close'],\n\n\tdata() {\n\t\treturn {\n\t\t\tnow: new Date(),\n\t\t\ttimer: null,\n\t\t\tinerted: [],\n\t\t\treturnFocusTo: null,\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** @return {object} The classes of the outer element. */\n\t\trootClasses() {\n\t\t\treturn { 'cn-display-screen': true, 'cn-display-screen--overlay': this.overlay }\n\t\t},\n\n\t\t/** @return {string} The clock. */\n\t\tclockText() {\n\t\t\treturn formatTimeOfDay(this.now)\n\t\t},\n\n\t\t/** @return {string} The time of the last update, or '' without one. */\n\t\tupdatedTime() {\n\t\t\tconst date = parseDateValue(this.updatedAt)\n\t\t\treturn date ? formatTimeOfDay(date) : ''\n\t\t},\n\n\t\t/** @return {string} The update line. */\n\t\tupdatedText() {\n\t\t\tif (!this.updatedTime) {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tif (this.updatedTemplate) {\n\t\t\t\treturn this.updatedTemplate.replace('{time}', this.updatedTime)\n\t\t\t}\n\t\t\treturn t('nextcloud-vue', 'updated at {time}', { time: this.updatedTime })\n\t\t},\n\n\t\t/** @return {string} What the stale line says. */\n\t\tstaleMessage() {\n\t\t\tif (this.staleText) {\n\t\t\t\treturn this.staleText.replace('{time}', this.updatedTime)\n\t\t\t}\n\t\t\treturn this.updatedTime\n\t\t\t\t? t('nextcloud-vue', 'Cannot reach the server. This shows what it knew at {time}.', { time: this.updatedTime })\n\t\t\t\t: t('nextcloud-vue', 'Cannot reach the server. This may be out of date.')\n\t\t},\n\t},\n\n\twatch: {\n\t\tclock() {\n\t\t\tthis.startClock()\n\t\t},\n\n\t\toverlay(on) {\n\t\t\tif (on) {\n\t\t\t\tthis.$nextTick(this.enterOverlay)\n\t\t\t} else {\n\t\t\t\tthis.leaveOverlay()\n\t\t\t}\n\t\t},\n\t},\n\n\tmounted() {\n\t\tthis.startClock()\n\t\tif (this.overlay) {\n\t\t\tthis.enterOverlay()\n\t\t}\n\t},\n\n\tbeforeUnmount() {\n\t\tclearInterval(this.timer)\n\t\tthis.leaveOverlay()\n\t},\n\n\tmethods: {\n\t\t/** Keep the clock on time while it shows. */\n\t\tstartClock() {\n\t\t\tclearInterval(this.timer)\n\t\t\tthis.timer = null\n\t\t\tif (this.clock) {\n\t\t\t\tthis.now = new Date()\n\t\t\t\tthis.timer = setInterval(() => {\n\t\t\t\t\tthis.now = new Date()\n\t\t\t\t}, TICK_MS)\n\t\t\t}\n\t\t},\n\n\t\t/** Make the rest of the page inert and take focus. */\n\t\tenterOverlay() {\n\t\t\tconst root = this.$refs.screen?.closest('.cn-display-screen')\n\t\t\tthis.returnFocusTo = document.activeElement\n\t\t\tthis.inerted = [...document.body.children].filter((element) => element !== root && !element.inert)\n\t\t\tthis.inerted.forEach((element) => {\n\t\t\t\telement.inert = true\n\t\t\t})\n\t\t\tthis.$refs.screen?.focus()\n\t\t},\n\n\t\t/** Give the rest of the page and the focus back. */\n\t\tleaveOverlay() {\n\t\t\tthis.inerted.forEach((element) => {\n\t\t\t\telement.inert = false\n\t\t\t})\n\t\t\tthis.inerted = []\n\t\t\tthis.returnFocusTo?.focus?.()\n\t\t\tthis.returnFocusTo = null\n\t\t},\n\n\t\t/** Ask the host to close an overlay. */\n\t\tonEscape() {\n\t\t\tif (this.overlay) {\n\t\t\t\tthis.$emit('close')\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-display-screen {\n\tbackground: var(--color-main-background);\n\tcolor: var(--color-main-text);\n}\n\n.cn-display-screen--overlay {\n\tinset: 0;\n\toverflow: auto;\n\tposition: fixed;\n\tz-index: 10000;\n}\n\n.cn-display-screen__page {\n\tdisplay: flex;\n\tflex-direction: column;\n\tfont-size: 1.6rem;\n\tgap: 16px;\n\tmin-height: 100vh;\n\toutline: none;\n\tpadding: 24px 32px;\n}\n\n.cn-display-screen__header,\n.cn-display-screen__footer {\n\talign-items: flex-end;\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 8px 24px;\n\tjustify-content: space-between;\n}\n\n.cn-display-screen__titles,\n.cn-display-screen__time {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n}\n\n.cn-display-screen__time {\n\talign-items: flex-end;\n}\n\n.cn-display-screen__title {\n\tfont-size: 1.6em;\n\tfont-weight: 700;\n\tmargin: 0;\n}\n\n.cn-display-screen__clock {\n\tfont-size: 2.2em;\n\tfont-variant-numeric: tabular-nums;\n\tfont-weight: 700;\n\tline-height: 1;\n}\n\n.cn-display-screen__muted {\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-display-screen__stale {\n\tbackground: var(--color-background-hover);\n\tborder-inline-start: 6px solid var(--color-warning);\n\tmargin: 0;\n\tpadding: 8px 12px;\n}\n\n.cn-display-screen__body {\n\tflex: 1 1 auto;\n\tmin-height: 0;\n}\n\n.cn-display-screen__actions {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 8px;\n}\n</style>\n"],"names":["_createBlock","_createVNode","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,MAAA,EAAA,SAAA,CAAA;;;;;;;;;;;;;;;;"}
@@ -2,7 +2,7 @@ import script from './CnDurationField.vue2.js';
2
2
  import { render } from './CnDurationField.vue3.js';
3
3
 
4
4
  script.render = render;
5
- script.__scopeId = "data-v-12a6b992";
5
+ script.__scopeId = "data-v-4d13ee2b";
6
6
  const __sfc_main = script;
7
7
 
8
8
  export { __sfc_main as default };
@@ -1,6 +1,6 @@
1
1
  import { translate } from '@nextcloud/l10n';
2
- import { NcButton, NcSelect, NcTextField } from '@nextcloud/vue';
3
- import { parseDuration, isIsoDuration, DURATION_UNITS, formatDuration } from '../../utils/isoDuration.js';
2
+ import { NcButton, NcProgressBar, NcSelect, NcTextField } from '@nextcloud/vue';
3
+ import { parseDuration, isIsoDuration, DURATION_UNITS, parseClock, formatClock, durationSeconds, secondsToDuration, formatDuration } from '../../utils/isoDuration.js';
4
4
 
5
5
  /**
6
6
  * CnDurationField — edits an ISO 8601 duration as a number plus a unit
@@ -12,15 +12,21 @@ import { parseDuration, isIsoDuration, DURATION_UNITS, formatDuration } from '..
12
12
  * with an "Edit as ISO" toggle, so nothing is rounded. Clearing the number
13
13
  * writes `null`.
14
14
  *
15
+ * With `timer` the field is a clock: Start, Stop and Reset run it, and it writes
16
+ * the running time into the value every second, so a form saved mid-run holds it.
17
+ * Typing a time stops the clock and keeps what was typed. `autoStart` starts it
18
+ * when the field holds no value yet. `norm` shows the time against a length.
19
+ *
15
20
  * Example:
16
21
  * ```vue
17
22
  * <CnDurationField v-model="term" input-label="Handling term" />
23
+ * <CnDurationField v-model="length" input-label="Duration" timer auto-start norm="PT5M" />
18
24
  * ```
19
25
  */
20
26
  var script = {
21
27
  name: 'CnDurationField',
22
28
 
23
- components: { NcButton, NcSelect, NcTextField },
29
+ components: { NcButton, NcProgressBar, NcSelect, NcTextField },
24
30
 
25
31
  props: {
26
32
  /** ISO 8601 duration string (v-model), or null. */
@@ -52,15 +58,64 @@ var script = {
52
58
  type: Boolean,
53
59
  default: false,
54
60
  },
61
+
62
+ /** Draw the field as a clock with Start, Stop and Reset. */
63
+ timer: {
64
+ type: Boolean,
65
+ default: false,
66
+ },
67
+
68
+ /** With `timer`: start the clock when the field holds no value yet. */
69
+ autoStart: {
70
+ type: Boolean,
71
+ default: false,
72
+ },
73
+
74
+ /** With `timer`: an ISO 8601 length to show the time against. */
75
+ norm: {
76
+ type: String,
77
+ default: null,
78
+ },
79
+
80
+ /** Percentage of `norm` from which the bar warns. */
81
+ normWarningPercent: {
82
+ type: Number,
83
+ default: 80,
84
+ },
85
+
86
+ /** Words before the time on the norm line. */
87
+ normLabel: {
88
+ type: String,
89
+ default: '',
90
+ },
91
+
92
+ /** Accessible name of the Start, Stop and Reset group. */
93
+ timerLabel: {
94
+ type: String,
95
+ default: () => translate('nextcloud-vue', 'Timer'),
96
+ },
97
+
98
+ /** With `timer`: a line under the clock. */
99
+ hint: {
100
+ type: String,
101
+ default: '',
102
+ },
55
103
  },
56
104
 
57
- emits: ['update:modelValue'],
105
+ emits: ['update:modelValue', 'started', 'stopped', 'reset'],
58
106
 
59
107
  data() {
60
108
  return {
61
109
  unit: 'days',
62
110
  editIso: false,
63
111
  draftIso: null,
112
+ running: false,
113
+ hasRun: false,
114
+ startedAt: 0,
115
+ secondsBefore: 0,
116
+ elapsed: 0,
117
+ clockDraft: null,
118
+ interval: null,
64
119
  }
65
120
  },
66
121
 
@@ -109,9 +164,168 @@ var script = {
109
164
  unitOption() {
110
165
  return this.unitOptions.find((o) => o.id === this.currentUnit) || null
111
166
  },
167
+
168
+ clockInvalid() {
169
+ return this.clockDraft !== null && this.clockDraft.trim() !== '' && parseClock(this.clockDraft) === null
170
+ },
171
+
172
+ clockText() {
173
+ if (this.clockDraft !== null) {
174
+ return this.clockDraft
175
+ }
176
+ return this.running || this.hasValue ? formatClock(this.elapsed) : ''
177
+ },
178
+
179
+ stateText() {
180
+ if (this.running) {
181
+ return translate('nextcloud-vue', 'Running')
182
+ }
183
+ return this.hasRun ? translate('nextcloud-vue', 'Stopped') : ''
184
+ },
185
+
186
+ normSeconds() {
187
+ return this.norm ? durationSeconds(this.norm) : null
188
+ },
189
+
190
+ normPercent() {
191
+ return this.normSeconds ? Math.round((this.elapsed / this.normSeconds) * 100) : 0
192
+ },
193
+
194
+ normLevel() {
195
+ if (this.normPercent >= 100) {
196
+ return 'over'
197
+ }
198
+ return this.normPercent >= this.normWarningPercent ? 'near' : 'within'
199
+ },
200
+
201
+ normWords() {
202
+ if (this.normLevel === 'over') {
203
+ return translate('nextcloud-vue', 'Over the norm')
204
+ }
205
+ return this.normLevel === 'near' ? translate('nextcloud-vue', 'Close to the norm') : ''
206
+ },
207
+
208
+ normText() {
209
+ const amount = translate('nextcloud-vue', '{elapsed} of {norm}', {
210
+ elapsed: formatClock(this.elapsed),
211
+ norm: formatClock(this.normSeconds),
212
+ });
213
+ return this.normLabel ? `${this.normLabel} ${amount}` : amount
214
+ },
215
+ },
216
+
217
+ watch: {
218
+ // The clock owns the value while it runs; the echo of its own write is ignored.
219
+ modelValue: {
220
+ immediate: true,
221
+ handler(value) {
222
+ if (!this.running) {
223
+ this.elapsed = durationSeconds(value) ?? 0;
224
+ }
225
+ if (this.clockDraft !== null && secondsToDuration(parseClock(this.clockDraft)) !== value) {
226
+ this.clockDraft = null;
227
+ }
228
+ },
229
+ },
230
+
231
+ autoStart() {
232
+ this.maybeAutoStart();
233
+ },
234
+ },
235
+
236
+ mounted() {
237
+ this.maybeAutoStart();
238
+ },
239
+
240
+ beforeUnmount() {
241
+ clearInterval(this.interval);
112
242
  },
113
243
 
114
244
  methods: {
245
+ t: translate,
246
+
247
+ maybeAutoStart() {
248
+ if (this.timer && this.autoStart && !this.disabled && !this.hasRun && !this.hasValue) {
249
+ this.start();
250
+ }
251
+ },
252
+
253
+ /**
254
+ * Run the clock from the time it shows now.
255
+ *
256
+ * @spec openspec/changes/duration-field-timer/specs/duration-field-timer/spec.md#requirement-a-duration-field-can-run-as-a-clock
257
+ */
258
+ start() {
259
+ if (this.running) {
260
+ return
261
+ }
262
+ this.clockDraft = null;
263
+ this.secondsBefore = this.elapsed;
264
+ this.startedAt = Date.now();
265
+ this.running = true;
266
+ this.hasRun = true;
267
+ this.interval = setInterval(this.tick, 1000);
268
+ /** @event started The clock started. */
269
+ this.$emit('started');
270
+ },
271
+
272
+ // Counted from the start time, because a background tab throttles intervals.
273
+ tick() {
274
+ this.elapsed = this.secondsBefore + Math.floor((Date.now() - this.startedAt) / 1000);
275
+ this.$emit('update:modelValue', secondsToDuration(this.elapsed));
276
+ },
277
+
278
+ halt() {
279
+ clearInterval(this.interval);
280
+ this.interval = null;
281
+ this.running = false;
282
+ },
283
+
284
+ /**
285
+ * Stop the clock and write the final time.
286
+ *
287
+ * @spec openspec/changes/duration-field-timer/specs/duration-field-timer/spec.md#requirement-a-duration-field-can-run-as-a-clock
288
+ */
289
+ stop() {
290
+ if (!this.running) {
291
+ return
292
+ }
293
+ this.tick();
294
+ this.halt();
295
+ const value = secondsToDuration(this.elapsed);
296
+ /** @event stopped The clock stopped; carries the ISO string of the time. */
297
+ this.$emit('stopped', value);
298
+ },
299
+
300
+ /**
301
+ * Stop the clock and clear the value.
302
+ *
303
+ * @spec openspec/changes/duration-field-timer/specs/duration-field-timer/spec.md#requirement-a-duration-field-can-run-as-a-clock
304
+ */
305
+ reset() {
306
+ this.halt();
307
+ this.elapsed = 0;
308
+ this.clockDraft = null;
309
+ this.hasRun = false;
310
+ this.$emit('update:modelValue', null);
311
+ /** @event reset The clock stopped and the value was cleared. */
312
+ this.$emit('reset');
313
+ },
314
+
315
+ onClock(text) {
316
+ const seconds = parseClock(text);
317
+ this.clockDraft = text;
318
+ if (String(text).trim() === '') {
319
+ this.halt();
320
+ this.elapsed = 0;
321
+ this.$emit('update:modelValue', null);
322
+ } else if (seconds !== null) {
323
+ this.halt();
324
+ this.elapsed = seconds;
325
+ this.$emit('update:modelValue', secondsToDuration(seconds));
326
+ }
327
+ },
328
+
115
329
  onAmount(value) {
116
330
  /** @event update:modelValue The ISO string for the chosen amount and unit; null when the amount is cleared. */
117
331
  this.$emit('update:modelValue', formatDuration(value, this.currentUnit));