@conduction/nextcloud-vue 0.1.0-beta.1 → 0.1.0-beta.11

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 (208) hide show
  1. package/README.md +226 -0
  2. package/css/index.css +5 -0
  3. package/dist/nextcloud-vue.cjs.js +79416 -7715
  4. package/dist/nextcloud-vue.cjs.js.map +1 -1
  5. package/dist/nextcloud-vue.css +3583 -504
  6. package/dist/nextcloud-vue.esm.js +79343 -7692
  7. package/dist/nextcloud-vue.esm.js.map +1 -1
  8. package/l10n/en.json +164 -0
  9. package/l10n/nl.json +164 -0
  10. package/package.json +104 -63
  11. package/src/components/CnActionsBar/CnActionsBar.vue +254 -0
  12. package/src/components/CnActionsBar/index.js +1 -0
  13. package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +570 -0
  14. package/src/components/CnAdvancedFormDialog/CnDataTab.vue +217 -0
  15. package/src/components/CnAdvancedFormDialog/CnMetadataTab.vue +121 -0
  16. package/src/components/CnAdvancedFormDialog/CnPropertiesTab.vue +422 -0
  17. package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -0
  18. package/src/components/CnAdvancedFormDialog/index.js +1 -0
  19. package/src/components/CnCard/CnCard.vue +415 -0
  20. package/src/components/CnCard/index.js +1 -0
  21. package/src/components/CnCardGrid/CnCardGrid.vue +156 -152
  22. package/src/components/CnCardGrid/index.js +1 -1
  23. package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -132
  24. package/src/components/CnCellRenderer/index.js +1 -1
  25. package/src/components/CnChartWidget/CnChartWidget.vue +346 -0
  26. package/src/components/CnChartWidget/index.js +1 -0
  27. package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -77
  28. package/src/components/CnConfigurationCard/index.js +1 -1
  29. package/src/components/CnContextMenu/CnContextMenu.vue +142 -0
  30. package/src/components/CnContextMenu/index.js +1 -0
  31. package/src/components/CnCopyDialog/CnCopyDialog.vue +266 -0
  32. package/src/components/CnCopyDialog/index.js +1 -0
  33. package/src/components/CnDashboardGrid/CnDashboardGrid.vue +229 -0
  34. package/src/components/CnDashboardGrid/index.js +1 -0
  35. package/src/components/CnDashboardPage/CnDashboardPage.vue +397 -0
  36. package/src/components/CnDashboardPage/index.js +1 -0
  37. package/src/components/CnDataTable/CnDataTable.vue +362 -354
  38. package/src/components/CnDataTable/index.js +1 -1
  39. package/src/components/CnDeleteDialog/CnDeleteDialog.vue +177 -0
  40. package/src/components/CnDeleteDialog/index.js +1 -0
  41. package/src/components/CnDetailCard/CnDetailCard.vue +225 -0
  42. package/src/components/CnDetailCard/index.js +1 -0
  43. package/src/components/CnDetailGrid/CnDetailGrid.vue +256 -0
  44. package/src/components/CnDetailGrid/index.js +1 -0
  45. package/src/components/CnDetailPage/CnDetailPage.vue +432 -0
  46. package/src/components/CnDetailPage/index.js +1 -0
  47. package/src/components/CnFacetSidebar/CnFacetSidebar.vue +234 -223
  48. package/src/components/CnFacetSidebar/index.js +1 -1
  49. package/src/components/CnFilterBar/CnFilterBar.vue +153 -152
  50. package/src/components/CnFilterBar/index.js +1 -1
  51. package/src/components/CnFormDialog/CnFormDialog.vue +1047 -0
  52. package/src/components/CnFormDialog/index.js +1 -0
  53. package/src/components/CnIcon/CnIcon.vue +89 -0
  54. package/src/components/CnIcon/index.js +1 -0
  55. package/src/components/CnIndexPage/CnIndexPage.vue +980 -682
  56. package/src/components/CnIndexPage/index.js +1 -1
  57. package/src/components/CnIndexSidebar/CnIndexSidebar.vue +536 -0
  58. package/src/components/CnIndexSidebar/index.js +1 -0
  59. package/src/components/CnInfoWidget/CnInfoWidget.vue +219 -0
  60. package/src/components/CnInfoWidget/index.js +1 -0
  61. package/src/components/CnItemCard/CnItemCard.vue +134 -0
  62. package/src/components/CnItemCard/index.js +1 -0
  63. package/src/components/CnJsonViewer/CnJsonViewer.vue +312 -0
  64. package/src/components/CnJsonViewer/index.js +1 -0
  65. package/src/components/CnKpiGrid/CnKpiGrid.vue +93 -89
  66. package/src/components/CnKpiGrid/index.js +1 -1
  67. package/src/components/CnMassActionBar/CnMassActionBar.vue +161 -160
  68. package/src/components/CnMassActionBar/index.js +1 -1
  69. package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +327 -320
  70. package/src/components/CnMassCopyDialog/index.js +1 -1
  71. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +245 -238
  72. package/src/components/CnMassDeleteDialog/index.js +1 -1
  73. package/src/components/CnMassExportDialog/CnMassExportDialog.vue +191 -190
  74. package/src/components/CnMassExportDialog/index.js +1 -1
  75. package/src/components/CnMassImportDialog/CnMassImportDialog.vue +494 -491
  76. package/src/components/CnMassImportDialog/index.js +1 -1
  77. package/src/components/CnNoteCard/CnNoteCard.vue +149 -0
  78. package/src/components/CnNoteCard/index.js +1 -0
  79. package/src/components/CnNotesCard/CnNotesCard.vue +416 -0
  80. package/src/components/CnNotesCard/index.js +1 -0
  81. package/src/components/CnObjectCard/CnObjectCard.vue +294 -292
  82. package/src/components/CnObjectCard/index.js +1 -1
  83. package/src/components/CnObjectDataWidget/CnObjectDataWidget.vue +854 -0
  84. package/src/components/CnObjectDataWidget/index.js +1 -0
  85. package/src/components/CnObjectMetadataWidget/CnObjectMetadataWidget.vue +289 -0
  86. package/src/components/CnObjectMetadataWidget/index.js +1 -0
  87. package/src/components/CnObjectSidebar/CnAuditTrailTab.vue +369 -0
  88. package/src/components/CnObjectSidebar/CnFilesTab.vue +287 -0
  89. package/src/components/CnObjectSidebar/CnNotesTab.vue +250 -0
  90. package/src/components/CnObjectSidebar/CnObjectSidebar.vue +255 -0
  91. package/src/components/CnObjectSidebar/CnTagsTab.vue +259 -0
  92. package/src/components/CnObjectSidebar/CnTasksTab.vue +483 -0
  93. package/src/components/CnObjectSidebar/index.js +6 -0
  94. package/src/components/CnPageHeader/CnPageHeader.vue +61 -0
  95. package/src/components/CnPageHeader/index.js +1 -0
  96. package/src/components/CnPagination/CnPagination.vue +253 -252
  97. package/src/components/CnPagination/index.js +1 -1
  98. package/src/components/CnProgressBar/CnProgressBar.vue +262 -0
  99. package/src/components/CnProgressBar/index.js +1 -0
  100. package/src/components/CnRegisterMapping/CnRegisterMapping.vue +793 -0
  101. package/src/components/CnRegisterMapping/index.js +1 -0
  102. package/src/components/CnRowActions/CnRowActions.vue +95 -73
  103. package/src/components/CnRowActions/index.js +1 -1
  104. package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -0
  105. package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +788 -0
  106. package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -0
  107. package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -0
  108. package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -0
  109. package/src/components/CnSchemaFormDialog/index.js +1 -0
  110. package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -92
  111. package/src/components/CnSettingsCard/index.js +1 -1
  112. package/src/components/CnSettingsSection/CnSettingsSection.vue +267 -266
  113. package/src/components/CnSettingsSection/index.js +1 -1
  114. package/src/components/CnStatsBlock/CnStatsBlock.vue +437 -366
  115. package/src/components/CnStatsBlock/index.js +1 -1
  116. package/src/components/CnStatsPanel/CnStatsPanel.vue +321 -0
  117. package/src/components/CnStatsPanel/index.js +1 -0
  118. package/src/components/CnStatusBadge/CnStatusBadge.vue +90 -77
  119. package/src/components/CnStatusBadge/index.js +1 -1
  120. package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +545 -0
  121. package/src/components/CnTabbedFormDialog/index.js +1 -0
  122. package/src/components/CnTableWidget/CnTableWidget.vue +333 -0
  123. package/src/components/CnTableWidget/index.js +1 -0
  124. package/src/components/CnTasksCard/CnTasksCard.vue +374 -0
  125. package/src/components/CnTasksCard/index.js +1 -0
  126. package/src/components/CnTileWidget/CnTileWidget.vue +159 -0
  127. package/src/components/CnTileWidget/index.js +1 -0
  128. package/src/components/CnTimelineStages/CnTimelineStages.vue +294 -0
  129. package/src/components/CnTimelineStages/index.js +1 -0
  130. package/src/components/CnUserActionMenu/CnUserActionMenu.vue +436 -0
  131. package/src/components/CnUserActionMenu/index.js +1 -0
  132. package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +313 -312
  133. package/src/components/CnVersionInfoCard/index.js +1 -1
  134. package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -0
  135. package/src/components/CnWidgetRenderer/index.js +1 -0
  136. package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +248 -0
  137. package/src/components/CnWidgetWrapper/index.js +1 -0
  138. package/src/components/index.js +57 -25
  139. package/src/composables/index.js +5 -3
  140. package/src/composables/useContextMenu.js +126 -0
  141. package/src/composables/useDashboardView.js +286 -0
  142. package/src/composables/useDetailView.js +290 -132
  143. package/src/composables/useListView.js +364 -153
  144. package/src/composables/useSubResource.js +142 -142
  145. package/src/constants/metadata.js +30 -0
  146. package/src/css/CnSchemaFormDialog.css +546 -0
  147. package/src/css/__sample_nextcloud_tokens.css +110 -0
  148. package/src/css/actions-bar.css +54 -0
  149. package/src/css/badge.css +83 -51
  150. package/src/css/card.css +129 -128
  151. package/src/css/context-menu.css +20 -0
  152. package/src/css/dashboard.css +70 -0
  153. package/src/css/detail-page.css +235 -0
  154. package/src/css/detail.css +68 -68
  155. package/src/css/index-page.css +44 -0
  156. package/src/css/index-sidebar.css +193 -0
  157. package/src/css/index.css +17 -8
  158. package/src/css/layout.css +90 -90
  159. package/src/css/page-header.css +35 -0
  160. package/src/css/pagination.css +72 -72
  161. package/src/css/table.css +142 -143
  162. package/src/css/timeline-stages.css +220 -0
  163. package/src/css/utilities.css +46 -46
  164. package/src/index.js +95 -50
  165. package/src/l10n/index.js +12 -0
  166. package/src/mixins/gridLayout.js +118 -0
  167. package/src/store/createCrudStore.d.ts +350 -0
  168. package/src/store/createCrudStore.js +413 -0
  169. package/src/store/createSubResourcePlugin.js +125 -135
  170. package/src/store/index.js +4 -3
  171. package/src/store/pluginMerge.js +55 -0
  172. package/src/store/plugins/auditTrails.js +357 -17
  173. package/src/store/plugins/files.js +250 -186
  174. package/src/store/plugins/index.js +8 -4
  175. package/src/store/plugins/lifecycle.js +180 -180
  176. package/src/store/plugins/logs.d.ts +22 -0
  177. package/src/store/plugins/logs.js +172 -0
  178. package/src/store/plugins/registerMapping.js +195 -0
  179. package/src/store/plugins/relations.js +68 -68
  180. package/src/store/plugins/search.js +385 -0
  181. package/src/store/plugins/selection.js +104 -0
  182. package/src/store/useObjectStore.js +793 -625
  183. package/src/types/auditTrail.d.ts +32 -32
  184. package/src/types/file.d.ts +23 -23
  185. package/src/types/index.d.ts +67 -35
  186. package/src/types/notification.d.ts +36 -36
  187. package/src/types/object.d.ts +40 -40
  188. package/src/types/organisation.d.ts +41 -41
  189. package/src/types/register.d.ts +25 -25
  190. package/src/types/schema.d.ts +39 -39
  191. package/src/types/shared.d.ts +79 -79
  192. package/src/types/source.d.ts +14 -14
  193. package/src/types/task.d.ts +31 -31
  194. package/src/utils/errors.js +96 -96
  195. package/src/utils/getTheme.js +9 -0
  196. package/src/utils/headers.js +80 -44
  197. package/src/utils/id.js +13 -0
  198. package/src/utils/index.js +4 -3
  199. package/src/utils/schema.js +423 -287
  200. package/src/utils/widgetVisibility.js +162 -0
  201. package/src/components/CnDetailViewLayout/CnDetailViewLayout.vue +0 -88
  202. package/src/components/CnDetailViewLayout/index.js +0 -1
  203. package/src/components/CnEmptyState/CnEmptyState.vue +0 -78
  204. package/src/components/CnEmptyState/index.js +0 -1
  205. package/src/components/CnListViewLayout/CnListViewLayout.vue +0 -80
  206. package/src/components/CnListViewLayout/index.js +0 -1
  207. package/src/components/CnViewModeToggle/CnViewModeToggle.vue +0 -77
  208. package/src/components/CnViewModeToggle/index.js +0 -1
