@conduction/nextcloud-vue 0.1.0-beta.2 → 0.1.0-beta.4

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 (153) hide show
  1. package/README.md +226 -226
  2. package/css/index.css +5 -0
  3. package/dist/nextcloud-vue.cjs.js +60455 -8755
  4. package/dist/nextcloud-vue.cjs.js.map +1 -1
  5. package/dist/nextcloud-vue.css +2062 -528
  6. package/dist/nextcloud-vue.esm.js +60411 -8731
  7. package/dist/nextcloud-vue.esm.js.map +1 -1
  8. package/package.json +75 -61
  9. package/src/components/CnActionsBar/CnActionsBar.vue +235 -225
  10. package/src/components/CnActionsBar/index.js +1 -1
  11. package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +579 -0
  12. package/src/components/CnAdvancedFormDialog/CnDataTab.vue +217 -0
  13. package/src/components/CnAdvancedFormDialog/CnMetadataTab.vue +121 -0
  14. package/src/components/CnAdvancedFormDialog/CnPropertiesTab.vue +418 -0
  15. package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -0
  16. package/src/components/CnAdvancedFormDialog/index.js +1 -0
  17. package/src/components/CnCardGrid/CnCardGrid.vue +152 -152
  18. package/src/components/CnCardGrid/index.js +1 -1
  19. package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -132
  20. package/src/components/CnCellRenderer/index.js +1 -1
  21. package/src/components/CnChartWidget/CnChartWidget.vue +320 -0
  22. package/src/components/CnChartWidget/index.js +1 -0
  23. package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -77
  24. package/src/components/CnConfigurationCard/index.js +1 -1
  25. package/src/components/CnDashboardGrid/CnDashboardGrid.vue +225 -0
  26. package/src/components/CnDashboardGrid/index.js +1 -0
  27. package/src/components/CnDashboardPage/CnDashboardPage.vue +390 -0
  28. package/src/components/CnDashboardPage/index.js +1 -0
  29. package/src/components/CnDataTable/CnDataTable.vue +349 -349
  30. package/src/components/CnDataTable/index.js +1 -1
  31. package/src/components/CnDetailCard/CnDetailCard.vue +214 -0
  32. package/src/components/CnDetailCard/index.js +1 -0
  33. package/src/components/CnDetailPage/CnDetailPage.vue +281 -0
  34. package/src/components/CnDetailPage/index.js +1 -0
  35. package/src/components/CnFacetSidebar/CnFacetSidebar.vue +231 -223
  36. package/src/components/CnFacetSidebar/index.js +1 -1
  37. package/src/components/CnFilterBar/CnFilterBar.vue +152 -152
  38. package/src/components/CnFilterBar/index.js +1 -1
  39. package/src/components/CnIcon/CnIcon.vue +89 -89
  40. package/src/components/CnIcon/index.js +1 -1
  41. package/src/components/CnIndexPage/CnIndexPage.vue +874 -816
  42. package/src/components/CnIndexPage/index.js +1 -1
  43. package/src/components/CnIndexSidebar/CnIndexSidebar.vue +503 -484
  44. package/src/components/CnIndexSidebar/index.js +1 -1
  45. package/src/components/CnItemCard/CnItemCard.vue +132 -0
  46. package/src/components/CnItemCard/index.js +1 -0
  47. package/src/components/CnKpiGrid/CnKpiGrid.vue +89 -89
  48. package/src/components/CnKpiGrid/index.js +1 -1
  49. package/src/components/CnMassActionBar/CnMassActionBar.vue +160 -160
  50. package/src/components/CnMassActionBar/index.js +1 -1
  51. package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +320 -320
  52. package/src/components/CnMassCopyDialog/index.js +1 -1
  53. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +238 -238
  54. package/src/components/CnMassDeleteDialog/index.js +1 -1
  55. package/src/components/CnMassExportDialog/CnMassExportDialog.vue +190 -190
  56. package/src/components/CnMassExportDialog/index.js +1 -1
  57. package/src/components/CnMassImportDialog/CnMassImportDialog.vue +491 -491
  58. package/src/components/CnMassImportDialog/index.js +1 -1
  59. package/src/components/CnNoteCard/CnNoteCard.vue +149 -0
  60. package/src/components/CnNoteCard/index.js +1 -0
  61. package/src/components/CnNotesCard/CnNotesCard.vue +413 -0
  62. package/src/components/CnNotesCard/index.js +1 -0
  63. package/src/components/CnObjectCard/CnObjectCard.vue +292 -292
  64. package/src/components/CnObjectCard/index.js +1 -1
  65. package/src/components/CnObjectSidebar/CnObjectSidebar.vue +876 -0
  66. package/src/components/CnObjectSidebar/index.js +1 -0
  67. package/src/components/CnPageHeader/CnPageHeader.vue +57 -57
  68. package/src/components/CnPageHeader/index.js +1 -1
  69. package/src/components/CnPagination/CnPagination.vue +252 -252
  70. package/src/components/CnPagination/index.js +1 -1
  71. package/src/components/CnRowActions/CnRowActions.vue +73 -73
  72. package/src/components/CnRowActions/index.js +1 -1
  73. package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -0
  74. package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +787 -0
  75. package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -0
  76. package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -0
  77. package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -0
  78. package/src/components/CnSchemaFormDialog/index.js +1 -0
  79. package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -92
  80. package/src/components/CnSettingsCard/index.js +1 -1
  81. package/src/components/CnSettingsSection/CnSettingsSection.vue +266 -266
  82. package/src/components/CnSettingsSection/index.js +1 -1
  83. package/src/components/CnStatsBlock/CnStatsBlock.vue +420 -366
  84. package/src/components/CnStatsBlock/index.js +1 -1
  85. package/src/components/CnStatusBadge/CnStatusBadge.vue +77 -77
  86. package/src/components/CnStatusBadge/index.js +1 -1
  87. package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +540 -0
  88. package/src/components/CnTabbedFormDialog/index.js +1 -0
  89. package/src/components/CnTasksCard/CnTasksCard.vue +373 -0
  90. package/src/components/CnTasksCard/index.js +1 -0
  91. package/src/components/CnTileWidget/CnTileWidget.vue +159 -0
  92. package/src/components/CnTileWidget/index.js +1 -0
  93. package/src/components/CnTimelineStages/CnTimelineStages.vue +292 -0
  94. package/src/components/CnTimelineStages/index.js +1 -0
  95. package/src/components/CnUserActionMenu/CnUserActionMenu.vue +435 -0
  96. package/src/components/CnUserActionMenu/index.js +1 -0
  97. package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +312 -312
  98. package/src/components/CnVersionInfoCard/index.js +1 -1
  99. package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -0
  100. package/src/components/CnWidgetRenderer/index.js +1 -0
  101. package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +211 -0
  102. package/src/components/CnWidgetWrapper/index.js +1 -0
  103. package/src/components/index.js +43 -29
  104. package/src/composables/index.js +4 -3
  105. package/src/composables/useDashboardView.js +240 -0
  106. package/src/composables/useDetailView.js +289 -132
  107. package/src/composables/useListView.js +363 -153
  108. package/src/composables/useSubResource.js +142 -142
  109. package/src/constants/metadata.js +30 -30
  110. package/src/css/CnSchemaFormDialog.css +546 -0
  111. package/src/css/__sample_nextcloud_tokens.css +110 -0
  112. package/src/css/actions-bar.css +48 -48
  113. package/src/css/badge.css +51 -51
  114. package/src/css/card.css +128 -128
  115. package/src/css/dashboard.css +70 -0
  116. package/src/css/detail-page.css +168 -0
  117. package/src/css/detail.css +68 -68
  118. package/src/css/index-page.css +44 -32
  119. package/src/css/index-sidebar.css +193 -187
  120. package/src/css/index.css +16 -12
  121. package/src/css/layout.css +90 -90
  122. package/src/css/page-header.css +33 -33
  123. package/src/css/pagination.css +72 -72
  124. package/src/css/table.css +142 -142
  125. package/src/css/timeline-stages.css +218 -0
  126. package/src/css/utilities.css +46 -46
  127. package/src/index.js +72 -53
  128. package/src/store/createSubResourcePlugin.js +135 -135
  129. package/src/store/index.js +3 -3
  130. package/src/store/plugins/auditTrails.js +17 -17
  131. package/src/store/plugins/files.js +250 -186
  132. package/src/store/plugins/index.js +7 -5
  133. package/src/store/plugins/lifecycle.js +180 -180
  134. package/src/store/plugins/relations.js +68 -68
  135. package/src/store/plugins/search.js +372 -0
  136. package/src/store/plugins/selection.js +104 -0
  137. package/src/store/useObjectStore.js +829 -686
  138. package/src/types/auditTrail.d.ts +32 -32
  139. package/src/types/file.d.ts +23 -23
  140. package/src/types/index.d.ts +35 -35
  141. package/src/types/notification.d.ts +36 -36
  142. package/src/types/object.d.ts +40 -40
  143. package/src/types/organisation.d.ts +41 -41
  144. package/src/types/register.d.ts +25 -25
  145. package/src/types/schema.d.ts +39 -39
  146. package/src/types/shared.d.ts +79 -79
  147. package/src/types/source.d.ts +14 -14
  148. package/src/types/task.d.ts +31 -31
  149. package/src/utils/errors.js +96 -96
  150. package/src/utils/headers.js +68 -50
  151. package/src/utils/id.js +13 -0
  152. package/src/utils/index.js +3 -3
  153. package/src/utils/schema.js +422 -419
