@conduction/nextcloud-vue 2.62.0 → 2.64.0

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 (209) hide show
  1. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue.js +10 -0
  2. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue.js.map +1 -0
  3. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue2.js +189 -0
  4. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue2.js.map +1 -0
  5. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue3.js +72 -0
  6. package/dist/esm/components/CnAdminActionCard/CnAdminActionCard.vue3.js.map +1 -0
  7. package/dist/esm/components/CnAppNav/CnAppNav.vue2.js +425 -39
  8. package/dist/esm/components/CnAppNav/CnAppNav.vue2.js.map +1 -1
  9. package/dist/esm/components/CnAppNav/CnAppNav.vue3.js +119 -42
  10. package/dist/esm/components/CnAppNav/CnAppNav.vue3.js.map +1 -1
  11. package/dist/esm/components/CnAppRoot/CnAppRoot.vue2.js +186 -9
  12. package/dist/esm/components/CnAppRoot/CnAppRoot.vue2.js.map +1 -1
  13. package/dist/esm/components/CnAppRoot/CnAppRoot.vue3.js +65 -42
  14. package/dist/esm/components/CnAppRoot/CnAppRoot.vue3.js.map +1 -1
  15. package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue2.js +61 -16
  16. package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue2.js.map +1 -1
  17. package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue3.js.map +1 -1
  18. package/dist/esm/components/CnAuditTrailWidget/CnAuditTrailWidget.vue2.js +20 -0
  19. package/dist/esm/components/CnAuditTrailWidget/CnAuditTrailWidget.vue2.js.map +1 -1
  20. package/dist/esm/components/CnAuditTrailWidget/CnAuditTrailWidget.vue3.js +3 -2
  21. package/dist/esm/components/CnAuditTrailWidget/CnAuditTrailWidget.vue3.js.map +1 -1
  22. package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js +33 -2
  23. package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js.map +1 -1
  24. package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js.map +1 -1
  25. package/dist/esm/components/CnChoiceCards/CnChoiceCards.vue2.js.map +1 -1
  26. package/dist/esm/components/CnChoiceCards/CnChoiceCards.vue3.js +53 -37
  27. package/dist/esm/components/CnChoiceCards/CnChoiceCards.vue3.js.map +1 -1
  28. package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue2.js +29 -0
  29. package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue2.js.map +1 -1
  30. package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue3.js +152 -135
  31. package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue3.js.map +1 -1
  32. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue.js +10 -0
  33. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue.js.map +1 -0
  34. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue2.js +293 -0
  35. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue2.js.map +1 -0
  36. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue3.js +189 -0
  37. package/dist/esm/components/CnDataTable/CnColumnFilterPopover.vue3.js.map +1 -0
  38. package/dist/esm/components/CnDataTable/CnDataTable.vue2.js +253 -9
  39. package/dist/esm/components/CnDataTable/CnDataTable.vue2.js.map +1 -1
  40. package/dist/esm/components/CnDataTable/CnDataTable.vue3.js +126 -50
  41. package/dist/esm/components/CnDataTable/CnDataTable.vue3.js.map +1 -1
  42. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js +66 -14
  43. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js.map +1 -1
  44. package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js +23 -14
  45. package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js.map +1 -1
  46. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue2.js.map +1 -1
  47. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue3.js +2 -1
  48. package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue3.js.map +1 -1
  49. package/dist/esm/components/CnFieldHelper/CnFieldHelper.vue2.js +3 -1
  50. package/dist/esm/components/CnFieldHelper/CnFieldHelper.vue2.js.map +1 -1
  51. package/dist/esm/components/CnFieldHelper/CnFieldHelper.vue3.js +1 -1
  52. package/dist/esm/components/CnFieldHelper/CnFieldHelper.vue3.js.map +1 -1
  53. package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js +234 -9
  54. package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js.map +1 -1
  55. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js +96 -57
  56. package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
  57. package/dist/esm/components/CnHeaderWidget/CnHeaderWidget.vue2.js +81 -4
  58. package/dist/esm/components/CnHeaderWidget/CnHeaderWidget.vue2.js.map +1 -1
  59. package/dist/esm/components/CnHeaderWidget/CnHeaderWidget.vue3.js +22 -5
  60. package/dist/esm/components/CnHeaderWidget/CnHeaderWidget.vue3.js.map +1 -1
  61. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +81 -2
  62. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
  63. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js +7 -3
  64. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
  65. package/dist/esm/components/CnIndexPage/selfModeActions.js +3 -3
  66. package/dist/esm/components/CnIndexPage/selfModeActions.js.map +1 -1
  67. package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue2.js +41 -2
  68. package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue2.js.map +1 -1
  69. package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue3.js +8 -3
  70. package/dist/esm/components/CnObjectListWidget/CnObjectListWidget.vue3.js.map +1 -1
  71. package/dist/esm/components/CnResourceSelect/CnResourceSelect.vue2.js +121 -12
  72. package/dist/esm/components/CnResourceSelect/CnResourceSelect.vue2.js.map +1 -1
  73. package/dist/esm/components/CnResourceSelect/CnResourceSelect.vue3.js +3 -1
  74. package/dist/esm/components/CnResourceSelect/CnResourceSelect.vue3.js.map +1 -1
  75. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue2.js +326 -1
  76. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue2.js.map +1 -1
  77. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue3.js +112 -26
  78. package/dist/esm/components/CnSetupWizard/CnSetupWizard.vue3.js.map +1 -1
  79. package/dist/esm/components/CnStagesWidget/CnStagesWidget.vue2.js +63 -2
  80. package/dist/esm/components/CnStagesWidget/CnStagesWidget.vue2.js.map +1 -1
  81. package/dist/esm/components/CnStagesWidget/CnStagesWidget.vue3.js +96 -37
  82. package/dist/esm/components/CnStagesWidget/CnStagesWidget.vue3.js.map +1 -1
  83. package/dist/esm/components/CnStagesWidget/stagesModel.js +5 -2
  84. package/dist/esm/components/CnStagesWidget/stagesModel.js.map +1 -1
  85. package/dist/esm/components/CnStatWidget/CnStatWidget.vue2.js +52 -2
  86. package/dist/esm/components/CnStatWidget/CnStatWidget.vue2.js.map +1 -1
  87. package/dist/esm/components/CnStatWidget/CnStatWidget.vue3.js +6 -6
  88. package/dist/esm/components/CnStatWidget/CnStatWidget.vue3.js.map +1 -1
  89. package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue2.js +14 -2
  90. package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue2.js.map +1 -1
  91. package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue3.js +2 -1
  92. package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue3.js.map +1 -1
  93. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue.js +10 -0
  94. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue.js.map +1 -0
  95. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue2.js +337 -0
  96. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue2.js.map +1 -0
  97. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue3.js +102 -0
  98. package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue3.js.map +1 -0
  99. package/dist/esm/components/CnTimelineWidget/dashboardRegistration.js +34 -0
  100. package/dist/esm/components/CnTimelineWidget/dashboardRegistration.js.map +1 -0
  101. package/dist/esm/components/CnWalkthrough/CnWalkthrough.vue2.js +131 -8
  102. package/dist/esm/components/CnWalkthrough/CnWalkthrough.vue2.js.map +1 -1
  103. package/dist/esm/components/CnWalkthrough/CnWalkthrough.vue3.js +40 -38
  104. package/dist/esm/components/CnWalkthrough/CnWalkthrough.vue3.js.map +1 -1
  105. package/dist/esm/components/CnWidgetGrid/builtInWidgets.js +8 -6
  106. package/dist/esm/components/CnWidgetGrid/builtInWidgets.js.map +1 -1
  107. package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js +1 -0
  108. package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js.map +1 -1
  109. package/dist/esm/components/CnWidgetWrapper/CnWidgetWrapper.vue2.js +73 -1
  110. package/dist/esm/components/CnWidgetWrapper/CnWidgetWrapper.vue2.js.map +1 -1
  111. package/dist/esm/components/CnWidgetWrapper/CnWidgetWrapper.vue3.js +14 -2
  112. package/dist/esm/components/CnWidgetWrapper/CnWidgetWrapper.vue3.js.map +1 -1
  113. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue2.js +19 -0
  114. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue2.js.map +1 -1
  115. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue3.js +1 -1
  116. package/dist/esm/components/CnWizardDialog/CnWizardDialog.vue3.js.map +1 -1
  117. package/dist/esm/composables/useDependencyCheck.js +65 -0
  118. package/dist/esm/composables/useDependencyCheck.js.map +1 -0
  119. package/dist/esm/composables/useWalkthrough.js +218 -6
  120. package/dist/esm/composables/useWalkthrough.js.map +1 -1
  121. package/dist/esm/index.js +2 -0
  122. package/dist/esm/index.js.map +1 -1
  123. package/dist/esm/l10n/en.json.js +45 -1
  124. package/dist/esm/l10n/en.json.js.map +1 -1
  125. package/dist/esm/l10n/nl.json.js +45 -1
  126. package/dist/esm/l10n/nl.json.js.map +1 -1
  127. package/dist/esm/nextcloud-vue.css +780 -81
  128. package/dist/esm/store/useObjectStore.js +8 -0
  129. package/dist/esm/store/useObjectStore.js.map +1 -1
  130. package/dist/esm/utils/columnFilters.js +311 -0
  131. package/dist/esm/utils/columnFilters.js.map +1 -0
  132. package/dist/esm/utils/groupAutocomplete.js +123 -0
  133. package/dist/esm/utils/groupAutocomplete.js.map +1 -0
  134. package/dist/esm/utils/libraryWidgetKeys.js +2 -0
  135. package/dist/esm/utils/libraryWidgetKeys.js.map +1 -1
  136. package/dist/esm/utils/pickerOptions.js +198 -0
  137. package/dist/esm/utils/pickerOptions.js.map +1 -0
  138. package/dist/esm/utils/schema.js +83 -7
  139. package/dist/esm/utils/schema.js.map +1 -1
  140. package/dist/esm/utils/schemaRefSlug.js +19 -3
  141. package/dist/esm/utils/schemaRefSlug.js.map +1 -1
  142. package/dist/esm/utils/timelineEvents.js +174 -0
  143. package/dist/esm/utils/timelineEvents.js.map +1 -0
  144. package/dist/esm/utils/validateManifestV2.compiled.js +2 -2
  145. package/dist/esm/utils/validateManifestV2.compiled.js.map +1 -1
  146. package/dist/esm/utils/walkthroughSignals.js +88 -0
  147. package/dist/esm/utils/walkthroughSignals.js.map +1 -0
  148. package/dist/nextcloud-vue.cjs.js +13088 -7937
  149. package/dist/nextcloud-vue.cjs.js.map +2 -2
  150. package/dist/nextcloud-vue.css +780 -81
  151. package/l10n/en.json +45 -0
  152. package/l10n/nl.json +45 -0
  153. package/package.json +1 -1
  154. package/src/components/CnAdminActionCard/CnAdminActionCard.vue +234 -0
  155. package/src/components/CnAdminActionCard/index.js +4 -0
  156. package/src/components/CnAppNav/CnAppNav.vue +568 -43
  157. package/src/components/CnAppRoot/CnAppRoot.md +4 -0
  158. package/src/components/CnAppRoot/CnAppRoot.vue +223 -16
  159. package/src/components/CnAuditTrailCard/CnAuditTrailCard.vue +61 -16
  160. package/src/components/CnAuditTrailWidget/CnAuditTrailWidget.vue +22 -1
  161. package/src/components/CnCellRenderer/CnCellRenderer.vue +33 -2
  162. package/src/components/CnChoiceCards/CnChoiceCards.vue +56 -31
  163. package/src/components/CnDashboardPage/CnDashboardPage.vue +45 -4
  164. package/src/components/CnDataTable/CnColumnFilterPopover.vue +524 -0
  165. package/src/components/CnDataTable/CnDataTable.md +3 -0
  166. package/src/components/CnDataTable/CnDataTable.vue +305 -5
  167. package/src/components/CnDetailPage/CnDetailPage.md +4 -0
  168. package/src/components/CnDetailPage/CnDetailPage.vue +60 -1
  169. package/src/components/CnDetailWidgetHost/CnDetailWidgetHost.vue +2 -2
  170. package/src/components/CnFieldHelper/CnFieldHelper.vue +4 -2
  171. package/src/components/CnFormDialog/CnFormDialog.vue +290 -31
  172. package/src/components/CnHeaderWidget/CnHeaderWidget.vue +116 -6
  173. package/src/components/CnIndexPage/CnIndexPage.vue +87 -4
  174. package/src/components/CnIndexPage/selfModeActions.js +3 -3
  175. package/src/components/CnObjectListWidget/CnObjectListWidget.vue +46 -2
  176. package/src/components/CnResourceSelect/CnResourceSelect.vue +123 -12
  177. package/src/components/CnSetupWizard/CnSetupWizard.vue +392 -3
  178. package/src/components/CnStagesWidget/CnStagesWidget.vue +180 -2
  179. package/src/components/CnStagesWidget/stagesModel.js +5 -2
  180. package/src/components/CnStatWidget/CnStatWidget.vue +57 -3
  181. package/src/components/CnTabsWidget/CnTabsWidget.vue +15 -2
  182. package/src/components/CnTimelineWidget/CnTimelineWidget.vue +477 -0
  183. package/src/components/CnTimelineWidget/dashboardRegistration.js +32 -0
  184. package/src/components/CnTimelineWidget/index.js +4 -0
  185. package/src/components/CnWalkthrough/CnWalkthrough.vue +143 -10
  186. package/src/components/CnWidgetGrid/builtInWidgets.js +2 -0
  187. package/src/components/CnWidgetGrid/registerDashboardWidgets.js +1 -0
  188. package/src/components/CnWidgetWrapper/CnWidgetWrapper.md +4 -0
  189. package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +107 -1
  190. package/src/components/CnWizardDialog/CnWizardDialog.vue +20 -1
  191. package/src/components/index.js +2 -0
  192. package/src/composables/useDependencyCheck.js +61 -0
  193. package/src/composables/useWalkthrough.js +217 -5
  194. package/src/css/dashboard.css +49 -0
  195. package/src/css/detail-page.css +29 -4
  196. package/src/css/kpi-card.css +24 -1
  197. package/src/css/table.css +99 -6
  198. package/src/index.js +2 -0
  199. package/src/schemas/app-manifest-v2.schema.json +135 -3
  200. package/src/store/useObjectStore.js +8 -0
  201. package/src/utils/columnFilters.js +324 -0
  202. package/src/utils/groupAutocomplete.js +119 -0
  203. package/src/utils/libraryWidgetKeys.js +2 -0
  204. package/src/utils/pickerOptions.js +194 -0
  205. package/src/utils/schema.js +83 -7
  206. package/src/utils/schemaRefSlug.js +19 -3
  207. package/src/utils/timelineEvents.js +171 -0
  208. package/src/utils/validateManifestV2.compiled.js +2 -2
  209. package/src/utils/walkthroughSignals.js +94 -0
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Nextcloud group search for the schema-driven form's group picker
3
+ * (a property marked `format: 'nc-group'` or `referenceType: 'nextcloud-group'`).
4
+ *
5
+ * Asks the core autocomplete OCS endpoint for groups first: every signed-in
6
+ * user may call it, and it returns the group's display name. The provisioning
7
+ * endpoint `cloud/groups` is the fallback; it also answers non-admins, but it
8
+ * returns only group ids, so the id doubles as the label there.
9
+ *
10
+ * Options are `{ id: <gid>, label: <display name> }`: the form stores the gid.
11
+ *
12
+ * @module utils/groupAutocomplete
13
+ */
14
+
15
+ import axios from '@nextcloud/axios'
16
+ import { generateOcsUrl } from '@nextcloud/router'
17
+
18
+ const OCS_HEADERS = {
19
+ 'OCS-APIRequest': 'true',
20
+ Accept: 'application/json',
21
+ }
22
+
23
+ /**
24
+ * Read the `ocs.data` payload, tolerating a bare body.
25
+ *
26
+ * @param {object} response An axios response.
27
+ * @return {unknown} The data.
28
+ */
29
+ function ocsData(response) {
30
+ const body = response && response.data
31
+ return body && body.ocs ? body.ocs.data : body
32
+ }
33
+
34
+ /**
35
+ * Map one autocomplete suggestion to an option, keeping only groups.
36
+ *
37
+ * @param {object} suggestion An autocomplete suggestion.
38
+ * @return {{id: string, label: string}|null} The option, or null when it is not a group.
39
+ */
40
+ function toGroupOption(suggestion) {
41
+ if (!suggestion || typeof suggestion !== 'object') {
42
+ return null
43
+ }
44
+ const isGroup = suggestion.source === 'groups'
45
+ || suggestion.shareType === 1
46
+ || (suggestion.value && suggestion.value.shareType === 1)
47
+ if (!isGroup) {
48
+ return null
49
+ }
50
+ const gid = suggestion.id || (suggestion.value && suggestion.value.shareWith)
51
+ if (gid === undefined || gid === null || gid === '') {
52
+ return null
53
+ }
54
+ return { id: String(gid), label: suggestion.label || String(gid) }
55
+ }
56
+
57
+ /**
58
+ * Search Nextcloud groups by name or id. Fails soft: an error yields `[]`.
59
+ *
60
+ * @spec openspec/changes/form-pickers-from-schema/specs/schema-utilities/spec.md
61
+ * @param {string} [query] The search term (empty loads a first page).
62
+ * @param {object} [options] Tuning options.
63
+ * @param {number} [options.limit] Max results (default 25).
64
+ * @return {Promise<Array<{id: string, label: string}>>} Picker options.
65
+ */
66
+ export async function searchNextcloudGroups(query = '', options = {}) {
67
+ const { limit = 25 } = options
68
+ try {
69
+ const response = await axios.get(generateOcsUrl('core/autocomplete/get'), {
70
+ headers: OCS_HEADERS,
71
+ params: {
72
+ search: query || '',
73
+ itemType: ' ',
74
+ itemId: ' ',
75
+ 'shareTypes[]': 1,
76
+ limit,
77
+ },
78
+ })
79
+ const list = ocsData(response)
80
+ const groups = (Array.isArray(list) ? list : [])
81
+ .map(toGroupOption)
82
+ .filter((opt) => opt !== null)
83
+ if (groups.length > 0) {
84
+ return groups
85
+ }
86
+ } catch {
87
+ // Fall through to the provisioning endpoint.
88
+ }
89
+ try {
90
+ const response = await axios.get(generateOcsUrl('cloud/groups'), {
91
+ headers: OCS_HEADERS,
92
+ params: { search: query || '', limit },
93
+ })
94
+ const data = ocsData(response)
95
+ const gids = data && Array.isArray(data.groups) ? data.groups : []
96
+ return gids
97
+ .filter((gid) => typeof gid === 'string' && gid !== '')
98
+ .map((gid) => ({ id: gid, label: gid }))
99
+ } catch {
100
+ return []
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Resolve a stored gid to `{ id, label }` for edit-mode display. Falls back
106
+ * to the gid itself when the name cannot be looked up.
107
+ *
108
+ * @spec openspec/changes/form-pickers-from-schema/specs/schema-utilities/spec.md
109
+ * @param {string} gid The stored group id.
110
+ * @return {Promise<{id: string, label: string}>} The resolved option.
111
+ */
112
+ export async function resolveNextcloudGroup(gid) {
113
+ const fallback = { id: String(gid), label: String(gid) }
114
+ if (gid === undefined || gid === null || gid === '') {
115
+ return fallback
116
+ }
117
+ const results = await searchNextcloudGroups(String(gid))
118
+ return results.find((opt) => opt.id === String(gid)) || fallback
119
+ }
@@ -67,6 +67,7 @@ export const BUILT_IN_WIDGET_KEYS = Object.freeze([
67
67
  'integration',
68
68
  'banner',
69
69
  'audit-trail',
70
+ 'timeline',
70
71
  'header',
71
72
  'text',
72
73
  'divider',
@@ -131,6 +132,7 @@ export const DASHBOARD_CATALOG_WIDGET_KEYS = Object.freeze([
131
132
  'tasks',
132
133
  'text',
133
134
  'tile',
135
+ 'timeline',
134
136
  'video',
135
137
  'week-strip',
136
138
  'workspace-filter',
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Option lists for the language and time zone pickers, and the defaults a
3
+ * schema can ask for with `x-default`.
4
+ *
5
+ * Both pickers store a code (`nl`, `Europe/Amsterdam`) and show a label in
6
+ * the user's own language, so a person picks "Nederlands" and the record
7
+ * stores `nl`.
8
+ *
9
+ * @module utils/pickerOptions
10
+ */
11
+
12
+ import { getLanguage } from '@nextcloud/l10n'
13
+
14
+ /**
15
+ * ISO 639-1 language codes. `Intl` has no list of languages, so the codes
16
+ * live here; the labels come from `Intl.DisplayNames` at runtime.
17
+ *
18
+ * @type {string[]}
19
+ */
20
+ export const LANGUAGE_CODES = (''
21
+ + 'aa ab af ak am an ar as av ay az ba be bg bi bm bn bo br bs '
22
+ + 'ca ce ch co cr cs cu cv cy da de dv dz ee el en eo es et eu '
23
+ + 'fa ff fi fj fo fr fy ga gd gl gn gu gv ha he hi ho hr ht hu '
24
+ + 'hy hz ia id ie ig ii ik io is it iu ja jv ka kg ki kj kk kl '
25
+ + 'km kn ko kr ks ku kv kw ky la lb lg li ln lo lt lu lv mg mh '
26
+ + 'mi mk ml mn mr ms mt my na nb nd ne ng nl nn no nr nv ny oc '
27
+ + 'oj om or os pa pi pl ps pt qu rm rn ro ru rw sa sc sd se sg '
28
+ + 'si sk sl sm sn so sq sr ss st su sv sw ta te tg th ti tk tl '
29
+ + 'tn to tr ts tt tw ty ug uk ur uz ve vi vo wa wo xh yi yo za '
30
+ + 'zh zu'
31
+ ).split(' ')
32
+
33
+ /**
34
+ * A small fallback for runtimes without `Intl.supportedValuesOf`.
35
+ *
36
+ * @type {string[]}
37
+ */
38
+ const FALLBACK_TIMEZONES = 'UTC Europe/Amsterdam Europe/Berlin Europe/Brussels Europe/London Europe/Paris America/New_York America/Chicago America/Los_Angeles Asia/Tokyo Australia/Sydney'.split(' ')
39
+
40
+ /**
41
+ * The user's Nextcloud language as a BCP 47 tag (`en_GB` becomes `en-GB`).
42
+ *
43
+ * @return {string} The tag, `en` when Nextcloud reports nothing.
44
+ */
45
+ export function currentLanguageTag() {
46
+ let lang
47
+ try {
48
+ lang = getLanguage()
49
+ } catch {
50
+ lang = ''
51
+ }
52
+ return String(lang || 'en').replace(/_/g, '-')
53
+ }
54
+
55
+ /**
56
+ * The browser's time zone (IANA id).
57
+ *
58
+ * @return {string} The time zone, `UTC` when the runtime does not say.
59
+ */
60
+ export function currentTimezone() {
61
+ try {
62
+ return Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC'
63
+ } catch {
64
+ return 'UTC'
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Cached option lists, keyed by display language. Stable identity matters:
70
+ * the form's select matches the chosen option by reference.
71
+ *
72
+ * @type {Map<string, {codes: string[], labels: object}>}
73
+ */
74
+ const languageCache = new Map()
75
+
76
+ /**
77
+ * The language picker's codes and labels, labelled in `displayLanguage`.
78
+ *
79
+ * @spec openspec/changes/form-pickers-from-schema/specs/schema-utilities/spec.md
80
+ * @param {string} [displayLanguage] BCP 47 tag the labels are written in; defaults to the user's language.
81
+ * @return {{codes: string[], labels: object}} Codes sorted by label, and `{ code: label }`.
82
+ */
83
+ export function languageOptions(displayLanguage) {
84
+ const locale = displayLanguage || currentLanguageTag()
85
+ if (languageCache.has(locale)) {
86
+ return languageCache.get(locale)
87
+ }
88
+ let names
89
+ try {
90
+ names = new Intl.DisplayNames([locale, 'en'], { type: 'language' })
91
+ } catch {
92
+ names = null
93
+ }
94
+ const labels = {}
95
+ for (const code of LANGUAGE_CODES) {
96
+ let label
97
+ try {
98
+ label = (names && names.of(code)) || code
99
+ } catch {
100
+ label = code
101
+ }
102
+ // `Intl` lower-cases some names ("nederlands" is fine in a sentence,
103
+ // not in a list); capitalise the first letter for the list.
104
+ labels[code] = label.charAt(0).toLocaleUpperCase(locale) + label.slice(1)
105
+ }
106
+ const codes = [...LANGUAGE_CODES].sort((a, b) => labels[a].localeCompare(labels[b], locale))
107
+ const result = { codes, labels }
108
+ languageCache.set(locale, result)
109
+ return result
110
+ }
111
+
112
+ /** @type {{codes: string[], labels: object}|null} */
113
+ let timezoneCache = null
114
+
115
+ /**
116
+ * The time zone picker's codes and labels (`Europe/Amsterdam` shows as
117
+ * `Europe/Amsterdam`, underscores as spaces).
118
+ *
119
+ * @spec openspec/changes/form-pickers-from-schema/specs/schema-utilities/spec.md
120
+ * @return {{codes: string[], labels: object}} IANA ids, and `{ id: label }`.
121
+ */
122
+ export function timezoneOptions() {
123
+ if (timezoneCache) {
124
+ return timezoneCache
125
+ }
126
+ let codes
127
+ try {
128
+ codes = typeof Intl.supportedValuesOf === 'function' ? Intl.supportedValuesOf('timeZone') : []
129
+ } catch {
130
+ codes = []
131
+ }
132
+ if (!codes.length) {
133
+ codes = FALLBACK_TIMEZONES
134
+ }
135
+ if (!codes.includes('UTC')) {
136
+ codes = ['UTC', ...codes]
137
+ }
138
+ const labels = {}
139
+ for (const code of codes) {
140
+ labels[code] = code.replace(/_/g, ' ')
141
+ }
142
+ timezoneCache = { codes: [...codes], labels }
143
+ return timezoneCache
144
+ }
145
+
146
+ /**
147
+ * Fit a language tag to the property's `pattern`, if it has one.
148
+ *
149
+ * A schema that stores ISO 639-1 (`^[a-z]{2}$`) cannot take `en-GB`, so the
150
+ * tag falls back to its primary subtag. Without a pattern the full tag stays.
151
+ *
152
+ * @param {string} tag A BCP 47 tag.
153
+ * @param {string|undefined} pattern The property's `pattern`.
154
+ * @return {string} The tag as the schema accepts it.
155
+ */
156
+ function fitLanguageTag(tag, pattern) {
157
+ if (!pattern) {
158
+ return tag
159
+ }
160
+ let re
161
+ try {
162
+ re = new RegExp(pattern)
163
+ } catch {
164
+ return tag
165
+ }
166
+ if (re.test(tag)) {
167
+ return tag
168
+ }
169
+ const primary = tag.split('-')[0].toLowerCase()
170
+ return re.test(primary) ? primary : tag
171
+ }
172
+
173
+ /**
174
+ * Resolve an `x-default` token to the value a NEW object starts with.
175
+ *
176
+ * - `current-language`: the user's Nextcloud language (BCP 47, fitted to the
177
+ * property's `pattern`).
178
+ * - `current-timezone`: the browser's time zone.
179
+ *
180
+ * @spec openspec/changes/form-pickers-from-schema/specs/schema-utilities/spec.md
181
+ * @param {string|null} token The `x-default` value.
182
+ * @param {object} [field] The field descriptor (reads `validation.pattern`).
183
+ * @return {string|null} The value, or null for an unknown token.
184
+ */
185
+ export function resolveDefaultToken(token, field = {}) {
186
+ if (token === 'current-language') {
187
+ const pattern = field && field.validation ? field.validation.pattern : undefined
188
+ return fitLanguageTag(currentLanguageTag(), pattern)
189
+ }
190
+ if (token === 'current-timezone') {
191
+ return currentTimezone()
192
+ }
193
+ return null
194
+ }
@@ -297,10 +297,13 @@ function truncateString(str, maxLength) {
297
297
  * surface (CnFormDialog) resolves the reference to a searchable dropdown
298
298
  * of the referenced objects (label = human name, value = UUID).
299
299
  * 4. Nextcloud user reference: `referenceType: 'nextcloud-user'` (or
300
- * `format: 'user'`/`'username'`) → `'user'`; an array of such
300
+ * `format: 'user'`/`'username'`/`'nc-user'`) → `'user'`; an array of such
301
301
  * properties → `'user-multiselect'`. CnFormDialog resolves these to a
302
302
  * searchable dropdown of real Nextcloud users (label = display name,
303
- * value = UID).
303
+ * value = UID). A Nextcloud group (`referenceType: 'nextcloud-group'` or
304
+ * `format: 'nc-group'`) → `'group'`, an array of groups →
305
+ * `'group-multiselect'`. `format: 'language'` → `'language'` and
306
+ * `format: 'timezone'` → `'timezone'` (both searchable code lists).
304
307
  * 5. Type-based: `boolean` → `'checkbox'`, `integer`/`number` → `'number'`,
305
308
  * `array` + `items.enum` → `'multiselect'`, `array` → `'tags'`
306
309
  * 6. Format-based: `date-time` → `'datetime'`, `date` → `'date'`,
@@ -368,9 +371,32 @@ function isUserProp(prop) {
368
371
  return true
369
372
  }
370
373
  const format = prop.format || ''
371
- return format === 'user' || format === 'username'
374
+ return format === 'user' || format === 'username' || format === 'nc-user'
372
375
  }
373
376
 
377
+ /**
378
+ * Whether a (single-value) schema property represents a Nextcloud group.
379
+ *
380
+ * A property is a group field when it declares `referenceType: 'nextcloud-group'`
381
+ * or `format: 'nc-group'`. CnFormDialog renders it as a searchable dropdown of
382
+ * Nextcloud groups (label = display name, value = group id).
383
+ *
384
+ * @spec openspec/changes/form-pickers-from-schema/specs/schema-utilities/spec.md
385
+ * @param {object} prop A schema property definition (or `items` for an array).
386
+ * @return {boolean} True when the property marks a Nextcloud group.
387
+ */
388
+ function isGroupProp(prop) {
389
+ if (!prop || typeof prop !== 'object') {
390
+ return false
391
+ }
392
+ return prop.referenceType === 'nextcloud-group' || prop.format === 'nc-group'
393
+ }
394
+
395
+ /**
396
+ * @spec openspec/changes/form-pickers-from-schema/specs/schema-utilities/spec.md
397
+ * @param {object} prop The schema property definition.
398
+ * @return {string} The widget identifier (see the block above).
399
+ */
374
400
  function resolveWidget(prop) {
375
401
  // Explicit widget hint takes priority
376
402
  if (prop.widget) {
@@ -409,6 +435,24 @@ function resolveWidget(prop) {
409
435
  return 'user-multiselect'
410
436
  }
411
437
 
438
+ // Nextcloud group (`format: 'nc-group'` / `referenceType: 'nextcloud-group'`):
439
+ // a searchable dropdown of groups storing the group id.
440
+ if (isGroupProp(prop)) {
441
+ return 'group'
442
+ }
443
+ if (type === 'array' && isGroupProp(prop.items)) {
444
+ return 'group-multiselect'
445
+ }
446
+
447
+ // Language and time zone codes: a searchable list instead of a free-text
448
+ // box, so a person picks "Dutch" and the record stores `nl`.
449
+ if (type === 'string' && format === 'language') {
450
+ return 'language'
451
+ }
452
+ if (type === 'string' && format === 'timezone') {
453
+ return 'timezone'
454
+ }
455
+
412
456
  // Boolean → switch/checkbox
413
457
  if (type === 'boolean') {
414
458
  return 'checkbox'
@@ -587,7 +631,8 @@ export function isTenantProperty(key, prop) {
587
631
  * @param {boolean} [options.includeReadOnly] Whether to include readOnly properties
588
632
  * @param {boolean} [options.hideTenant] Drop properties that hold the record's tenant (see `isTenantProperty`). Off by default, so a detail page still shows the tenant; CnFormDialog turns it on because nobody should be asked for it. `overrides[key].hidden === false` keeps one visible.
589
633
  * @param {(text: string) => string} [options.translate] Optional display-layer translation function applied to each field's `label` and `description`. Schema property titles/descriptions are authored in English as the canonical source; consumers pass their bound `t()` (via the injected `cnTranslate`) so the rendered field label follows the user's language. When omitted, label/description are the English source strings unchanged (pure, backward-compatible).
590
- * @return {Array<{key: string, label: string, description: string, descriptionLong: string, type: string, format: string|null, widget: string, required: boolean, readOnly: boolean, default: unknown, enum: Array|null, enumLabels: object|null, items: object|null, referenceType: string|null, referenceSemanticType: string|null, referenceSemanticApp: string|null, reference: {schema: string|number, multiple: boolean}|null, userPicker: {multiple: boolean}|null, fillFrom: object|null, validation: object, order: number}>} `description` is the inline helper text (see `splitDescription`); `descriptionLong` carries the full text when it was too long to render inline, else ''. `enumLabels` maps each raw enum value to its English display label (from the property's `x-enum-labels`), or null.
634
+ * @spec openspec/changes/form-pickers-from-schema/specs/schema-utilities/spec.md
635
+ * @return {Array<{key: string, label: string, description: string, descriptionLong: string, type: string, format: string|null, widget: string, required: boolean, readOnly: boolean, default: unknown, enum: Array|null, enumLabels: object|null, items: object|null, referenceType: string|null, referenceSemanticType: string|null, referenceSemanticApp: string|null, reference: {schema: string|number, multiple: boolean, register?: string, labelField?: string}|null, allowCreate: boolean, userPicker: {multiple: boolean}|null, groupPicker: {multiple: boolean}|null, defaultToken: string|null, fillFrom: object|null, validation: object, order: number}>} `description` is the inline helper text (see `splitDescription`); `descriptionLong` carries the property's `x-help` text when it declares one, else the full description when it was too long to render inline, else ''. `enumLabels` maps each raw enum value to its English display label (from the property's `x-enum-labels`), or null.
591
636
  */
592
637
  export function fieldsFromSchema(schema, options = {}) {
593
638
  const { exclude = [], include = null, overrides = {}, includeReadOnly = false, hideTenant = false, translate } = options
@@ -663,11 +708,19 @@ export function fieldsFromSchema(schema, options = {}) {
663
708
 
664
709
  return entries.map(([key, prop]) => {
665
710
  const description = splitDescription(prop.description ? tr(prop.description) : '')
711
+ // `x-help` is the long explanation behind the (i) popover. It always
712
+ // shows the popover, while `description` stays the short helper line.
713
+ const help = typeof prop['x-help'] === 'string' && prop['x-help'].trim() !== ''
714
+ ? tr(prop['x-help'].trim())
715
+ : ''
716
+ const labelField = prop['x-label-field']
717
+ || (prop.items && prop.items['x-label-field'])
718
+ || null
666
719
  const field = {
667
720
  key,
668
721
  label: tr(prop.title || key),
669
722
  description: description.short,
670
- descriptionLong: description.long,
723
+ descriptionLong: help || description.long,
671
724
  type: prop.type || 'string',
672
725
  format: prop.format || null,
673
726
  widget: resolveWidget(prop),
@@ -685,6 +738,10 @@ export function fieldsFromSchema(schema, options = {}) {
685
738
  required: requiredKeys.includes(key),
686
739
  readOnly: prop.readOnly || false,
687
740
  default: prop.default !== undefined ? prop.default : null,
741
+ // A default that depends on who opens the form (`x-default:
742
+ // 'current-language'` / `'current-timezone'`). Resolved by the
743
+ // consuming form on a NEW object only; never on edit.
744
+ defaultToken: typeof prop['x-default'] === 'string' ? prop['x-default'] : null,
688
745
  enum: prop.enum || null,
689
746
  // Display labels for the enum CODES, keyed by raw value. An enum
690
747
  // value is a stored contract value, not display text — several are
@@ -732,11 +789,23 @@ export function fieldsFromSchema(schema, options = {}) {
732
789
  // form's own; absent, the reference stays same-register (the form's
733
790
  // `register` prop is used). Consolidates the ad-hoc caseReference /
734
791
  // approvalDecisionId / x-mirror-of variants onto one convention.
792
+ //
793
+ // `x-label-field` names the referenced object's property that labels
794
+ // an option and that an inline create writes the typed term to
795
+ // (`reference.labelField`, default `name` at the consumer).
735
796
  reference: (normalizeRef(prop.$ref) !== null)
736
- ? { schema: normalizeRef(prop.$ref), multiple: false, ...(prop['x-external-register'] ? { register: prop['x-external-register'] } : {}) }
797
+ ? { schema: normalizeRef(prop.$ref), multiple: false, ...(prop['x-external-register'] ? { register: prop['x-external-register'] } : {}), ...(labelField ? { labelField } : {}) }
737
798
  : (prop.type === 'array' && prop.items && normalizeRef(prop.items.$ref) !== null)
738
- ? { schema: normalizeRef(prop.items.$ref), multiple: true, ...((prop.items['x-external-register'] || prop['x-external-register']) ? { register: prop.items['x-external-register'] || prop['x-external-register'] } : {}) }
799
+ ? { schema: normalizeRef(prop.items.$ref), multiple: true, ...((prop.items['x-external-register'] || prop['x-external-register']) ? { register: prop.items['x-external-register'] || prop['x-external-register'] } : {}), ...(labelField ? { labelField } : {}) }
739
800
  : null,
801
+ // Select OR create (`x-allow-create: true`, on the property or on
802
+ // its `items` for an array): the picker offers "Create" next to the
803
+ // existing objects. Only meaningful on a reference.
804
+ allowCreate: prop['x-allow-create'] === true
805
+ || (prop.type === 'array' && !!prop.items && prop.items['x-allow-create'] === true),
806
+ // Template copy (`x-fill-from: { formKey: sourceKey }`): choosing a
807
+ // referenced object copies those of its values into this form.
808
+ fillFrom: (prop['x-fill-from'] && typeof prop['x-fill-from'] === 'object') ? prop['x-fill-from'] : null,
740
809
  // Nextcloud user reference: when a property marks a NC user
741
810
  // (`referenceType: 'nextcloud-user'`, or `format: 'user'`/
742
811
  // `'username'`), tag it so CnFormDialog renders a searchable
@@ -749,6 +818,13 @@ export function fieldsFromSchema(schema, options = {}) {
749
818
  : (prop.type === 'array' && isUserProp(prop.items))
750
819
  ? { multiple: true }
751
820
  : null,
821
+ // Nextcloud group reference (`format: 'nc-group'` or
822
+ // `referenceType: 'nextcloud-group'`): the form stores the group id.
823
+ groupPicker: isGroupProp(prop)
824
+ ? { multiple: false }
825
+ : (prop.type === 'array' && isGroupProp(prop.items))
826
+ ? { multiple: true }
827
+ : null,
752
828
  // Conditional immutability (AD: x-openregister-readonly-when): a
753
829
  // property can declare it becomes read-only when another field on the
754
830
  // same object holds a given value — e.g. a hybrid app's identity
@@ -35,9 +35,14 @@
35
35
  * registers author the slug by hand for multi-word titles) folds to one
36
36
  * `-`, leading/trailing dashes trimmed.
37
37
  *
38
- * Idempotent: a value that is already a slug (`report-period`, `cohort`)
39
- * passes through unchanged, so it is always safe to route an already-correct
40
- * value through this function defensively.
38
+ * Idempotent: a value that is already a slug (`report-period`, `cohort`,
39
+ * `statusType`) passes through unchanged, so it is always safe to route an
40
+ * already-correct value through this function defensively. A slug is any
41
+ * value that starts with a lowercase letter or digit and holds only
42
+ * letters, digits and dashes; only a title (capital initial, or spaces and
43
+ * punctuation) is kebab-cased.
44
+ *
45
+ * @spec openspec/changes/zuiddrecht-pixel-gaps/specs/zuiddrecht-pixel-gaps/spec.md#requirement-a-plain-schema-slug-is-left-as-written
41
46
  *
42
47
  * A numeric schema id (OpenRegister accepts either the slug or the numeric
43
48
  * id in the objects-API path) is returned unchanged — slugifying a number
@@ -63,6 +68,17 @@ export function schemaRefSlug(ref) {
63
68
  if (tail === '') {
64
69
  return ''
65
70
  }
71
+ // A plain slug is left as written. OpenRegister matches a slug
72
+ // case-insensitively (`statusType`, `statustype` and `StatusType` all
73
+ // answer 200) but `status-type` is another slug and 404s, so a
74
+ // camelCase slug authored as a slug must not be kebab-cased. Only a
75
+ // `$ref` TITLE is: it starts with a capital (`ReportPeriod`) or carries
76
+ // spaces or punctuation (`Praktijkovereenkomst (POK)`). 2.62.0 kebab-cased
77
+ // everything and broke every camelCase slug (dossiq: statusType, caseType,
78
+ // caseObject, bezwaarDecision, bacAdviceRequest, wmsLayer, ...).
79
+ if (/^[a-z0-9][A-Za-z0-9-]*$/.test(tail)) {
80
+ return tail
81
+ }
66
82
  const kebab = tail
67
83
  // PascalCase / camelCase word boundaries: `ReportPeriod` -> `Report-Period`,
68
84
  // an acronym run followed by a new capitalised word: `HTTPServer` -> `HTTP-Server`.