@@ -0,0 +1,219 @@
1
+ <!--
2
+ CnInfoWidget — Renders label-value pairs in a responsive CSS grid.
3
+
4
+ Supports two modes:
5
+ 1. Manual: provide `fields` prop with `[{ label, value }]` objects
6
+ 2. Auto-generated: provide `object` + `schema` props to generate from JSON Schema properties
7
+
8
+ Used in dashboard and detail page grid layouts to display entity metadata.
9
+ -->
10
+ <template>
11
+ <div
12
+ class="cn-info-widget"
13
+ :style="gridStyle">
14
+ <div
15
+ v-for="(field, index) in displayFields"
16
+ :key="index"
17
+ class="cn-info-widget__field">
18
+ <dt class="cn-info-widget__label">
19
+ {{ field.label }}
20
+ </dt>
21
+ <dd class="cn-info-widget__value">
22
+ {{ field.value || '—' }}
23
+ </dd>
24
+ </div>
25
+ </div>
26
+ </template>
27
+
28
+ <script>
29
+ /**
30
+ * CnInfoWidget — Renders label-value pairs in a responsive CSS grid.
31
+ *
32
+ * @example Manual fields
33
+ * <CnInfoWidget :fields="[
34
+ * { label: 'Email', value: 'test@example.com' },
35
+ * { label: 'Phone', value: '+31 6 12345678' },
36
+ * ]" :columns="2" />
37
+ *
38
+ * @example Auto-generated from schema
39
+ * <CnInfoWidget :object="myObject" :schema="mySchema" :columns="3" />
40
+ */
41
+ export default {
42
+ name: 'CnInfoWidget',
43
+
44
+ props: {
45
+ /**
46
+ * Manual field definitions. Array of `{ label, value }` objects.
47
+ * Takes precedence over object+schema auto-generation.
48
+ *
49
+ * @type {{ label: string, value: string|number }[]}
50
+ */
51
+ fields: {
52
+ type: Array,
53
+ default: null,
54
+ },
55
+ /**
56
+ * Object data for auto-generation mode. Properties are extracted
57
+ * based on the schema definition.
58
+ *
59
+ * @type {object}
60
+ */
61
+ object: {
62
+ type: Object,
63
+ default: null,
64
+ },
65
+ /**
66
+ * JSON Schema for auto-generation mode. Each schema property
67
+ * generates a label:value pair using the property title as label.
68
+ *
69
+ * @type {object}
70
+ */
71
+ schema: {
72
+ type: Object,
73
+ default: null,
74
+ },
75
+ /**
76
+ * Number of columns for the grid layout.
77
+ *
78
+ * @type {number}
79
+ */
80
+ columns: {
81
+ type: Number,
82
+ default: 2,
83
+ },
84
+ /**
85
+ * Fields to include (by key). If provided, only these fields are shown.
86
+ * Only applies in auto-generation mode.
87
+ *
88
+ * @type {string[]}
89
+ */
90
+ includeFields: {
91
+ type: Array,
92
+ default: null,
93
+ },
94
+ /**
95
+ * Fields to exclude (by key). Only applies in auto-generation mode.
96
+ *
97
+ * @type {string[]}
98
+ */
99
+ excludeFields: {
100
+ type: Array,
101
+ default: () => [],
102
+ },
103
+ },
104
+
105
+ computed: {
106
+ /**
107
+ * Resolved fields to display. Manual fields take precedence;
108
+ * otherwise generates from object + schema.
109
+ *
110
+ * @return {{ label: string, value: string|number }[]}
111
+ */
112
+ displayFields() {
113
+ if (this.fields) {
114
+ return this.fields
115
+ }
116
+
117
+ if (this.object && this.schema && this.schema.properties) {
118
+ return this.generateFieldsFromSchema()
119
+ }
120
+
121
+ return []
122
+ },
123
+
124
+ /**
125
+ * CSS grid style based on column count.
126
+ *
127
+ * @return {object}
128
+ */
129
+ gridStyle() {
130
+ return {
131
+ gridTemplateColumns: `repeat(${this.columns}, 1fr)`,
132
+ }
133
+ },
134
+ },
135
+
136
+ methods: {
137
+ /**
138
+ * Generate label-value field definitions from object + schema.
139
+ *
140
+ * @return {{ label: string, value: string|number }[]}
141
+ */
142
+ generateFieldsFromSchema() {
143
+ const properties = this.schema.properties || {}
144
+ const keys = this.includeFields || Object.keys(properties)
145
+
146
+ return keys
147
+ .filter(key => !this.excludeFields.includes(key))
148
+ .filter(key => properties[key])
149
+ .map(key => ({
150
+ label: properties[key].title || key,
151
+ value: this.formatFieldValue(this.object[key], properties[key]),
152
+ }))
153
+ },
154
+
155
+ /**
156
+ * Format a field value for display based on its schema type.
157
+ *
158
+ * @param {*} value - The raw value.
159
+ * @param {object} schemaProp - The JSON Schema property definition.
160
+ * @return {string} Formatted display value.
161
+ */
162
+ formatFieldValue(value) {
163
+ if (value === null || value === undefined) {
164
+ return ''
165
+ }
166
+
167
+ if (Array.isArray(value)) {
168
+ return value.join(', ')
169
+ }
170
+
171
+ if (typeof value === 'object') {
172
+ return JSON.stringify(value)
173
+ }
174
+
175
+ if (typeof value === 'boolean') {
176
+ return value ? 'Yes' : 'No'
177
+ }
178
+
179
+ return String(value)
180
+ },
181
+ },
182
+ }
183
+ </script>
184
+
185
+ <style scoped>
186
+ .cn-info-widget {
187
+ display: grid;
188
+ gap: 12px 24px;
189
+ }
190
+
191
+ .cn-info-widget__field {
192
+ display: flex;
193
+ flex-direction: column;
194
+ gap: 2px;
195
+ }
196
+
197
+ .cn-info-widget__label {
198
+ font-size: 12px;
199
+ font-weight: 600;
200
+ color: var(--color-text-maxcontrast);
201
+ text-transform: uppercase;
202
+ letter-spacing: 0.5px;
203
+ margin: 0;
204
+ }
205
+
206
+ .cn-info-widget__value {
207
+ font-size: 14px;
208
+ color: var(--color-main-text);
209
+ margin: 0;
210
+ word-break: break-word;
211
+ }
212
+
213
+ /* Responsive: single column on small screens */
214
+ @media (max-width: 600px) {
215
+ .cn-info-widget {
216
+ grid-template-columns: 1fr !important;
217
+ }
218
+ }
219
+ </style>
@@ -0,0 +1 @@
1
+ export { default as CnInfoWidget } from './CnInfoWidget.vue'
@@ -0,0 +1,134 @@
1
+ <template>
2
+ <div class="cn-item-card" @click="$emit('click', $event)">
3
+ <div class="cn-item-card__header">
4
+ <div class="cn-item-card__title-row">
5
+ <slot name="icon">
6
+ <component :is="icon" v-if="icon" :size="iconSize" />
7
+ </slot>
8
+ <div class="cn-item-card__title-content">
9
+ <h3 class="cn-item-card__title">
10
+ {{ title }}
11
+ </h3>
12
+ <span v-if="subtitle" class="cn-item-card__subtitle">{{ subtitle }}</span>
13
+ </div>
14
+ </div>
15
+ <div v-if="$slots.actions || $scopedSlots.actions" class="cn-item-card__actions">
16
+ <slot name="actions" />
17
+ </div>
18
+ </div>
19
+ <div v-if="$slots.default || $scopedSlots.default" class="cn-item-card__content">
20
+ <slot />
21
+ </div>
22
+ </div>
23
+ </template>
24
+
25
+ <script>
26
+ /**
27
+ * CnItemCard — Compact card for displaying an item in a sidebar list.
28
+ *
29
+ * Provides a card with a header (icon + title + optional actions) and
30
+ * a flexible content area. Designed for use in sidebar lists such as
31
+ * schema listings, source listings, etc.
32
+ *
33
+ * @example Basic usage
34
+ * <CnItemCard title="My Schema" :icon="FileCodeOutline">
35
+ * <p>Schema content here</p>
36
+ * </CnItemCard>
37
+ *
38
+ * @example With actions and stats
39
+ * <CnItemCard title="My Schema" :icon="FileCodeOutline" subtitle="v1.0">
40
+ * <template #actions>
41
+ * <NcActions>
42
+ * <NcActionButton @click="edit">Edit</NcActionButton>
43
+ * </NcActions>
44
+ * </template>
45
+ * <CnKpiGrid :columns="2">
46
+ * <CnStatsBlock title="Objects" :count="42" />
47
+ * <CnStatsBlock title="Size" :count="0" :breakdown="{ size: '1.2 MB' }" />
48
+ * </CnKpiGrid>
49
+ * </CnItemCard>
50
+ */
51
+ export default {
52
+ name: 'CnItemCard',
53
+
54
+ props: {
55
+ /** Card title */
56
+ title: {
57
+ type: String,
58
+ default: '',
59
+ },
60
+ /** Optional subtitle below the title */
61
+ subtitle: {
62
+ type: String,
63
+ default: '',
64
+ },
65
+ /** Icon component (e.g., imported MDI icon) */
66
+ icon: {
67
+ type: [Object, Function],
68
+ default: null,
69
+ },
70
+ /** Icon size in pixels */
71
+ iconSize: {
72
+ type: Number,
73
+ default: 20,
74
+ },
75
+ },
76
+ }
77
+ </script>
78
+
79
+ <style scoped>
80
+ .cn-item-card {
81
+ background: var(--color-main-background);
82
+ border: 1px solid var(--color-border);
83
+ border-radius: var(--border-radius-large, 10px);
84
+ padding: 12px;
85
+ margin-bottom: 12px;
86
+ }
87
+
88
+ .cn-item-card:last-child {
89
+ margin-bottom: 0;
90
+ }
91
+
92
+ .cn-item-card__header {
93
+ display: flex;
94
+ align-items: center;
95
+ justify-content: space-between;
96
+ }
97
+
98
+ .cn-item-card__title-row {
99
+ display: flex;
100
+ align-items: center;
101
+ gap: 8px;
102
+ min-width: 0;
103
+ flex: 1;
104
+ }
105
+
106
+ .cn-item-card__title-content {
107
+ display: flex;
108
+ flex-direction: column;
109
+ min-width: 0;
110
+ }
111
+
112
+ .cn-item-card__title {
113
+ margin: 0;
114
+ font-size: 1em;
115
+ font-weight: 600;
116
+ color: var(--color-main-text);
117
+ overflow: hidden;
118
+ text-overflow: ellipsis;
119
+ white-space: nowrap;
120
+ }
121
+
122
+ .cn-item-card__subtitle {
123
+ font-size: 0.85em;
124
+ color: var(--color-text-maxcontrast);
125
+ }
126
+
127
+ .cn-item-card__actions {
128
+ flex-shrink: 0;
129
+ }
130
+
131
+ .cn-item-card__content {
132
+ margin-top: 8px;
133
+ }
134
+ </style>
@@ -0,0 +1 @@
1
+ export { default as CnItemCard } from './CnItemCard.vue'
@@ -0,0 +1,312 @@
1
+ <!--
2
+ CnJsonViewer — Syntax-highlighted code viewer/editor powered by CodeMirror.
3
+
4
+ Supports multiple languages (JSON, XML, HTML, plain text) with optional
5
+ auto-detection. Use `readOnly` for display-only mode.
6
+ -->
7
+ <template>
8
+ <div class="cn-json-viewer">
9
+ <div :class="['cn-json-viewer__codemirror', isDark ? 'cn-json-viewer__codemirror--dark' : 'cn-json-viewer__codemirror--light']">
10
+ <CodeMirror
11
+ v-model="localValue"
12
+ :basic="true"
13
+ :placeholder="resolvedLanguage === 'json' ? '{ &quot;key&quot;: &quot;value&quot; }' : ''"
14
+ :dark="isDark"
15
+ :readonly="readOnly"
16
+ :linter="linterExtension"
17
+ :lang="langExtension"
18
+ :extensions="editorExtensions"
19
+ :tab-size="2"
20
+ :style="{ height }" />
21
+ <NcButton
22
+ v-if="!readOnly && resolvedLanguage === 'json'"
23
+ class="cn-json-viewer__format-btn"
24
+ type="secondary"
25
+ size="small"
26
+ @click="formatJson">
27
+ Format JSON
28
+ </NcButton>
29
+ </div>
30
+ <span v-if="shouldShowError" class="cn-json-viewer__error">
31
+ {{ resolvedErrorText }}
32
+ </span>
33
+ </div>
34
+ </template>
35
+
36
+ <script>
37
+ import { NcButton } from '@nextcloud/vue'
38
+ import CodeMirror from 'vue-codemirror6'
39
+ import { githubLight, githubDark } from '@uiw/codemirror-theme-github'
40
+ import { json as jsonLang, jsonParseLinter as jsonLinter } from '@codemirror/lang-json'
41
+ import { xml as xmlLang } from '@codemirror/lang-xml'
42
+ import { html as htmlLang } from '@codemirror/lang-html'
43
+ import { getTheme } from '../../utils/getTheme.js'
44
+
45
+ /**
46
+ * CnJsonViewer — Syntax-highlighted code viewer/editor.
47
+ *
48
+ * Wraps CodeMirror 6 with support for JSON, XML, HTML, and plain text.
49
+ * Includes syntax highlighting, and optional formatting/validation for JSON.
50
+ * Use `readOnly` for display-only mode.
51
+ *
52
+ * @example Read-only JSON display (default)
53
+ * <CnJsonViewer :value="jsonString" :read-only="true" />
54
+ *
55
+ * @example Auto-detect language from content
56
+ * <CnJsonViewer :value="responseBody" :read-only="true" language="auto" />
57
+ *
58
+ * @example Explicit XML mode
59
+ * <CnJsonViewer :value="xmlString" :read-only="true" language="xml" />
60
+ *
61
+ * @example Editable JSON with custom height
62
+ * <CnJsonViewer :value="jsonString" height="500px" @update:value="onUpdate" />
63
+ */
64
+ export default {
65
+ name: 'CnJsonViewer',
66
+
67
+ components: {
68
+ NcButton,
69
+ CodeMirror,
70
+ },
71
+
72
+ props: {
73
+ /** JSON string to display or edit */
74
+ value: { type: String, default: '' },
75
+ /** When true, the editor is non-editable and hides format button and validation */
76
+ readOnly: { type: Boolean, default: false },
77
+ /** CSS height for the editor container */
78
+ height: { type: String, default: '300px' },
79
+ /**
80
+ * Content language for syntax highlighting.
81
+ * - 'auto': Auto-detect from content (JSON → xml → text) (default)
82
+ * - 'json': JSON with validation and formatting
83
+ * - 'xml': XML/HTML tag highlighting
84
+ * - 'html': Alias for XML highlighting
85
+ * - 'text': Plain text, no highlighting
86
+ */
87
+ language: {
88
+ type: String,
89
+ default: 'auto',
90
+ validator: (v) => ['json', 'xml', 'html', 'text', 'auto'].includes(v),
91
+ },
92
+ /**
93
+ * Custom text for the error banner rendered below the editor.
94
+ * - `null` (default): the built-in "Invalid JSON format" banner renders
95
+ * whenever `language === 'json'` and the content fails to parse.
96
+ * - Any string: the caller owns the banner — it renders when this
97
+ * string is non-empty, and is hidden when empty. Use this to surface
98
+ * a richer parse error (e.g. the exception message).
99
+ */
100
+ errorText: { type: String, default: null },
101
+ },
102
+
103
+ data() {
104
+ return {
105
+ githubLight,
106
+ githubDark,
107
+ }
108
+ },
109
+
110
+ computed: {
111
+ localValue: {
112
+ get() { return this.value },
113
+ set(v) { this.$emit('update:value', v) },
114
+ },
115
+ isDark: {
116
+ get() { return getTheme() === 'dark' },
117
+ },
118
+ theme: {
119
+ get() { return this.isDark ? githubDark : githubLight },
120
+ },
121
+ /**
122
+ * Resolve 'auto' language to a concrete language based on content.
123
+ * @return {string} Resolved language: 'json', 'xml', or 'text'
124
+ */
125
+ resolvedLanguage() {
126
+ if (this.language !== 'auto') {
127
+ return this.language
128
+ }
129
+ const trimmed = (this.value || '').trim()
130
+ if (!trimmed) return 'text'
131
+ try {
132
+ JSON.parse(trimmed)
133
+ return 'json'
134
+ } catch {
135
+ // not JSON
136
+ }
137
+ if (trimmed.charAt(0) === '<' && trimmed.includes('>')) {
138
+ // Detect HTML by doctype or common HTML tags
139
+ if (/<!doctype\s+html/i.test(trimmed) || /<(?:html|head|body|div|span|p|a|script|style|link|meta|form|input|button|table|ul|ol|li|h[1-6]|img|nav|header|footer|main|section|article)\b/i.test(trimmed)) {
140
+ return 'html'
141
+ }
142
+ return 'xml'
143
+ }
144
+ return 'text'
145
+ },
146
+ /**
147
+ * CodeMirror language extension based on resolved language.
148
+ * @return {object|null} Language extension or null for plain text
149
+ */
150
+ langExtension() {
151
+ switch (this.resolvedLanguage) {
152
+ case 'json':
153
+ return jsonLang()
154
+ case 'html':
155
+ return htmlLang()
156
+ case 'xml':
157
+ return xmlLang()
158
+ case 'text':
159
+ default:
160
+ return null
161
+ }
162
+ },
163
+ /**
164
+ * CodeMirror linter extension (only active for JSON in edit mode).
165
+ * @return {object|null} Linter extension or null
166
+ */
167
+ linterExtension() {
168
+ if (this.readOnly) return null
169
+ if (this.resolvedLanguage === 'json') return jsonLinter()
170
+ return null
171
+ },
172
+ /**
173
+ * Combined CodeMirror extensions array.
174
+ * @return {Array} Extensions including theme and optional language
175
+ */
176
+ editorExtensions() {
177
+ const exts = [this.theme]
178
+ if (this.langExtension) exts.push(this.langExtension)
179
+ return exts
180
+ },
181
+ /**
182
+ * Error text displayed in the banner. Caller-provided `errorText` wins;
183
+ * otherwise falls back to the built-in "Invalid JSON format" message.
184
+ * @return {string} Message to show.
185
+ */
186
+ resolvedErrorText() {
187
+ if (this.errorText !== null) return this.errorText
188
+ return 'Invalid JSON format'
189
+ },
190
+ /**
191
+ * Whether to show the error banner.
192
+ * - If `errorText` is supplied, the caller controls visibility via its
193
+ * emptiness.
194
+ * - Otherwise, show iff the content is editable JSON and fails to parse.
195
+ * @return {boolean} Visibility flag.
196
+ */
197
+ shouldShowError() {
198
+ if (this.errorText !== null) return this.errorText !== ''
199
+ return !this.readOnly
200
+ && this.resolvedLanguage === 'json'
201
+ && !this.isValidJson(this.value)
202
+ },
203
+ },
204
+
205
+ methods: {
206
+ /**
207
+ * Format the current JSON value with 2-space indentation.
208
+ * Emits 'update:value' with the formatted string and 'format' with the parsed object.
209
+ */
210
+ formatJson() {
211
+ try {
212
+ if (this.value) {
213
+ const parsed = JSON.parse(this.value)
214
+ this.$emit('update:value', JSON.stringify(parsed, null, 2))
215
+ this.$emit('format', parsed)
216
+ }
217
+ } catch {
218
+ // Keep invalid JSON as-is
219
+ }
220
+ },
221
+
222
+ /**
223
+ * Check if a string is valid JSON.
224
+ * @param {string} str - String to validate
225
+ * @return {boolean} True if valid JSON
226
+ */
227
+ isValidJson(str) {
228
+ if (!str || !str.trim()) return false
229
+ try {
230
+ JSON.parse(str)
231
+ return true
232
+ } catch {
233
+ return false
234
+ }
235
+ },
236
+ },
237
+ }
238
+ </script>
239
+
240
+ <style scoped>
241
+ .cn-json-viewer {
242
+ display: flex;
243
+ flex-direction: column;
244
+ gap: 8px;
245
+ }
246
+
247
+ .cn-json-viewer__codemirror {
248
+ position: relative;
249
+ }
250
+
251
+ .cn-json-viewer__codemirror :deep(.cm-editor) {
252
+ height: 100%;
253
+ outline: none !important;
254
+ }
255
+
256
+ .cn-json-viewer__codemirror :deep(.cm-scroller) {
257
+ overflow: auto;
258
+ }
259
+
260
+ .cn-json-viewer__codemirror :deep(.cm-content) {
261
+ border-radius: 0 !important;
262
+ border: none !important;
263
+ }
264
+
265
+ .cn-json-viewer__codemirror--light > .vue-codemirror {
266
+ border: 1px dotted silver;
267
+ }
268
+
269
+ .cn-json-viewer__codemirror--dark > .vue-codemirror {
270
+ border: 1px dotted grey;
271
+ }
272
+
273
+ /* Text cursor */
274
+ .cn-json-viewer__codemirror :deep(.cm-content) * {
275
+ cursor: text !important;
276
+ }
277
+
278
+ /* PATCH SELECTION COLOR - default selection system does not work */
279
+ /* Selection background — CodeMirror uses .cm-selectionBackground instead of ::selection */
280
+ .cn-json-viewer__codemirror--light :deep(.cm-selectionBackground) {
281
+ background: #3390ff !important;
282
+ }
283
+
284
+ .cn-json-viewer__codemirror--light :deep(.cm-selectionBackground) + .cm-selectionBackground,
285
+ .cn-json-viewer__codemirror--light :deep(.cm-line ::selection) {
286
+ color: white !important;
287
+ }
288
+
289
+ .cn-json-viewer__codemirror--dark :deep(.cm-selectionBackground) {
290
+ background: #3390ff !important;
291
+ }
292
+
293
+ /* Selected text color */
294
+ .cn-json-viewer__codemirror--light :deep(.cm-content ::selection) {
295
+ background: #3390ff !important;
296
+ color: white !important;
297
+ }
298
+
299
+ .cn-json-viewer__codemirror--dark :deep(.cm-content ::selection) {
300
+ background: #3390ff !important;
301
+ color: white !important;
302
+ }
303
+
304
+ .cn-json-viewer__format-btn {
305
+ margin-top: 8px;
306
+ }
307
+
308
+ .cn-json-viewer__error {
309
+ color: var(--color-error);
310
+ font-size: 14px;
311
+ }
312
+ </style>
@@ -0,0 +1 @@
1
+ export { default as CnJsonViewer } from './CnJsonViewer.vue'