@@ -1,366 +1,420 @@
1
- <template>
2
- <component
3
- :is="clickable ? 'a' : 'div'"
4
- class="cn-stats-block"
5
- :class="rootClasses"
6
- v-bind="clickable ? { href: '#', role: 'button', tabindex: '0' } : {}"
7
- @click="onClick">
8
- <!-- Icon -->
9
- <div v-if="hasIcon" class="cn-stats-block__icon" :class="iconClasses">
10
- <slot name="icon">
11
- <component :is="icon" v-if="icon" :size="iconSize" />
12
- </slot>
13
- </div>
14
-
15
- <!-- Content -->
16
- <div class="cn-stats-block__content">
17
- <div class="cn-stats-block__header">
18
- <h4>{{ title || 'Objects' }}</h4>
19
- </div>
20
-
21
- <div v-if="count > 0" class="cn-stats-block__count">
22
- <span class="cn-stats-block__count-value">{{ formattedCount }}</span>
23
- <span class="cn-stats-block__count-label">{{ countLabel }}</span>
24
- </div>
25
- <div v-else-if="loading" class="cn-stats-block__loading">
26
- <NcLoadingIcon :size="16" />
27
- {{ loadingLabel }}
28
- </div>
29
- <div v-else class="cn-stats-block__empty">
30
- {{ emptyLabel }}
31
- </div>
32
-
33
- <!-- Breakdown details -->
34
- <div v-if="breakdown && count > 0" class="cn-stats-block__breakdown">
35
- <div
36
- v-for="(value, key) in breakdown"
37
- :key="key"
38
- class="cn-stats-block__breakdown-item">
39
- <span class="cn-stats-block__breakdown-label">{{ formatBreakdownLabel(key) }}</span>
40
- <span
41
- class="cn-stats-block__breakdown-value"
42
- :class="'cn-stats-block__breakdown-value--' + key">
43
- {{ value }}
44
- </span>
45
- </div>
46
- </div>
47
- </div>
48
- </component>
49
- </template>
50
-
51
- <script>
52
- import { NcLoadingIcon } from '@nextcloud/vue'
53
-
54
- /**
55
- * CnStatsBlock — Statistics display card with icon, count, and optional breakdown.
56
- *
57
- * Supports vertical (default) and horizontal layouts, color variants, icons,
58
- * and clickable state. Use in a CnKpiGrid for responsive dashboard layouts.
59
- *
60
- * @example Basic vertical (default)
61
- * <CnStatsBlock title="Cases" :count="42" count-label="open cases" />
62
- *
63
- * @example Horizontal with icon and variant
64
- * <CnStatsBlock
65
- * title="Open Cases"
66
- * :count="42"
67
- * :icon="BriefcaseOutline"
68
- * variant="primary"
69
- * horizontal
70
- * clickable
71
- * @click="goToCases" />
72
- *
73
- * @example With breakdown
74
- * <CnStatsBlock
75
- * title="Cases"
76
- * :count="42"
77
- * :breakdown="{ total: 100, invalid: 3, deleted: 5, published: 92 }" />
78
- *
79
- * @example Custom icon slot
80
- * <CnStatsBlock title="Files" :count="128">
81
- * <template #icon>
82
- * <FileDocumentOutline :size="24" />
83
- * </template>
84
- * </CnStatsBlock>
85
- */
86
- export default {
87
- name: 'CnStatsBlock',
88
-
89
- components: {
90
- NcLoadingIcon,
91
- },
92
-
93
- props: {
94
- /** Block title */
95
- title: {
96
- type: String,
97
- default: '',
98
- },
99
- /** The main count number to display prominently */
100
- count: {
101
- type: Number,
102
- default: 0,
103
- },
104
- /** Label displayed next to the count */
105
- countLabel: {
106
- type: String,
107
- default: 'objects',
108
- },
109
- /** Detailed breakdown object (key-value pairs) */
110
- breakdown: {
111
- type: Object,
112
- default: null,
113
- },
114
- /** Whether data is currently loading */
115
- loading: {
116
- type: Boolean,
117
- default: false,
118
- },
119
- /** Text shown while loading */
120
- loadingLabel: {
121
- type: String,
122
- default: 'Loading...',
123
- },
124
- /** Text shown when count is 0 */
125
- emptyLabel: {
126
- type: String,
127
- default: 'No items found',
128
- },
129
- /** Icon component (e.g., imported MDI icon) */
130
- icon: {
131
- type: [Object, Function],
132
- default: null,
133
- },
134
- /** Icon size in pixels */
135
- iconSize: {
136
- type: Number,
137
- default: 24,
138
- },
139
- /** Color variant: 'default', 'primary', 'success', 'warning', 'error' */
140
- variant: {
141
- type: String,
142
- default: 'default',
143
- validator: (v) => ['default', 'primary', 'success', 'warning', 'error'].includes(v),
144
- },
145
- /** Use horizontal layout (icon left, content right) */
146
- horizontal: {
147
- type: Boolean,
148
- default: false,
149
- },
150
- /** Whether the card is clickable */
151
- clickable: {
152
- type: Boolean,
153
- default: false,
154
- },
155
- },
156
-
157
- computed: {
158
- hasIcon() {
159
- return this.icon !== null || this.$scopedSlots.icon || this.$slots.icon
160
- },
161
-
162
- formattedCount() {
163
- return this.count.toLocaleString()
164
- },
165
-
166
- rootClasses() {
167
- return {
168
- 'cn-stats-block--horizontal': this.horizontal,
169
- 'cn-stats-block--clickable': this.clickable,
170
- [`cn-stats-block--${this.variant}`]: this.variant !== 'default',
171
- }
172
- },
173
-
174
- iconClasses() {
175
- return {
176
- [`cn-stats-block__icon--${this.variant}`]: this.variant !== 'default',
177
- }
178
- },
179
- },
180
-
181
- methods: {
182
- formatBreakdownLabel(key) {
183
- return key.charAt(0).toUpperCase() + key.slice(1) + ':'
184
- },
185
-
186
- onClick(event) {
187
- if (this.clickable) {
188
- event.preventDefault()
189
- this.$emit('click', event)
190
- }
191
- },
192
- },
193
- }
194
- </script>
195
-
196
- <style scoped>
197
- .cn-stats-block {
198
- background: var(--color-background-hover);
199
- border-radius: var(--border-radius-large, 10px);
200
- padding: 1rem;
201
- display: flex;
202
- flex-direction: column;
203
- align-items: center;
204
- text-decoration: none;
205
- color: inherit;
206
- border: 2px solid transparent;
207
- transition: border-color 0.15s ease, box-shadow 0.15s ease;
208
- }
209
-
210
- .cn-stats-block--horizontal {
211
- flex-direction: row;
212
- align-items: flex-start;
213
- gap: 16px;
214
- }
215
-
216
- .cn-stats-block--horizontal .cn-stats-block__content {
217
- text-align: left;
218
- }
219
-
220
- .cn-stats-block--horizontal .cn-stats-block__count {
221
- justify-content: flex-start;
222
- }
223
-
224
- .cn-stats-block--clickable {
225
- cursor: pointer;
226
- }
227
-
228
- .cn-stats-block--clickable:hover {
229
- border-color: var(--color-primary-element);
230
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
231
- }
232
-
233
- .cn-stats-block--clickable:focus-visible {
234
- outline: 2px solid var(--color-primary-element);
235
- outline-offset: 2px;
236
- }
237
-
238
- /* Icon */
239
- .cn-stats-block__icon {
240
- display: flex;
241
- align-items: center;
242
- justify-content: center;
243
- width: 44px;
244
- height: 44px;
245
- border-radius: 50%;
246
- background: var(--color-primary-element-light, rgba(0, 130, 201, 0.1));
247
- color: var(--color-primary-element);
248
- flex-shrink: 0;
249
- margin-bottom: 8px;
250
- }
251
-
252
- .cn-stats-block--horizontal .cn-stats-block__icon {
253
- margin-bottom: 0;
254
- }
255
-
256
- .cn-stats-block__icon--primary {
257
- background: var(--color-primary-element-light, rgba(0, 130, 201, 0.1));
258
- color: var(--color-primary-element);
259
- }
260
-
261
- .cn-stats-block__icon--success {
262
- background: rgba(70, 186, 97, 0.1);
263
- color: var(--color-success);
264
- }
265
-
266
- .cn-stats-block__icon--warning {
267
- background: rgba(232, 163, 24, 0.1);
268
- color: var(--color-warning);
269
- }
270
-
271
- .cn-stats-block__icon--error {
272
- background: rgba(224, 36, 36, 0.1);
273
- color: var(--color-error);
274
- }
275
-
276
- /* Content */
277
- .cn-stats-block__content {
278
- flex: 1;
279
- min-width: 0;
280
- text-align: center;
281
- }
282
-
283
- .cn-stats-block__header h4 {
284
- margin-top: 0;
285
- margin-bottom: 0.5rem;
286
- color: var(--color-main-text);
287
- font-size: 14px;
288
- font-weight: 600;
289
- }
290
-
291
- .cn-stats-block__count {
292
- display: flex;
293
- align-items: baseline;
294
- justify-content: center;
295
- gap: 0.5rem;
296
- font-size: 1.2rem;
297
- margin-bottom: 0.5rem;
298
- }
299
-
300
- .cn-stats-block__count-value {
301
- font-size: 2rem;
302
- font-weight: bold;
303
- color: var(--color-primary-element);
304
- }
305
-
306
- .cn-stats-block--primary .cn-stats-block__count-value { color: var(--color-primary-element); }
307
- .cn-stats-block--success .cn-stats-block__count-value { color: var(--color-success); }
308
- .cn-stats-block--warning .cn-stats-block__count-value { color: var(--color-warning); }
309
- .cn-stats-block--error .cn-stats-block__count-value { color: var(--color-error); }
310
-
311
- .cn-stats-block__count-label {
312
- color: var(--color-text-maxcontrast);
313
- }
314
-
315
- .cn-stats-block__loading {
316
- display: flex;
317
- align-items: center;
318
- justify-content: center;
319
- gap: 0.5rem;
320
- color: var(--color-text-maxcontrast);
321
- margin-bottom: 0.5rem;
322
- }
323
-
324
- .cn-stats-block__empty {
325
- text-align: center;
326
- color: var(--color-text-maxcontrast);
327
- font-style: italic;
328
- margin-bottom: 0.5rem;
329
- }
330
-
331
- .cn-stats-block__breakdown {
332
- margin-top: 0.5rem;
333
- padding: 0.75rem;
334
- background: var(--color-background-hover);
335
- border-radius: var(--border-radius);
336
- border: 1px solid var(--color-border);
337
- width: 100%;
338
- }
339
-
340
- .cn-stats-block__breakdown-item {
341
- display: flex;
342
- justify-content: space-between;
343
- align-items: center;
344
- margin-bottom: 0.5rem;
345
- }
346
-
347
- .cn-stats-block__breakdown-item:last-child {
348
- margin-bottom: 0;
349
- }
350
-
351
- .cn-stats-block__breakdown-label {
352
- font-weight: 500;
353
- color: var(--color-main-text);
354
- }
355
-
356
- .cn-stats-block__breakdown-value {
357
- font-weight: 600;
358
- padding: 0.25rem 0.5rem;
359
- border-radius: var(--border-radius);
360
- background: var(--color-background-hover);
361
- }
362
-
363
- .cn-stats-block__breakdown-value--invalid { color: var(--color-warning); }
364
- .cn-stats-block__breakdown-value--deleted { color: var(--color-error); }
365
- .cn-stats-block__breakdown-value--published { color: var(--color-success); }
366
- </style>
1
+ <template>
2
+ <component
3
+ :is="componentTag"
4
+ class="cn-stats-block"
5
+ :class="rootClasses"
6
+ v-bind="componentAttrs"
7
+ @click="onClick">
8
+ <!-- Icon -->
9
+ <div v-if="hasIcon" class="cn-stats-block__icon" :class="iconClasses">
10
+ <slot name="icon">
11
+ <component :is="icon" v-if="icon" :size="iconSize" />
12
+ </slot>
13
+ </div>
14
+
15
+ <!-- Content -->
16
+ <div class="cn-stats-block__content">
17
+ <div class="cn-stats-block__header">
18
+ <h4>{{ title || 'Objects' }}</h4>
19
+ </div>
20
+
21
+ <div v-if="count > 0 || (showZeroCount && count === 0)" class="cn-stats-block__count">
22
+ <span class="cn-stats-block__count-value">{{ formattedCount }}</span>
23
+ <span class="cn-stats-block__count-label">{{ countLabel }}</span>
24
+ </div>
25
+ <div v-else-if="loading" class="cn-stats-block__loading">
26
+ <NcLoadingIcon :size="16" />
27
+ {{ loadingLabel }}
28
+ </div>
29
+ <div v-else class="cn-stats-block__empty">
30
+ {{ emptyLabel }}
31
+ </div>
32
+
33
+ <!-- Breakdown details -->
34
+ <div v-if="breakdown && (count > 0 || showZeroCount)" class="cn-stats-block__breakdown">
35
+ <div
36
+ v-for="(value, key) in breakdown"
37
+ :key="key"
38
+ class="cn-stats-block__breakdown-item">
39
+ <span class="cn-stats-block__breakdown-label">{{ formatBreakdownLabel(key) }}</span>
40
+ <span
41
+ class="cn-stats-block__breakdown-value"
42
+ :class="'cn-stats-block__breakdown-value--' + key">
43
+ {{ value }}
44
+ </span>
45
+ </div>
46
+ </div>
47
+ </div>
48
+ </component>
49
+ </template>
50
+
51
+ <script>
52
+ import { NcLoadingIcon } from '@nextcloud/vue'
53
+
54
+ /**
55
+ * CnStatsBlock — Statistics display card with icon, count, and optional breakdown.
56
+ *
57
+ * Supports vertical (default) and horizontal layouts, color variants, icons,
58
+ * and clickable state. Use in a CnKpiGrid for responsive dashboard layouts.
59
+ *
60
+ * @example Basic vertical (default)
61
+ * <CnStatsBlock title="Cases" :count="42" count-label="open cases" />
62
+ *
63
+ * @example Horizontal with icon and variant
64
+ * <CnStatsBlock
65
+ * title="Open Cases"
66
+ * :count="42"
67
+ * :icon="BriefcaseOutline"
68
+ * variant="primary"
69
+ * horizontal
70
+ * clickable
71
+ * @click="goToCases" />
72
+ *
73
+ * @example With route-based navigation (renders as <router-link>)
74
+ * <CnStatsBlock
75
+ * title="Open Cases"
76
+ * :count="42"
77
+ * :icon="BriefcaseOutline"
78
+ * variant="primary"
79
+ * :route="{ name: 'Cases', query: { status: 'open' } }" />
80
+ *
81
+ * @example With breakdown
82
+ * <CnStatsBlock
83
+ * title="Cases"
84
+ * :count="42"
85
+ * :breakdown="{ total: 100, invalid: 3, deleted: 5, published: 92 }" />
86
+ *
87
+ * @example Custom icon slot
88
+ * <CnStatsBlock title="Files" :count="128">
89
+ * <template #icon>
90
+ * <FileDocumentOutline :size="24" />
91
+ * </template>
92
+ * </CnStatsBlock>
93
+ */
94
+ export default {
95
+ name: 'CnStatsBlock',
96
+
97
+ components: {
98
+ NcLoadingIcon,
99
+ },
100
+
101
+ props: {
102
+ /** Block title */
103
+ title: {
104
+ type: String,
105
+ default: '',
106
+ },
107
+ /** The main count number to display prominently */
108
+ count: {
109
+ type: Number,
110
+ default: 0,
111
+ },
112
+ /** Label displayed next to the count */
113
+ countLabel: {
114
+ type: String,
115
+ default: 'objects',
116
+ },
117
+ /** Detailed breakdown object (key-value pairs) */
118
+ breakdown: {
119
+ type: Object,
120
+ default: null,
121
+ },
122
+ /** Whether data is currently loading */
123
+ loading: {
124
+ type: Boolean,
125
+ default: false,
126
+ },
127
+ /** Text shown while loading */
128
+ loadingLabel: {
129
+ type: String,
130
+ default: 'Loading...',
131
+ },
132
+ /** Text shown when count is 0 */
133
+ emptyLabel: {
134
+ type: String,
135
+ default: 'No items found',
136
+ },
137
+ /** Icon component (e.g., imported MDI icon) */
138
+ icon: {
139
+ type: [Object, Function],
140
+ default: null,
141
+ },
142
+ /** Icon size in pixels */
143
+ iconSize: {
144
+ type: Number,
145
+ default: 24,
146
+ },
147
+ /** Color variant: 'default', 'primary', 'success', 'warning', 'error' */
148
+ variant: {
149
+ type: String,
150
+ default: 'default',
151
+ validator: (v) => ['default', 'primary', 'success', 'warning', 'error'].includes(v),
152
+ },
153
+ /** Use horizontal layout (icon left, content right) */
154
+ horizontal: {
155
+ type: Boolean,
156
+ default: false,
157
+ },
158
+ /** Whether the card is clickable */
159
+ clickable: {
160
+ type: Boolean,
161
+ default: false,
162
+ },
163
+ /** Whether to display 0 as a count value instead of the empty label */
164
+ showZeroCount: {
165
+ type: Boolean,
166
+ default: false,
167
+ },
168
+ /**
169
+ * Vue Router location object for declarative navigation.
170
+ * When set, the card renders as a <router-link> and clickable styles are implied.
171
+ * @example { name: 'Cases', query: { status: 'open' } }
172
+ * @example { path: '/catalogi' }
173
+ */
174
+ route: {
175
+ type: Object,
176
+ default: null,
177
+ },
178
+ },
179
+
180
+ computed: {
181
+ hasIcon() {
182
+ return this.icon !== null || this.$scopedSlots.icon || this.$slots.icon
183
+ },
184
+
185
+ formattedCount() {
186
+ return this.count.toLocaleString()
187
+ },
188
+
189
+ /**
190
+ * Whether the card is interactive (clickable or has a route).
191
+ * Used for applying hover/focus styles.
192
+ */
193
+ isInteractive() {
194
+ return !!this.route || this.clickable
195
+ },
196
+
197
+ /**
198
+ * Determines which HTML element or component to render.
199
+ * - route set → 'router-link' (SPA navigation)
200
+ * - clickable → 'a' (app handles click via event)
201
+ * - neither → 'div' (static display)
202
+ */
203
+ componentTag() {
204
+ if (this.route) return 'router-link'
205
+ if (this.clickable) return 'a'
206
+ return 'div'
207
+ },
208
+
209
+ /**
210
+ * Dynamic attributes for the root element based on rendering mode.
211
+ */
212
+ componentAttrs() {
213
+ if (this.route) return { to: this.route, tabindex: '0' }
214
+ if (this.clickable) return { href: '#', role: 'button', tabindex: '0' }
215
+ return {}
216
+ },
217
+
218
+ rootClasses() {
219
+ return {
220
+ 'cn-stats-block--horizontal': this.horizontal,
221
+ 'cn-stats-block--clickable': this.isInteractive,
222
+ [`cn-stats-block--${this.variant}`]: this.variant !== 'default',
223
+ }
224
+ },
225
+
226
+ iconClasses() {
227
+ return {
228
+ [`cn-stats-block__icon--${this.variant}`]: this.variant !== 'default',
229
+ }
230
+ },
231
+ },
232
+
233
+ methods: {
234
+ formatBreakdownLabel(key) {
235
+ return key.charAt(0).toUpperCase() + key.slice(1) + ':'
236
+ },
237
+
238
+ onClick(event) {
239
+ // When route is set, router-link handles navigation — do not emit click
240
+ if (this.route) return
241
+ if (this.clickable) {
242
+ event.preventDefault()
243
+ this.$emit('click', event)
244
+ }
245
+ },
246
+ },
247
+ }
248
+ </script>
249
+
250
+ <style scoped>
251
+ .cn-stats-block {
252
+ background: var(--color-background-hover);
253
+ border-radius: var(--border-radius-large, 10px);
254
+ padding: 1rem;
255
+ display: flex;
256
+ flex-direction: column;
257
+ align-items: center;
258
+ text-decoration: none;
259
+ color: inherit;
260
+ border: 2px solid transparent;
261
+ transition: border-color 0.15s ease, box-shadow 0.15s ease;
262
+ }
263
+
264
+ .cn-stats-block--horizontal {
265
+ flex-direction: row;
266
+ align-items: flex-start;
267
+ gap: 16px;
268
+ }
269
+
270
+ .cn-stats-block--horizontal .cn-stats-block__content {
271
+ text-align: left;
272
+ }
273
+
274
+ .cn-stats-block--horizontal .cn-stats-block__count {
275
+ justify-content: flex-start;
276
+ }
277
+
278
+ .cn-stats-block--clickable {
279
+ cursor: pointer;
280
+ }
281
+
282
+ .cn-stats-block--clickable:hover {
283
+ border-color: var(--color-primary-element);
284
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
285
+ }
286
+
287
+ .cn-stats-block--clickable:focus-visible {
288
+ outline: 2px solid var(--color-primary-element);
289
+ outline-offset: 2px;
290
+ }
291
+
292
+ /* Icon */
293
+ .cn-stats-block__icon {
294
+ display: flex;
295
+ align-items: center;
296
+ justify-content: center;
297
+ width: 44px;
298
+ height: 44px;
299
+ border-radius: 50%;
300
+ background: var(--color-primary-element-light, rgba(0, 130, 201, 0.1));
301
+ color: var(--color-primary-element);
302
+ flex-shrink: 0;
303
+ margin-bottom: 8px;
304
+ }
305
+
306
+ .cn-stats-block--horizontal .cn-stats-block__icon {
307
+ margin-bottom: 0;
308
+ }
309
+
310
+ .cn-stats-block__icon--primary {
311
+ background: var(--color-primary-element-light, rgba(0, 130, 201, 0.1));
312
+ color: var(--color-primary-element);
313
+ }
314
+
315
+ .cn-stats-block__icon--success {
316
+ background: rgba(70, 186, 97, 0.1);
317
+ color: var(--color-success);
318
+ }
319
+
320
+ .cn-stats-block__icon--warning {
321
+ background: rgba(232, 163, 24, 0.1);
322
+ color: var(--color-warning);
323
+ }
324
+
325
+ .cn-stats-block__icon--error {
326
+ background: rgba(224, 36, 36, 0.1);
327
+ color: var(--color-error);
328
+ }
329
+
330
+ /* Content */
331
+ .cn-stats-block__content {
332
+ flex: 1;
333
+ min-width: 0;
334
+ text-align: center;
335
+ }
336
+
337
+ .cn-stats-block__header h4 {
338
+ margin-top: 0;
339
+ margin-bottom: 0.5rem;
340
+ color: var(--color-main-text);
341
+ font-size: 14px;
342
+ font-weight: 600;
343
+ }
344
+
345
+ .cn-stats-block__count {
346
+ display: flex;
347
+ align-items: baseline;
348
+ justify-content: center;
349
+ gap: 0.5rem;
350
+ font-size: 1.2rem;
351
+ margin-bottom: 0.5rem;
352
+ }
353
+
354
+ .cn-stats-block__count-value {
355
+ font-size: 2rem;
356
+ font-weight: bold;
357
+ color: var(--color-primary-element);
358
+ }
359
+
360
+ .cn-stats-block--primary .cn-stats-block__count-value { color: var(--color-primary-element); }
361
+ .cn-stats-block--success .cn-stats-block__count-value { color: var(--color-success); }
362
+ .cn-stats-block--warning .cn-stats-block__count-value { color: var(--color-warning); }
363
+ .cn-stats-block--error .cn-stats-block__count-value { color: var(--color-error); }
364
+
365
+ .cn-stats-block__count-label {
366
+ color: var(--color-text-maxcontrast);
367
+ }
368
+
369
+ .cn-stats-block__loading {
370
+ display: flex;
371
+ align-items: center;
372
+ justify-content: center;
373
+ gap: 0.5rem;
374
+ color: var(--color-text-maxcontrast);
375
+ margin-bottom: 0.5rem;
376
+ }
377
+
378
+ .cn-stats-block__empty {
379
+ text-align: center;
380
+ color: var(--color-text-maxcontrast);
381
+ font-style: italic;
382
+ margin-bottom: 0.5rem;
383
+ }
384
+
385
+ .cn-stats-block__breakdown {
386
+ margin-top: 0.5rem;
387
+ padding: 0.75rem;
388
+ background: var(--color-background-hover);
389
+ border-radius: var(--border-radius);
390
+ border: 1px solid var(--color-border);
391
+ width: 100%;
392
+ }
393
+
394
+ .cn-stats-block__breakdown-item {
395
+ display: flex;
396
+ justify-content: space-between;
397
+ align-items: center;
398
+ margin-bottom: 0.5rem;
399
+ }
400
+
401
+ .cn-stats-block__breakdown-item:last-child {
402
+ margin-bottom: 0;
403
+ }
404
+
405
+ .cn-stats-block__breakdown-label {
406
+ font-weight: 500;
407
+ color: var(--color-main-text);
408
+ }
409
+
410
+ .cn-stats-block__breakdown-value {
411
+ font-weight: 600;
412
+ padding: 0.25rem 0.5rem;
413
+ border-radius: var(--border-radius);
414
+ background: var(--color-background-hover);
415
+ }
416
+
417
+ .cn-stats-block__breakdown-value--invalid { color: var(--color-element-warning); }
418
+ .cn-stats-block__breakdown-value--deleted { color: var(--color-element-error); }
419
+ .cn-stats-block__breakdown-value--published { color: var(--color-element-success); }
420
+ </style>