@conduction/nextcloud-vue 2.59.0 → 2.61.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 (254) hide show
  1. package/dist/esm/components/CnActionsMenu/CnActionsMenu.vue2.js +14 -1
  2. package/dist/esm/components/CnActionsMenu/CnActionsMenu.vue2.js.map +1 -1
  3. package/dist/esm/components/CnActionsMenu/CnActionsMenu.vue3.js.map +1 -1
  4. package/dist/esm/components/CnAppNav/CnAppNav.vue2.js +80 -1
  5. package/dist/esm/components/CnAppNav/CnAppNav.vue2.js.map +1 -1
  6. package/dist/esm/components/CnAppNav/CnAppNav.vue3.js +46 -4
  7. package/dist/esm/components/CnAppNav/CnAppNav.vue3.js.map +1 -1
  8. package/dist/esm/components/CnBannerWidget/CnBannerWidget.vue2.js +232 -10
  9. package/dist/esm/components/CnBannerWidget/CnBannerWidget.vue2.js.map +1 -1
  10. package/dist/esm/components/CnBannerWidget/CnBannerWidget.vue3.js +79 -25
  11. package/dist/esm/components/CnBannerWidget/CnBannerWidget.vue3.js.map +1 -1
  12. package/dist/esm/components/CnBannerWidgetForm/CnBannerWidgetForm.vue2.js +42 -3
  13. package/dist/esm/components/CnBannerWidgetForm/CnBannerWidgetForm.vue2.js.map +1 -1
  14. package/dist/esm/components/CnBannerWidgetForm/CnBannerWidgetForm.vue3.js +39 -6
  15. package/dist/esm/components/CnBannerWidgetForm/CnBannerWidgetForm.vue3.js.map +1 -1
  16. package/dist/esm/components/CnBoardView/CnBoardView.vue2.js +46 -0
  17. package/dist/esm/components/CnBoardView/CnBoardView.vue2.js.map +1 -1
  18. package/dist/esm/components/CnBoardView/CnBoardView.vue3.js +11 -4
  19. package/dist/esm/components/CnBoardView/CnBoardView.vue3.js.map +1 -1
  20. package/dist/esm/components/CnBrandStripe/CnBrandStripe.vue.js +10 -0
  21. package/dist/esm/components/CnBrandStripe/CnBrandStripe.vue.js.map +1 -0
  22. package/dist/esm/components/CnBrandStripe/CnBrandStripe.vue2.js +39 -0
  23. package/dist/esm/components/CnBrandStripe/CnBrandStripe.vue2.js.map +1 -0
  24. package/dist/esm/components/CnBrandStripe/CnBrandStripe.vue3.js +16 -0
  25. package/dist/esm/components/CnBrandStripe/CnBrandStripe.vue3.js.map +1 -0
  26. package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js +117 -1
  27. package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue2.js.map +1 -1
  28. package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js +147 -89
  29. package/dist/esm/components/CnCellRenderer/CnCellRenderer.vue3.js.map +1 -1
  30. package/dist/esm/components/CnConversationThread/CnConversationThread.vue.js +10 -0
  31. package/dist/esm/components/CnConversationThread/CnConversationThread.vue.js.map +1 -0
  32. package/dist/esm/components/CnConversationThread/CnConversationThread.vue2.js +259 -0
  33. package/dist/esm/components/CnConversationThread/CnConversationThread.vue2.js.map +1 -0
  34. package/dist/esm/components/CnConversationThread/CnConversationThread.vue3.js +131 -0
  35. package/dist/esm/components/CnConversationThread/CnConversationThread.vue3.js.map +1 -0
  36. package/dist/esm/components/CnConversationThread/CnConversationWidget.vue.js +10 -0
  37. package/dist/esm/components/CnConversationThread/CnConversationWidget.vue.js.map +1 -0
  38. package/dist/esm/components/CnConversationThread/CnConversationWidget.vue2.js +116 -0
  39. package/dist/esm/components/CnConversationThread/CnConversationWidget.vue2.js.map +1 -0
  40. package/dist/esm/components/CnConversationThread/CnConversationWidget.vue3.js +24 -0
  41. package/dist/esm/components/CnConversationThread/CnConversationWidget.vue3.js.map +1 -0
  42. package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue2.js +10 -2
  43. package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue2.js.map +1 -1
  44. package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue3.js.map +1 -1
  45. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js +503 -28
  46. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js.map +1 -1
  47. package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js +303 -144
  48. package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js.map +1 -1
  49. package/dist/esm/components/CnDocumentReviewList/CnDocumentReviewList.vue.js +10 -0
  50. package/dist/esm/components/CnDocumentReviewList/CnDocumentReviewList.vue.js.map +1 -0
  51. package/dist/esm/components/CnDocumentReviewList/CnDocumentReviewList.vue2.js +237 -0
  52. package/dist/esm/components/CnDocumentReviewList/CnDocumentReviewList.vue2.js.map +1 -0
  53. package/dist/esm/components/CnDocumentReviewList/CnDocumentReviewList.vue3.js +120 -0
  54. package/dist/esm/components/CnDocumentReviewList/CnDocumentReviewList.vue3.js.map +1 -0
  55. package/dist/esm/components/CnDocumentReviewList/CnDocumentReviewWidget.vue.js +10 -0
  56. package/dist/esm/components/CnDocumentReviewList/CnDocumentReviewWidget.vue.js.map +1 -0
  57. package/dist/esm/components/CnDocumentReviewList/CnDocumentReviewWidget.vue2.js +77 -0
  58. package/dist/esm/components/CnDocumentReviewList/CnDocumentReviewWidget.vue2.js.map +1 -0
  59. package/dist/esm/components/CnDocumentReviewList/CnDocumentReviewWidget.vue3.js +27 -0
  60. package/dist/esm/components/CnDocumentReviewList/CnDocumentReviewWidget.vue3.js.map +1 -0
  61. package/dist/esm/components/CnHeaderWidget/CnHeaderWidget.vue2.js +171 -12
  62. package/dist/esm/components/CnHeaderWidget/CnHeaderWidget.vue2.js.map +1 -1
  63. package/dist/esm/components/CnHeaderWidget/CnHeaderWidget.vue3.js +15 -7
  64. package/dist/esm/components/CnHeaderWidget/CnHeaderWidget.vue3.js.map +1 -1
  65. package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm.vue2.js +37 -3
  66. package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm.vue2.js.map +1 -1
  67. package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm.vue3.js +44 -16
  68. package/dist/esm/components/CnHeaderWidgetForm/CnHeaderWidgetForm.vue3.js.map +1 -1
  69. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +132 -3
  70. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
  71. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js +6 -3
  72. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
  73. package/dist/esm/components/CnLinkCardsPage/CnLinkCardsPage.vue.js +10 -0
  74. package/dist/esm/components/CnLinkCardsPage/CnLinkCardsPage.vue.js.map +1 -0
  75. package/dist/esm/components/CnLinkCardsPage/CnLinkCardsPage.vue2.js +316 -0
  76. package/dist/esm/components/CnLinkCardsPage/CnLinkCardsPage.vue2.js.map +1 -0
  77. package/dist/esm/components/CnLinkCardsPage/CnLinkCardsPage.vue3.js +105 -0
  78. package/dist/esm/components/CnLinkCardsPage/CnLinkCardsPage.vue3.js.map +1 -0
  79. package/dist/esm/components/CnNextStepCard/CnNextStepCard.vue.js +10 -0
  80. package/dist/esm/components/CnNextStepCard/CnNextStepCard.vue.js.map +1 -0
  81. package/dist/esm/components/CnNextStepCard/CnNextStepCard.vue2.js +150 -0
  82. package/dist/esm/components/CnNextStepCard/CnNextStepCard.vue2.js.map +1 -0
  83. package/dist/esm/components/CnNextStepCard/CnNextStepCard.vue3.js +106 -0
  84. package/dist/esm/components/CnNextStepCard/CnNextStepCard.vue3.js.map +1 -0
  85. package/dist/esm/components/CnNextStepCard/CnNextStepWidget.vue.js +9 -0
  86. package/dist/esm/components/CnNextStepCard/CnNextStepWidget.vue.js.map +1 -0
  87. package/dist/esm/components/CnNextStepCard/CnNextStepWidget.vue2.js +47 -0
  88. package/dist/esm/components/CnNextStepCard/CnNextStepWidget.vue2.js.map +1 -0
  89. package/dist/esm/components/CnNextStepCard/CnNextStepWidget.vue3.js +17 -0
  90. package/dist/esm/components/CnNextStepCard/CnNextStepWidget.vue3.js.map +1 -0
  91. package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue2.js +49 -0
  92. package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue2.js.map +1 -1
  93. package/dist/esm/components/CnObjectDataWidget/CnObjectDataWidget.vue3.js.map +1 -1
  94. package/dist/esm/components/CnObjectDataWidgetForm/CnObjectDataWidgetForm.vue2.js +6 -0
  95. package/dist/esm/components/CnObjectDataWidgetForm/CnObjectDataWidgetForm.vue2.js.map +1 -1
  96. package/dist/esm/components/CnObjectDataWidgetForm/CnObjectDataWidgetForm.vue3.js.map +1 -1
  97. package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js +46 -0
  98. package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js.map +1 -1
  99. package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue3.js +15 -3
  100. package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue3.js.map +1 -1
  101. package/dist/esm/components/CnPageRenderer/pageTypes.js +1 -0
  102. package/dist/esm/components/CnPageRenderer/pageTypes.js.map +1 -1
  103. package/dist/esm/components/CnQuickFilterBar/CnQuickFilterBar.vue2.js +37 -1
  104. package/dist/esm/components/CnQuickFilterBar/CnQuickFilterBar.vue2.js.map +1 -1
  105. package/dist/esm/components/CnQuickFilterBar/CnQuickFilterBar.vue3.js +29 -13
  106. package/dist/esm/components/CnQuickFilterBar/CnQuickFilterBar.vue3.js.map +1 -1
  107. package/dist/esm/components/CnSavedViewsControl/CnSavedViewsControl.vue2.js +50 -3
  108. package/dist/esm/components/CnSavedViewsControl/CnSavedViewsControl.vue2.js.map +1 -1
  109. package/dist/esm/components/CnSavedViewsControl/CnSavedViewsControl.vue3.js.map +1 -1
  110. package/dist/esm/components/CnSegmentedControl/CnSegmentedControl.vue.js +10 -0
  111. package/dist/esm/components/CnSegmentedControl/CnSegmentedControl.vue.js.map +1 -0
  112. package/dist/esm/components/CnSegmentedControl/CnSegmentedControl.vue2.js +186 -0
  113. package/dist/esm/components/CnSegmentedControl/CnSegmentedControl.vue2.js.map +1 -0
  114. package/dist/esm/components/CnSegmentedControl/CnSegmentedControl.vue3.js +46 -0
  115. package/dist/esm/components/CnSegmentedControl/CnSegmentedControl.vue3.js.map +1 -0
  116. package/dist/esm/components/CnStackedBarWidget/CnStackedBarWidget.vue.js +11 -0
  117. package/dist/esm/components/CnStackedBarWidget/CnStackedBarWidget.vue.js.map +1 -0
  118. package/dist/esm/components/CnStackedBarWidget/CnStackedBarWidget.vue2.js +298 -0
  119. package/dist/esm/components/CnStackedBarWidget/CnStackedBarWidget.vue2.js.map +1 -0
  120. package/dist/esm/components/CnStackedBarWidget/CnStackedBarWidget.vue3.js +77 -0
  121. package/dist/esm/components/CnStackedBarWidget/CnStackedBarWidget.vue3.js.map +1 -0
  122. package/dist/esm/components/CnStackedBarWidgetForm/CnStackedBarWidgetForm.vue.js +10 -0
  123. package/dist/esm/components/CnStackedBarWidgetForm/CnStackedBarWidgetForm.vue.js.map +1 -0
  124. package/dist/esm/components/CnStackedBarWidgetForm/CnStackedBarWidgetForm.vue2.js +169 -0
  125. package/dist/esm/components/CnStackedBarWidgetForm/CnStackedBarWidgetForm.vue2.js.map +1 -0
  126. package/dist/esm/components/CnStackedBarWidgetForm/CnStackedBarWidgetForm.vue3.js +48 -0
  127. package/dist/esm/components/CnStackedBarWidgetForm/CnStackedBarWidgetForm.vue3.js.map +1 -0
  128. package/dist/esm/components/CnTabs/CnTab.vue2.js +35 -0
  129. package/dist/esm/components/CnTabs/CnTab.vue2.js.map +1 -1
  130. package/dist/esm/components/CnTabs/CnTab.vue3.js.map +1 -1
  131. package/dist/esm/components/CnTabs/CnTabs.vue2.js +120 -7
  132. package/dist/esm/components/CnTabs/CnTabs.vue2.js.map +1 -1
  133. package/dist/esm/components/CnTabs/CnTabs.vue3.js +57 -5
  134. package/dist/esm/components/CnTabs/CnTabs.vue3.js.map +1 -1
  135. package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue2.js +59 -4
  136. package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue2.js.map +1 -1
  137. package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue3.js +6 -2
  138. package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue3.js.map +1 -1
  139. package/dist/esm/components/CnWeekStripWidget/CnWeekStripWidget.vue.js +10 -0
  140. package/dist/esm/components/CnWeekStripWidget/CnWeekStripWidget.vue.js.map +1 -0
  141. package/dist/esm/components/CnWeekStripWidget/CnWeekStripWidget.vue2.js +484 -0
  142. package/dist/esm/components/CnWeekStripWidget/CnWeekStripWidget.vue2.js.map +1 -0
  143. package/dist/esm/components/CnWeekStripWidget/CnWeekStripWidget.vue3.js +115 -0
  144. package/dist/esm/components/CnWeekStripWidget/CnWeekStripWidget.vue3.js.map +1 -0
  145. package/dist/esm/components/CnWeekStripWidgetForm/CnWeekStripWidgetForm.vue.js +10 -0
  146. package/dist/esm/components/CnWeekStripWidgetForm/CnWeekStripWidgetForm.vue.js.map +1 -0
  147. package/dist/esm/components/CnWeekStripWidgetForm/CnWeekStripWidgetForm.vue2.js +189 -0
  148. package/dist/esm/components/CnWeekStripWidgetForm/CnWeekStripWidgetForm.vue2.js.map +1 -0
  149. package/dist/esm/components/CnWeekStripWidgetForm/CnWeekStripWidgetForm.vue3.js +74 -0
  150. package/dist/esm/components/CnWeekStripWidgetForm/CnWeekStripWidgetForm.vue3.js.map +1 -0
  151. package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js +82 -8
  152. package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js.map +1 -1
  153. package/dist/esm/index.js +16 -0
  154. package/dist/esm/index.js.map +1 -1
  155. package/dist/esm/l10n/en.json.js +55 -1
  156. package/dist/esm/l10n/en.json.js.map +1 -1
  157. package/dist/esm/l10n/nl.json.js +55 -1
  158. package/dist/esm/l10n/nl.json.js.map +1 -1
  159. package/dist/esm/nextcloud-vue.css +1036 -19
  160. package/dist/esm/utils/dateVariant.js +124 -0
  161. package/dist/esm/utils/dateVariant.js.map +1 -0
  162. package/dist/esm/utils/detailActionModel.js +260 -0
  163. package/dist/esm/utils/detailActionModel.js.map +1 -0
  164. package/dist/esm/utils/dueRule.js +84 -0
  165. package/dist/esm/utils/dueRule.js.map +1 -0
  166. package/dist/esm/utils/fetchAggregate.js +37 -1
  167. package/dist/esm/utils/fetchAggregate.js.map +1 -1
  168. package/dist/esm/utils/fetchFilterCounts.js +186 -0
  169. package/dist/esm/utils/fetchFilterCounts.js.map +1 -0
  170. package/dist/esm/utils/headers.js +28 -2
  171. package/dist/esm/utils/headers.js.map +1 -1
  172. package/dist/esm/utils/libraryWidgetKeys.js +5 -0
  173. package/dist/esm/utils/libraryWidgetKeys.js.map +1 -1
  174. package/dist/esm/utils/readPath.js +30 -0
  175. package/dist/esm/utils/readPath.js.map +1 -0
  176. package/dist/esm/utils/validateManifestV2.compiled.js +2 -2
  177. package/dist/esm/utils/validateManifestV2.compiled.js.map +1 -1
  178. package/dist/nextcloud-vue.cjs.js +16019 -9528
  179. package/dist/nextcloud-vue.cjs.js.map +2 -2
  180. package/dist/nextcloud-vue.css +1036 -19
  181. package/l10n/en.json +55 -1
  182. package/l10n/nl.json +55 -1
  183. package/package.json +1 -1
  184. package/scripts/.jsdoc-baselines.json +4 -0
  185. package/src/components/CnActionsMenu/CnActionsMenu.vue +14 -1
  186. package/src/components/CnAppNav/CnAppNav.md +26 -0
  187. package/src/components/CnAppNav/CnAppNav.vue +145 -2
  188. package/src/components/CnBannerWidget/CnBannerWidget.vue +373 -11
  189. package/src/components/CnBannerWidgetForm/CnBannerWidgetForm.vue +65 -3
  190. package/src/components/CnBoardView/CnBoardView.vue +77 -0
  191. package/src/components/CnBrandStripe/CnBrandStripe.md +22 -0
  192. package/src/components/CnBrandStripe/CnBrandStripe.vue +100 -0
  193. package/src/components/CnBrandStripe/index.js +4 -0
  194. package/src/components/CnCellRenderer/CnCellRenderer.vue +207 -1
  195. package/src/components/CnConversationThread/CnConversationThread.md +51 -0
  196. package/src/components/CnConversationThread/CnConversationThread.vue +457 -0
  197. package/src/components/CnConversationThread/CnConversationWidget.vue +144 -0
  198. package/src/components/CnConversationThread/index.js +4 -0
  199. package/src/components/CnDashboardPage/CnDashboardPage.vue +10 -2
  200. package/src/components/CnDetailPage/CnDetailPage.md +16 -0
  201. package/src/components/CnDetailPage/CnDetailPage.vue +687 -49
  202. package/src/components/CnDocumentReviewList/CnDocumentReviewList.md +55 -0
  203. package/src/components/CnDocumentReviewList/CnDocumentReviewList.vue +384 -0
  204. package/src/components/CnDocumentReviewList/CnDocumentReviewWidget.vue +108 -0
  205. package/src/components/CnDocumentReviewList/index.js +4 -0
  206. package/src/components/CnHeaderWidget/CnHeaderWidget.vue +191 -14
  207. package/src/components/CnHeaderWidgetForm/CnHeaderWidgetForm.vue +53 -3
  208. package/src/components/CnIndexPage/CnIndexPage.vue +135 -3
  209. package/src/components/CnLinkCardsPage/CnLinkCardsPage.vue +484 -0
  210. package/src/components/CnLinkCardsPage/index.js +4 -0
  211. package/src/components/CnNextStepCard/CnNextStepCard.md +40 -0
  212. package/src/components/CnNextStepCard/CnNextStepCard.vue +319 -0
  213. package/src/components/CnNextStepCard/CnNextStepWidget.vue +59 -0
  214. package/src/components/CnNextStepCard/index.js +4 -0
  215. package/src/components/CnObjectDataWidget/CnObjectDataWidget.vue +49 -0
  216. package/src/components/CnObjectDataWidgetForm/CnObjectDataWidgetForm.vue +6 -0
  217. package/src/components/CnObjectKanban/CnObjectKanban.vue +86 -2
  218. package/src/components/CnPageRenderer/pageTypes.js +1 -0
  219. package/src/components/CnQuickFilterBar/CnQuickFilterBar.md +3 -0
  220. package/src/components/CnQuickFilterBar/CnQuickFilterBar.vue +60 -1
  221. package/src/components/CnSavedViewsControl/CnSavedViewsControl.vue +50 -3
  222. package/src/components/CnSegmentedControl/CnSegmentedControl.md +46 -0
  223. package/src/components/CnSegmentedControl/CnSegmentedControl.vue +291 -0
  224. package/src/components/CnSegmentedControl/index.js +4 -0
  225. package/src/components/CnStackedBarWidget/CnStackedBarWidget.md +15 -0
  226. package/src/components/CnStackedBarWidget/CnStackedBarWidget.vue +414 -0
  227. package/src/components/CnStackedBarWidget/index.js +14 -0
  228. package/src/components/CnStackedBarWidgetForm/CnStackedBarWidgetForm.vue +224 -0
  229. package/src/components/CnStackedBarWidgetForm/index.js +4 -0
  230. package/src/components/CnTabs/CnTab.vue +35 -0
  231. package/src/components/CnTabs/CnTabs.vue +244 -10
  232. package/src/components/CnTabsWidget/CnTabsWidget.vue +63 -4
  233. package/src/components/CnWeekStripWidget/CnWeekStripWidget.md +31 -0
  234. package/src/components/CnWeekStripWidget/CnWeekStripWidget.vue +668 -0
  235. package/src/components/CnWeekStripWidget/index.js +14 -0
  236. package/src/components/CnWeekStripWidgetForm/CnWeekStripWidgetForm.vue +265 -0
  237. package/src/components/CnWeekStripWidgetForm/index.js +4 -0
  238. package/src/components/CnWidgetGrid/registerDashboardWidgets.js +74 -0
  239. package/src/components/index.js +12 -0
  240. package/src/css/detail-page.css +57 -2
  241. package/src/index.js +16 -0
  242. package/src/schemas/app-manifest-v2.schema.json +433 -3
  243. package/src/schemas/app-manifest.schema.json +2 -1
  244. package/src/types/manifest.d.ts +1 -1
  245. package/src/utils/dateVariant.js +120 -0
  246. package/src/utils/detailActionModel.js +256 -0
  247. package/src/utils/dueRule.js +94 -0
  248. package/src/utils/fetchAggregate.js +36 -0
  249. package/src/utils/fetchFilterCounts.js +182 -0
  250. package/src/utils/headers.js +28 -2
  251. package/src/utils/index.js +1 -0
  252. package/src/utils/libraryWidgetKeys.js +5 -0
  253. package/src/utils/readPath.js +27 -0
  254. package/src/utils/validateManifestV2.compiled.js +2 -2
@@ -0,0 +1,124 @@
1
+ import { compareVisibleWhen } from './visibleWhen.js';
2
+
3
+ /**
4
+ * SPDX-FileCopyrightText: 2026 Conduction B.V.
5
+ * SPDX-License-Identifier: EUPL-1.2
6
+ *
7
+ * dateVariant: turn "how far away is this date" into a colour variant.
8
+ *
9
+ * A deadline reads differently depending on how close it is. The rules are the
10
+ * `variantWhen` shape the stat tile already uses (`[{ op, value, variant }]`,
11
+ * first match wins), compared against the number of CALENDAR days from today
12
+ * until the date: `0` is today, a negative number is overdue.
13
+ *
14
+ * ```js
15
+ * resolveDateVariant('2026-10-01', [
16
+ * { op: 'lt', value: 0, variant: 'error' }, // overdue
17
+ * { op: 'lte', value: 5, variant: 'warning' }, // within five days
18
+ * ])
19
+ * ```
20
+ *
21
+ * Shared by the `date` cell widget (CnCellRenderer) and the week strip, and
22
+ * meant for board cards too, so a deadline is coloured by one rule everywhere.
23
+ *
24
+ * @module utils/dateVariant
25
+ */
26
+
27
+
28
+ /** Variants a date rule may name. `danger` is accepted as an alias of `error`. */
29
+ const DATE_VARIANTS = Object.freeze(['default', 'success', 'warning', 'error']);
30
+
31
+ const MS_PER_DAY = 86400000;
32
+
33
+ /**
34
+ * Parse a value into a Date. A date-only string (`2026-10-05`) is read as a
35
+ * LOCAL day, so it does not slide to the day before in a timezone west of UTC.
36
+ *
37
+ * @param {unknown} value A Date, a timestamp, or an ISO string.
38
+ * @return {Date|null} The date, or null when the value is not one.
39
+ * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-avatar-and-date-cells
40
+ */
41
+ function parseDateValue(value) {
42
+ if (value === null || value === undefined || value === '') {
43
+ return null
44
+ }
45
+ if (value instanceof Date) {
46
+ return Number.isNaN(value.getTime()) ? null : value
47
+ }
48
+ if (typeof value === 'string') {
49
+ const dateOnly = value.match(/^(\d{4})-(\d{2})-(\d{2})$/);
50
+ if (dateOnly) {
51
+ return new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3]))
52
+ }
53
+ }
54
+ if (typeof value !== 'string' && typeof value !== 'number') {
55
+ return null
56
+ }
57
+ const parsed = new Date(value);
58
+ return Number.isNaN(parsed.getTime()) ? null : parsed
59
+ }
60
+
61
+ /**
62
+ * The local calendar day of a date as `YYYY-MM-DD`.
63
+ *
64
+ * @param {Date} date The date.
65
+ * @return {string} The day key.
66
+ * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-week-strip-widget
67
+ */
68
+ function dayKey(date) {
69
+ const month = String(date.getMonth() + 1).padStart(2, '0');
70
+ const day = String(date.getDate()).padStart(2, '0');
71
+ return `${date.getFullYear()}-${month}-${day}`
72
+ }
73
+
74
+ /**
75
+ * Whole calendar days from `now` until `value`: 0 today, negative when past.
76
+ *
77
+ * @param {unknown} value The date.
78
+ * @param {Date} [now] The reference moment (defaults to the current time).
79
+ * @return {number|null} The day count, or null when `value` is not a date.
80
+ * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-avatar-and-date-cells
81
+ */
82
+ function daysUntil(value, now = new Date()) {
83
+ const date = parseDateValue(value);
84
+ if (date === null) {
85
+ return null
86
+ }
87
+ // UTC midnights of the two LOCAL days, so a daylight-saving hour never
88
+ // turns one day into zero or two.
89
+ const target = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate());
90
+ const today = Date.UTC(now.getFullYear(), now.getMonth(), now.getDate());
91
+ return Math.round((target - today) / MS_PER_DAY)
92
+ }
93
+
94
+ /**
95
+ * The variant of the first rule the date matches, or '' when none does.
96
+ *
97
+ * @param {unknown} value The date.
98
+ * @param {Array<{op: string, value: number, variant: string}>} rules The `variantWhen` rules.
99
+ * @param {Date} [now] The reference moment (defaults to the current time).
100
+ * @return {string} `success | warning | error | default`, or '' for no match.
101
+ * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-avatar-and-date-cells
102
+ */
103
+ function resolveDateVariant(value, rules, now = new Date()) {
104
+ if (!Array.isArray(rules) || rules.length === 0) {
105
+ return ''
106
+ }
107
+ const days = daysUntil(value, now);
108
+ if (days === null) {
109
+ return ''
110
+ }
111
+ for (const rule of rules) {
112
+ if (!rule || typeof rule !== 'object') {
113
+ continue
114
+ }
115
+ if (compareVisibleWhen(days, rule.op || 'eq', rule.value) === true) {
116
+ const variant = rule.variant === 'danger' ? 'error' : rule.variant;
117
+ return DATE_VARIANTS.includes(variant) ? variant : ''
118
+ }
119
+ }
120
+ return ''
121
+ }
122
+
123
+ export { DATE_VARIANTS, dayKey, daysUntil, parseDateValue, resolveDateVariant };
124
+ //# sourceMappingURL=dateVariant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dateVariant.js","sources":["../../../src/utils/dateVariant.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * dateVariant: turn \"how far away is this date\" into a colour variant.\n *\n * A deadline reads differently depending on how close it is. The rules are the\n * `variantWhen` shape the stat tile already uses (`[{ op, value, variant }]`,\n * first match wins), compared against the number of CALENDAR days from today\n * until the date: `0` is today, a negative number is overdue.\n *\n * ```js\n * resolveDateVariant('2026-10-01', [\n * { op: 'lt', value: 0, variant: 'error' }, // overdue\n * { op: 'lte', value: 5, variant: 'warning' }, // within five days\n * ])\n * ```\n *\n * Shared by the `date` cell widget (CnCellRenderer) and the week strip, and\n * meant for board cards too, so a deadline is coloured by one rule everywhere.\n *\n * @module utils/dateVariant\n */\n\nimport { compareVisibleWhen } from './visibleWhen.js'\n\n/** Variants a date rule may name. `danger` is accepted as an alias of `error`. */\nexport const DATE_VARIANTS = Object.freeze(['default', 'success', 'warning', 'error'])\n\nconst MS_PER_DAY = 86400000\n\n/**\n * Parse a value into a Date. A date-only string (`2026-10-05`) is read as a\n * LOCAL day, so it does not slide to the day before in a timezone west of UTC.\n *\n * @param {unknown} value A Date, a timestamp, or an ISO string.\n * @return {Date|null} The date, or null when the value is not one.\n * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-avatar-and-date-cells\n */\nexport function parseDateValue(value) {\n\tif (value === null || value === undefined || value === '') {\n\t\treturn null\n\t}\n\tif (value instanceof Date) {\n\t\treturn Number.isNaN(value.getTime()) ? null : value\n\t}\n\tif (typeof value === 'string') {\n\t\tconst dateOnly = value.match(/^(\\d{4})-(\\d{2})-(\\d{2})$/)\n\t\tif (dateOnly) {\n\t\t\treturn new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3]))\n\t\t}\n\t}\n\tif (typeof value !== 'string' && typeof value !== 'number') {\n\t\treturn null\n\t}\n\tconst parsed = new Date(value)\n\treturn Number.isNaN(parsed.getTime()) ? null : parsed\n}\n\n/**\n * The local calendar day of a date as `YYYY-MM-DD`.\n *\n * @param {Date} date The date.\n * @return {string} The day key.\n * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-week-strip-widget\n */\nexport function dayKey(date) {\n\tconst month = String(date.getMonth() + 1).padStart(2, '0')\n\tconst day = String(date.getDate()).padStart(2, '0')\n\treturn `${date.getFullYear()}-${month}-${day}`\n}\n\n/**\n * Whole calendar days from `now` until `value`: 0 today, negative when past.\n *\n * @param {unknown} value The date.\n * @param {Date} [now] The reference moment (defaults to the current time).\n * @return {number|null} The day count, or null when `value` is not a date.\n * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-avatar-and-date-cells\n */\nexport function daysUntil(value, now = new Date()) {\n\tconst date = parseDateValue(value)\n\tif (date === null) {\n\t\treturn null\n\t}\n\t// UTC midnights of the two LOCAL days, so a daylight-saving hour never\n\t// turns one day into zero or two.\n\tconst target = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())\n\tconst today = Date.UTC(now.getFullYear(), now.getMonth(), now.getDate())\n\treturn Math.round((target - today) / MS_PER_DAY)\n}\n\n/**\n * The variant of the first rule the date matches, or '' when none does.\n *\n * @param {unknown} value The date.\n * @param {Array<{op: string, value: number, variant: string}>} rules The `variantWhen` rules.\n * @param {Date} [now] The reference moment (defaults to the current time).\n * @return {string} `success | warning | error | default`, or '' for no match.\n * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-avatar-and-date-cells\n */\nexport function resolveDateVariant(value, rules, now = new Date()) {\n\tif (!Array.isArray(rules) || rules.length === 0) {\n\t\treturn ''\n\t}\n\tconst days = daysUntil(value, now)\n\tif (days === null) {\n\t\treturn ''\n\t}\n\tfor (const rule of rules) {\n\t\tif (!rule || typeof rule !== 'object') {\n\t\t\tcontinue\n\t\t}\n\t\tif (compareVisibleWhen(days, rule.op || 'eq', rule.value) === true) {\n\t\t\tconst variant = rule.variant === 'danger' ? 'error' : rule.variant\n\t\t\treturn DATE_VARIANTS.includes(variant) ? variant : ''\n\t\t}\n\t}\n\treturn ''\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACY,MAAC,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EAAC;AACtF;AACA,MAAM,UAAU,GAAG,SAAQ;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,KAAK,EAAE;AACtC,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,EAAE;AAC5D,EAAE,OAAO,IAAI;AACb,EAAE;AACF,CAAC,IAAI,KAAK,YAAY,IAAI,EAAE;AAC5B,EAAE,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,GAAG,KAAK;AACrD,EAAE;AACF,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAChC,EAAE,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,2BAA2B,EAAC;AAC3D,EAAE,IAAI,QAAQ,EAAE;AAChB,GAAG,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,C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'./visibleWhen.js';
3
+
4
+ /**
5
+ * SPDX-FileCopyrightText: 2026 Conduction B.V.
6
+ * SPDX-License-Identifier: EUPL-1.2
7
+ *
8
+ * detailActionModel: the rules behind a detail page's four action levels and
9
+ * the case surfaces that read the record's stage.
10
+ *
11
+ * 1. the next step: one primary button, chosen by the record's stage,
12
+ * 2. quick actions: at most three always visible buttons,
13
+ * 3. the overflow menu: the rest, in named groups,
14
+ * 4. admin actions: the last group, for admins only.
15
+ *
16
+ * Pure functions, no Vue and no fetch, so CnDetailPage, the widgets and the
17
+ * tests all read one implementation.
18
+ *
19
+ * @module utils/detailActionModel
20
+ */
21
+
22
+
23
+ /** The most quick actions a page shows. Later entries are dropped. */
24
+ const MAX_QUICK_ACTIONS = 3;
25
+
26
+ /**
27
+ * The record's stage, as the string a stage map is keyed on.
28
+ *
29
+ * @param {object|null} object The record.
30
+ * @param {string} [stageField] Dot-path to the stage. Defaults to `status`.
31
+ * @return {string} The stage, or '' when the record has none.
32
+ * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-primary-action-follows-the-stage
33
+ */
34
+ function stageOf(object, stageField = 'status') {
35
+ if (!object || typeof object !== 'object') {
36
+ return ''
37
+ }
38
+ const value = readPath(object, stageField || 'status');
39
+ if (value === null || value === undefined || typeof value === 'object') {
40
+ return ''
41
+ }
42
+ return String(value)
43
+ }
44
+
45
+ /**
46
+ * Look a stage up in a stage-keyed map. An exact key wins; otherwise the
47
+ * match ignores case, because a status is stored as `in_behandeling` in one
48
+ * register and `In_Behandeling` in the next.
49
+ *
50
+ * @param {object|null} map The stage-keyed map.
51
+ * @param {string} stage The stage.
52
+ * @return {unknown} The entry, or undefined.
53
+ * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-primary-action-follows-the-stage
54
+ */
55
+ function stageEntry(map, stage) {
56
+ if (!map || typeof map !== 'object' || Array.isArray(map) || stage === '') {
57
+ return undefined
58
+ }
59
+ if (Object.hasOwn(map, stage)) {
60
+ return map[stage]
61
+ }
62
+ const wanted = stage.toLowerCase();
63
+ const key = Object.keys(map).find((candidate) => candidate.toLowerCase() === wanted);
64
+ return key === undefined ? undefined : map[key]
65
+ }
66
+
67
+ /**
68
+ * Turn a pinned action entry into a descriptor the page can dispatch.
69
+ *
70
+ * An entry is the id of a declared header action, or an action object of its
71
+ * own. An object without an id gets `fallbackId`, since every dispatched
72
+ * action is addressed by id.
73
+ *
74
+ * @param {string|object|null} entry The entry.
75
+ * @param {string} fallbackId Id for an inline action that names none.
76
+ * @return {{id: string, inline: object|null}|null} The id, plus the inline definition when the entry carried one.
77
+ * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-quick-actions
78
+ */
79
+ function normalisePinnedAction(entry, fallbackId) {
80
+ if (typeof entry === 'string') {
81
+ return entry === '' ? null : { id: entry, inline: null }
82
+ }
83
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
84
+ return null
85
+ }
86
+ if (typeof entry.label !== 'string' || entry.label === '') {
87
+ return null
88
+ }
89
+ const id = typeof entry.id === 'string' && entry.id !== '' ? entry.id : fallbackId;
90
+ return { id, inline: { ...entry, id } }
91
+ }
92
+
93
+ /**
94
+ * Split menu entries into the groups the overflow menu draws.
95
+ *
96
+ * Ungrouped entries come first, under no caption. Named groups follow in the
97
+ * order they first appear. Admin only entries are dropped for everyone else
98
+ * and form the last group for admins, whatever `group` they also name.
99
+ *
100
+ * `adminOnly` hides a control. It is never an authorization decision: the
101
+ * endpoint behind the action decides who may call it.
102
+ *
103
+ * @param {Array<object>} entries Menu-ready entries, each with an `id`.
104
+ * @param {object} actionsById The declared actions by id, carrying `group` / `adminOnly`.
105
+ * @param {{isAdmin?: boolean, adminLabel?: string}} [options] Who is looking, and what the admin group is called.
106
+ * @return {Array<{key: string, label: string, entries: Array<object>}>} The non-empty groups, in render order.
107
+ * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-grouped-and-admin-only-menu-actions
108
+ */
109
+ function groupMenuEntries(entries, actionsById = {}, options = {}) {
110
+ const isAdmin = options.isAdmin === true;
111
+ const plain = { key: '', label: '', entries: [] };
112
+ const named = [];
113
+ const admin = { key: 'cn-admin', label: options.adminLabel || '', entries: [] };
114
+ for (const entry of Array.isArray(entries) ? entries : []) {
115
+ const declared = (entry && actionsById[entry.id]) || {};
116
+ if (declared.adminOnly === true) {
117
+ if (isAdmin) {
118
+ admin.entries.push(entry);
119
+ }
120
+ continue
121
+ }
122
+ const label = typeof declared.group === 'string' ? declared.group.trim() : '';
123
+ if (label === '') {
124
+ plain.entries.push(entry);
125
+ continue
126
+ }
127
+ let group = named.find((candidate) => candidate.label === label);
128
+ if (!group) {
129
+ group = { key: `cn-group-${named.length}`, label, entries: [] };
130
+ named.push(group);
131
+ }
132
+ group.entries.push(entry);
133
+ }
134
+ return [plain, ...named, admin].filter((group) => group.entries.length > 0)
135
+ }
136
+
137
+ /**
138
+ * Whether one checklist item is done for this record.
139
+ *
140
+ * `done` (a literal) wins, then `doneWhen` (a local visibleWhen condition),
141
+ * then `doneField` (truthy, and for a list: not empty).
142
+ *
143
+ * @param {object} item The checklist item.
144
+ * @param {object|null} object The record.
145
+ * @return {boolean} True when the item is done.
146
+ * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-next-step-card
147
+ */
148
+ function isChecklistItemDone(item, object) {
149
+ if (!item || typeof item !== 'object') {
150
+ return false
151
+ }
152
+ if (typeof item.done === 'boolean') {
153
+ return item.done
154
+ }
155
+ const data = object && typeof object === 'object' ? object : {};
156
+ if (item.doneWhen && typeof item.doneWhen === 'object') {
157
+ return evaluateVisibleWhenLocal(item.doneWhen, data)
158
+ }
159
+ if (typeof item.doneField === 'string' && item.doneField !== '') {
160
+ const value = readPath(data, item.doneField);
161
+ return Array.isArray(value) ? value.length > 0 : Boolean(value)
162
+ }
163
+ return false
164
+ }
165
+
166
+ /**
167
+ * Resolve the "what now" card for the record's stage.
168
+ *
169
+ * @param {{stages?: object, title?: string}|null} config The `nextStep` config.
170
+ * @param {object|null} object The record.
171
+ * @param {string} [stageField] Dot-path to the stage.
172
+ * @return {{stage: string, title: string, items: Array<{label: string, done: boolean, hint: string}>, after: string}|null} The card, or null when this stage declares no checklist.
173
+ * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-next-step-card
174
+ */
175
+ function resolveNextStep(config, object, stageField = 'status') {
176
+ if (!config || typeof config !== 'object') {
177
+ return null
178
+ }
179
+ const stage = stageOf(object, config.field || stageField);
180
+ const declared = stageEntry(config.stages, stage);
181
+ if (!declared || typeof declared !== 'object' || !Array.isArray(declared.checklist)) {
182
+ return null
183
+ }
184
+ const items = declared.checklist
185
+ .filter((item) => item && typeof item === 'object' && typeof item.label === 'string' && item.label !== '')
186
+ .map((item) => ({
187
+ label: item.label,
188
+ done: isChecklistItemDone(item, object),
189
+ hint: typeof item.hint === 'string' ? item.hint : '',
190
+ }));
191
+ if (items.length === 0) {
192
+ return null
193
+ }
194
+ return {
195
+ stage,
196
+ title: typeof declared.title === 'string' ? declared.title : (typeof config.title === 'string' ? config.title : ''),
197
+ items,
198
+ after: typeof declared.after === 'string' ? declared.after : '',
199
+ }
200
+ }
201
+
202
+ /**
203
+ * Resolve a header pill from the record.
204
+ *
205
+ * @param {{field?: string, colorMap?: object, labels?: object, variant?: string}|null} config The pill config.
206
+ * @param {object|null} object The record.
207
+ * @return {{label: string, colorKey: string, colorMap: object|null, variant: string}|null} What CnStatusBadge needs, or null when the field is empty.
208
+ * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-header-pills
209
+ */
210
+ function resolvePill(config, object) {
211
+ if (!config || typeof config !== 'object' || typeof config.field !== 'string' || config.field === '') {
212
+ return null
213
+ }
214
+ const raw = stageOf(object, config.field);
215
+ if (raw === '') {
216
+ return null
217
+ }
218
+ const mapped = stageEntry(config.labels, raw);
219
+ return {
220
+ label: typeof mapped === 'string' && mapped !== '' ? mapped : raw,
221
+ colorKey: raw,
222
+ colorMap: config.colorMap && typeof config.colorMap === 'object' ? config.colorMap : null,
223
+ variant: typeof config.variant === 'string' && config.variant !== '' ? config.variant : 'default',
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Resolve a tab's count.
229
+ *
230
+ * `count` (a number) wins. Otherwise `countField` is read off the record: a
231
+ * list counts its items, a number is taken as is.
232
+ *
233
+ * @param {{count?: number, countField?: string}|null} tab The tab declaration.
234
+ * @param {object|null} object The record.
235
+ * @return {number|null} The count, or null when the tab declares none.
236
+ * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-tab-counts-and-overflow
237
+ */
238
+ function resolveTabCount(tab, object) {
239
+ if (!tab || typeof tab !== 'object') {
240
+ return null
241
+ }
242
+ if (typeof tab.count === 'number' && Number.isFinite(tab.count)) {
243
+ return tab.count
244
+ }
245
+ if (typeof tab.countField !== 'string' || tab.countField === '') {
246
+ return null
247
+ }
248
+ const value = readPath(object && typeof object === 'object' ? object : {}, tab.countField);
249
+ if (Array.isArray(value)) {
250
+ return value.length
251
+ }
252
+ if (value === null || value === undefined || value === '') {
253
+ return 0
254
+ }
255
+ const number = Number(value);
256
+ return Number.isFinite(number) ? number : null
257
+ }
258
+
259
+ export { MAX_QUICK_ACTIONS, groupMenuEntries, isChecklistItemDone, normalisePinnedAction, resolveNextStep, resolvePill, resolveTabCount, stageEntry, stageOf };
260
+ //# sourceMappingURL=detailActionModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detailActionModel.js","sources":["../../../src/utils/detailActionModel.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * detailActionModel: the rules behind a detail page's four action levels and\n * the case surfaces that read the record's stage.\n *\n * 1. the next step: one primary button, chosen by the record's stage,\n * 2. quick actions: at most three always visible buttons,\n * 3. the overflow menu: the rest, in named groups,\n * 4. admin actions: the last group, for admins only.\n *\n * Pure functions, no Vue and no fetch, so CnDetailPage, the widgets and the\n * tests all read one implementation.\n *\n * @module utils/detailActionModel\n */\n\nimport { readPath } from './readPath.js'\nimport { evaluateVisibleWhenLocal } from './visibleWhen.js'\n\n/** The most quick actions a page shows. Later entries are dropped. */\nexport const MAX_QUICK_ACTIONS = 3\n\n/**\n * The record's stage, as the string a stage map is keyed on.\n *\n * @param {object|null} object The record.\n * @param {string} [stageField] Dot-path to the stage. Defaults to `status`.\n * @return {string} The stage, or '' when the record has none.\n * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-primary-action-follows-the-stage\n */\nexport function stageOf(object, stageField = 'status') {\n\tif (!object || typeof object !== 'object') {\n\t\treturn ''\n\t}\n\tconst value = readPath(object, stageField || 'status')\n\tif (value === null || value === undefined || typeof value === 'object') {\n\t\treturn ''\n\t}\n\treturn String(value)\n}\n\n/**\n * Look a stage up in a stage-keyed map. An exact key wins; otherwise the\n * match ignores case, because a status is stored as `in_behandeling` in one\n * register and `In_Behandeling` in the next.\n *\n * @param {object|null} map The stage-keyed map.\n * @param {string} stage The stage.\n * @return {unknown} The entry, or undefined.\n * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-primary-action-follows-the-stage\n */\nexport function stageEntry(map, stage) {\n\tif (!map || typeof map !== 'object' || Array.isArray(map) || stage === '') {\n\t\treturn undefined\n\t}\n\tif (Object.hasOwn(map, stage)) {\n\t\treturn map[stage]\n\t}\n\tconst wanted = stage.toLowerCase()\n\tconst key = Object.keys(map).find((candidate) => candidate.toLowerCase() === wanted)\n\treturn key === undefined ? undefined : map[key]\n}\n\n/**\n * Turn a pinned action entry into a descriptor the page can dispatch.\n *\n * An entry is the id of a declared header action, or an action object of its\n * own. An object without an id gets `fallbackId`, since every dispatched\n * action is addressed by id.\n *\n * @param {string|object|null} entry The entry.\n * @param {string} fallbackId Id for an inline action that names none.\n * @return {{id: string, inline: object|null}|null} The id, plus the inline definition when the entry carried one.\n * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-quick-actions\n */\nexport function normalisePinnedAction(entry, fallbackId) {\n\tif (typeof entry === 'string') {\n\t\treturn entry === '' ? null : { id: entry, inline: null }\n\t}\n\tif (!entry || typeof entry !== 'object' || Array.isArray(entry)) {\n\t\treturn null\n\t}\n\tif (typeof entry.label !== 'string' || entry.label === '') {\n\t\treturn null\n\t}\n\tconst id = typeof entry.id === 'string' && entry.id !== '' ? entry.id : fallbackId\n\treturn { id, inline: { ...entry, id } }\n}\n\n/**\n * Split menu entries into the groups the overflow menu draws.\n *\n * Ungrouped entries come first, under no caption. Named groups follow in the\n * order they first appear. Admin only entries are dropped for everyone else\n * and form the last group for admins, whatever `group` they also name.\n *\n * `adminOnly` hides a control. It is never an authorization decision: the\n * endpoint behind the action decides who may call it.\n *\n * @param {Array<object>} entries Menu-ready entries, each with an `id`.\n * @param {object} actionsById The declared actions by id, carrying `group` / `adminOnly`.\n * @param {{isAdmin?: boolean, adminLabel?: string}} [options] Who is looking, and what the admin group is called.\n * @return {Array<{key: string, label: string, entries: Array<object>}>} The non-empty groups, in render order.\n * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-grouped-and-admin-only-menu-actions\n */\nexport function groupMenuEntries(entries, actionsById = {}, options = {}) {\n\tconst isAdmin = options.isAdmin === true\n\tconst plain = { key: '', label: '', entries: [] }\n\tconst named = []\n\tconst admin = { key: 'cn-admin', label: options.adminLabel || '', entries: [] }\n\tfor (const entry of Array.isArray(entries) ? entries : []) {\n\t\tconst declared = (entry && actionsById[entry.id]) || {}\n\t\tif (declared.adminOnly === true) {\n\t\t\tif (isAdmin) {\n\t\t\t\tadmin.entries.push(entry)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tconst label = typeof declared.group === 'string' ? declared.group.trim() : ''\n\t\tif (label === '') {\n\t\t\tplain.entries.push(entry)\n\t\t\tcontinue\n\t\t}\n\t\tlet group = named.find((candidate) => candidate.label === label)\n\t\tif (!group) {\n\t\t\tgroup = { key: `cn-group-${named.length}`, label, entries: [] }\n\t\t\tnamed.push(group)\n\t\t}\n\t\tgroup.entries.push(entry)\n\t}\n\treturn [plain, ...named, admin].filter((group) => group.entries.length > 0)\n}\n\n/**\n * Whether one checklist item is done for this record.\n *\n * `done` (a literal) wins, then `doneWhen` (a local visibleWhen condition),\n * then `doneField` (truthy, and for a list: not empty).\n *\n * @param {object} item The checklist item.\n * @param {object|null} object The record.\n * @return {boolean} True when the item is done.\n * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-next-step-card\n */\nexport function isChecklistItemDone(item, object) {\n\tif (!item || typeof item !== 'object') {\n\t\treturn false\n\t}\n\tif (typeof item.done === 'boolean') {\n\t\treturn item.done\n\t}\n\tconst data = object && typeof object === 'object' ? object : {}\n\tif (item.doneWhen && typeof item.doneWhen === 'object') {\n\t\treturn evaluateVisibleWhenLocal(item.doneWhen, data)\n\t}\n\tif (typeof item.doneField === 'string' && item.doneField !== '') {\n\t\tconst value = readPath(data, item.doneField)\n\t\treturn Array.isArray(value) ? value.length > 0 : Boolean(value)\n\t}\n\treturn false\n}\n\n/**\n * Resolve the \"what now\" card for the record's stage.\n *\n * @param {{stages?: object, title?: string}|null} config The `nextStep` config.\n * @param {object|null} object The record.\n * @param {string} [stageField] Dot-path to the stage.\n * @return {{stage: string, title: string, items: Array<{label: string, done: boolean, hint: string}>, after: string}|null} The card, or null when this stage declares no checklist.\n * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-next-step-card\n */\nexport function resolveNextStep(config, object, stageField = 'status') {\n\tif (!config || typeof config !== 'object') {\n\t\treturn null\n\t}\n\tconst stage = stageOf(object, config.field || stageField)\n\tconst declared = stageEntry(config.stages, stage)\n\tif (!declared || typeof declared !== 'object' || !Array.isArray(declared.checklist)) {\n\t\treturn null\n\t}\n\tconst items = declared.checklist\n\t\t.filter((item) => item && typeof item === 'object' && typeof item.label === 'string' && item.label !== '')\n\t\t.map((item) => ({\n\t\t\tlabel: item.label,\n\t\t\tdone: isChecklistItemDone(item, object),\n\t\t\thint: typeof item.hint === 'string' ? item.hint : '',\n\t\t}))\n\tif (items.length === 0) {\n\t\treturn null\n\t}\n\treturn {\n\t\tstage,\n\t\ttitle: typeof declared.title === 'string' ? declared.title : (typeof config.title === 'string' ? config.title : ''),\n\t\titems,\n\t\tafter: typeof declared.after === 'string' ? declared.after : '',\n\t}\n}\n\n/**\n * Resolve a header pill from the record.\n *\n * @param {{field?: string, colorMap?: object, labels?: object, variant?: string}|null} config The pill config.\n * @param {object|null} object The record.\n * @return {{label: string, colorKey: string, colorMap: object|null, variant: string}|null} What CnStatusBadge needs, or null when the field is empty.\n * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-header-pills\n */\nexport function resolvePill(config, object) {\n\tif (!config || typeof config !== 'object' || typeof config.field !== 'string' || config.field === '') {\n\t\treturn null\n\t}\n\tconst raw = stageOf(object, config.field)\n\tif (raw === '') {\n\t\treturn null\n\t}\n\tconst mapped = stageEntry(config.labels, raw)\n\treturn {\n\t\tlabel: typeof mapped === 'string' && mapped !== '' ? mapped : raw,\n\t\tcolorKey: raw,\n\t\tcolorMap: config.colorMap && typeof config.colorMap === 'object' ? config.colorMap : null,\n\t\tvariant: typeof config.variant === 'string' && config.variant !== '' ? config.variant : 'default',\n\t}\n}\n\n/**\n * Resolve a tab's count.\n *\n * `count` (a number) wins. Otherwise `countField` is read off the record: a\n * list counts its items, a number is taken as is.\n *\n * @param {{count?: number, countField?: string}|null} tab The tab declaration.\n * @param {object|null} object The record.\n * @return {number|null} The count, or null when the tab declares none.\n * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-tab-counts-and-overflow\n */\nexport function resolveTabCount(tab, object) {\n\tif (!tab || typeof tab !== 'object') {\n\t\treturn null\n\t}\n\tif (typeof tab.count === 'number' && Number.isFinite(tab.count)) {\n\t\treturn tab.count\n\t}\n\tif (typeof tab.countField !== 'string' || tab.countField === '') {\n\t\treturn null\n\t}\n\tconst value = readPath(object && typeof object === 'object' ? object : {}, tab.countField)\n\tif (Array.isArray(value)) {\n\t\treturn value.length\n\t}\n\tif (value === null || value === undefined || value === '') {\n\t\treturn 0\n\t}\n\tconst number = Number(value)\n\treturn Number.isFinite(number) ? number : null\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACY,MAAC,iBAAiB,GAAG,EAAC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,EAAE;AACvD,CAAC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;AAC5C,EAAE,OAAO,EAAE;AACX,EAAE;AACF,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,UAAU,IAAI,QAAQ,EAAC;AACvD,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AACzE,EAAE,OAAO,EAAE;AACX,EAAE;AACF,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC;AACrB,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE;AACvC,CAAC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,KAAK,EAAE,EAAE;AAC5E,EAAE,OAAO,SAAS;AAClB,EAAE;AACF,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,E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G,MAAM,CAAC,OAAO,GAAG,SAAS;AACnG,EAAE;AACF,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE;AAC7C,CAAC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;AACtC,EAAE,OAAO,IAAI;AACb,EAAE;AACF,CAAC,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;AAClE,EAAE,OAAO,GAAG,CAAC,KAAK;AAClB,EAAE;AACF,CAAC,IAAI,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ,IAAI,GAAG,CAAC,UAAU,KAAK,EAAE,EAAE;AAClE,EAAE,OAAO,IAAI;AACb,EAAE;AACF,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,GAAG,MAAM,GAAG,EAAE,EAAE,GAAG,CAAC,UAAU,EAAC;AAC3F,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AAC3B,EAAE,OAAO,KAAK,CAAC,MAAM;AACrB,EAAE;AACF,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,EAAE;AAC5D,EAAE,OAAO,CAAC;AACV,EAAE;AACF,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,EAAC;AAC7B,CAAC,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI;AAC/C;;;;"}
@@ -0,0 +1,84 @@
1
+ import { daysUntil, resolveDateVariant } from './dateVariant.js';
2
+ import { readPath } from './readPath.js';
3
+
4
+ /**
5
+ * SPDX-FileCopyrightText: 2026 Conduction B.V.
6
+ * SPDX-License-Identifier: EUPL-1.2
7
+ *
8
+ * dueRule: decides whether a dated card is overdue, due soon or fine.
9
+ *
10
+ * A board's rule is `{ field, soonDays?, variantWhen? }`. `field` is a
11
+ * dot-path to the date on the row. `soonDays` (default 3) is how many days
12
+ * ahead still counts as "soon"; a date before today is overdue.
13
+ *
14
+ * The deciding is done by `utils/dateVariant.js`, the same rules a table's
15
+ * date cell uses, so a list and its board agree on what late means.
16
+ * `{ soonDays: 3 }` is shorthand for
17
+ * `variantWhen: [{ op: 'lt', value: 0, variant: 'error' }, { op: 'lte', value: 3, variant: 'warning' }]`,
18
+ * and a rule that carries its own `variantWhen` is used as written:
19
+ * `error` reads as overdue, `warning` as due soon.
20
+ *
21
+ * @module utils/dueRule
22
+ */
23
+
24
+
25
+ /** How many days ahead counts as "soon" when the rule does not say. */
26
+ const DEFAULT_SOON_DAYS = 3;
27
+
28
+ /**
29
+ * The `variantWhen` rules a due rule stands for.
30
+ *
31
+ * @param {{soonDays?: number, variantWhen?: Array<object>}|null} [rule] The due rule.
32
+ * @return {Array<{op: string, value: number, variant: string}>} The rules `resolveDateVariant` takes.
33
+ * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-late-marking-on-board-cards
34
+ */
35
+ function dueRuleToVariantWhen(rule = {}) {
36
+ if (Array.isArray(rule?.variantWhen) && rule.variantWhen.length > 0) {
37
+ return rule.variantWhen
38
+ }
39
+ const given = rule?.soonDays;
40
+ const soonDays = given !== null && given !== undefined && Number.isFinite(Number(given)) ? Number(given) : DEFAULT_SOON_DAYS;
41
+ return [
42
+ { op: 'lt', value: 0, variant: 'error' },
43
+ { op: 'lte', value: soonDays, variant: 'warning' },
44
+ ]
45
+ }
46
+
47
+ /**
48
+ * The due state of one date under a rule.
49
+ *
50
+ * @param {unknown} value The date.
51
+ * @param {{soonDays?: number, variantWhen?: Array<object>}|null} [rule] The rule.
52
+ * @param {Date} [now] The moment to measure from.
53
+ * @return {'overdue'|'soon'|'ok'|null} The state, or null when there is no readable date.
54
+ * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-late-marking-on-board-cards
55
+ */
56
+ function dueStateOf(value, rule = {}, now = new Date()) {
57
+ if (daysUntil(value, now) === null) {
58
+ return null
59
+ }
60
+ const variant = resolveDateVariant(value, dueRuleToVariantWhen(rule), now);
61
+ if (variant === 'error') {
62
+ return 'overdue'
63
+ }
64
+ return variant === 'warning' ? 'soon' : 'ok'
65
+ }
66
+
67
+ /**
68
+ * The due state of a row under a `{ field, soonDays }` rule.
69
+ *
70
+ * @param {object} row The row or card.
71
+ * @param {{field?: string, soonDays?: number, variantWhen?: Array<object>}|null} rule The rule. Null or field-less means no marking.
72
+ * @param {Date} [now] The moment to measure from.
73
+ * @return {'overdue'|'soon'|'ok'|null} The state, or null when the rule does not apply.
74
+ * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-late-marking-on-board-cards
75
+ */
76
+ function dueStateForRow(row, rule, now = new Date()) {
77
+ if (!rule || typeof rule.field !== 'string' || rule.field === '' || !row) {
78
+ return null
79
+ }
80
+ return dueStateOf(readPath(row, rule.field), rule, now)
81
+ }
82
+
83
+ export { DEFAULT_SOON_DAYS, daysUntil, dueRuleToVariantWhen, dueStateForRow, dueStateOf };
84
+ //# sourceMappingURL=dueRule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dueRule.js","sources":["../../../src/utils/dueRule.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * dueRule: decides whether a dated card is overdue, due soon or fine.\n *\n * A board's rule is `{ field, soonDays?, variantWhen? }`. `field` is a\n * dot-path to the date on the row. `soonDays` (default 3) is how many days\n * ahead still counts as \"soon\"; a date before today is overdue.\n *\n * The deciding is done by `utils/dateVariant.js`, the same rules a table's\n * date cell uses, so a list and its board agree on what late means.\n * `{ soonDays: 3 }` is shorthand for\n * `variantWhen: [{ op: 'lt', value: 0, variant: 'error' }, { op: 'lte', value: 3, variant: 'warning' }]`,\n * and a rule that carries its own `variantWhen` is used as written:\n * `error` reads as overdue, `warning` as due soon.\n *\n * @module utils/dueRule\n */\n\nimport { daysUntil, parseDateValue, resolveDateVariant } from './dateVariant.js'\nimport { readPath } from './readPath.js'\n\nexport { daysUntil }\n\n/** How many days ahead counts as \"soon\" when the rule does not say. */\nexport const DEFAULT_SOON_DAYS = 3\n\n/**\n * Local midnight of a date value. A bare `YYYY-MM-DD` is a LOCAL day.\n *\n * @param {unknown} value A Date, a timestamp or a date string.\n * @return {Date|null} Local midnight of that day, or null when unreadable.\n * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-late-marking-on-board-cards\n */\nexport function toLocalDay(value) {\n\tconst date = parseDateValue(value)\n\treturn date === null ? null : new Date(date.getFullYear(), date.getMonth(), date.getDate())\n}\n\n/**\n * The `variantWhen` rules a due rule stands for.\n *\n * @param {{soonDays?: number, variantWhen?: Array<object>}|null} [rule] The due rule.\n * @return {Array<{op: string, value: number, variant: string}>} The rules `resolveDateVariant` takes.\n * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-late-marking-on-board-cards\n */\nexport function dueRuleToVariantWhen(rule = {}) {\n\tif (Array.isArray(rule?.variantWhen) && rule.variantWhen.length > 0) {\n\t\treturn rule.variantWhen\n\t}\n\tconst given = rule?.soonDays\n\tconst soonDays = given !== null && given !== undefined && Number.isFinite(Number(given)) ? Number(given) : DEFAULT_SOON_DAYS\n\treturn [\n\t\t{ op: 'lt', value: 0, variant: 'error' },\n\t\t{ op: 'lte', value: soonDays, variant: 'warning' },\n\t]\n}\n\n/**\n * The due state of one date under a rule.\n *\n * @param {unknown} value The date.\n * @param {{soonDays?: number, variantWhen?: Array<object>}|null} [rule] The rule.\n * @param {Date} [now] The moment to measure from.\n * @return {'overdue'|'soon'|'ok'|null} The state, or null when there is no readable date.\n * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-late-marking-on-board-cards\n */\nexport function dueStateOf(value, rule = {}, now = new Date()) {\n\tif (daysUntil(value, now) === null) {\n\t\treturn null\n\t}\n\tconst variant = resolveDateVariant(value, dueRuleToVariantWhen(rule), now)\n\tif (variant === 'error') {\n\t\treturn 'overdue'\n\t}\n\treturn variant === 'warning' ? 'soon' : 'ok'\n}\n\n/**\n * The due state of a row under a `{ field, soonDays }` rule.\n *\n * @param {object} row The row or card.\n * @param {{field?: string, soonDays?: number, variantWhen?: Array<object>}|null} rule The rule. Null or field-less means no marking.\n * @param {Date} [now] The moment to measure from.\n * @return {'overdue'|'soon'|'ok'|null} The state, or null when the rule does not apply.\n * @spec openspec/changes/detail-action-model-and-case-surfaces/specs/detail-action-model/spec.md#requirement-late-marking-on-board-cards\n */\nexport function dueStateForRow(row, rule, now = new Date()) {\n\tif (!rule || typeof rule.field !== 'string' || rule.field === '' || !row) {\n\t\treturn null\n\t}\n\treturn dueStateOf(readPath(row, rule.field), rule, now)\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACY,MAAC,iBAAiB,GAAG,EAAC;AAalC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB,CAAC,IAAI,GAAG,EAAE,EAAE;AAChD,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;AACtE,EAAE,OAAO,IAAI,CAAC,WAAW;AACzB,EAAE;AACF,CAAC,MAAM,KAAK,GAAG,IAAI,EAAE,SAAQ;AAC7B,CAAC,MAAM,QAAQ,GAAG,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CA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ggregateValue(source, ctx) {
79
79
  return (res && res.data && res.data.value !== undefined) ? res.data.value : null
80
80
  }
81
81
 
82
- export { fetchAggregateValue, flattenAggFilter };
82
+ /**
83
+ * Fetch the object count per distinct value of one field, in ONE request,
84
+ * from OpenRegister's `/grouped` aggregation endpoint.
85
+ *
86
+ * @param {object} source The grouped descriptor.
87
+ * @param {string} source.register The register slug.
88
+ * @param {string} source.schema The schema slug.
89
+ * @param {string} source.groupBy The field to group on.
90
+ * @param {object} [source.filter] The filter map.
91
+ * @param {{objectId?: (string|number), object?: object, workspace?: object}} [ctx] Optional
92
+ * token-resolution context for the filter.
93
+ * @return {Promise<Array<{key: string, count: number}>>} One entry per group; [] when the source is incomplete.
94
+ * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-stacked-bar-widget
95
+ */
96
+ async function fetchGroupedCounts(source, ctx) {
97
+ const s = source || {};
98
+ if (!s.register || !s.schema || !s.groupBy) {
99
+ return []
100
+ }
101
+ const [{ default: axios }, { generateUrl }] = await Promise.all([
102
+ import('@nextcloud/axios'),
103
+ import('@nextcloud/router'),
104
+ ]);
105
+ const url = generateUrl(
106
+ '/apps/openregister/api/objects/aggregations/{register}/{schema}/grouped',
107
+ { register: s.register, schema: s.schema },
108
+ );
109
+ const params = { groupBy: s.groupBy, metric: 'count' };
110
+ flattenAggFilter(params, s.filter || {}, ctx);
111
+ const res = await axios.get(url, { params });
112
+ const groups = (res && res.data && Array.isArray(res.data.groups)) ? res.data.groups : [];
113
+ return groups
114
+ .filter((g) => g && g.key !== null && g.key !== undefined && g.key !== '')
115
+ .map((g) => ({ key: String(g.key), count: Number(g.value) || 0 }))
116
+ }
117
+
118
+ export { fetchAggregateValue, fetchGroupedCounts, flattenAggFilter };
83
119
  //# sourceMappingURL=fetchAggregate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetchAggregate.js","sources":["../../../src/utils/fetchAggregate.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * Shared helper for the abstract data widgets (CnStatWidget, CnDeltaWidget,\n * CnGaugeWidget, …) — fetches ONE scalar from OpenRegister's ad-hoc aggregation\n * `/value` endpoint given a `{ register, schema, metric, field, filter }`\n * descriptor. Filter values run through `resolveFilterTokens` first, so relative\n * tokens (`@me`, `@monthStart`, `@currentFiscalYear`, …) resolve at fetch time.\n *\n * @module utils/fetchAggregate\n */\n\nimport { resolveFilterTokens } from './resolveFilterTokens.js'\n\n/**\n * Flatten a filter map into operator-aware `filter[key]` / `filter[key][op]`\n * query params (the OpenRegister aggregation filter vocabulary). Resolves\n * relative tokens before writing.\n *\n * @param {object} target The params object to write into.\n * @param {object} filter The filter map.\n * @param {{objectId?: (string|number), object?: object, workspace?: object}} [ctx] Optional\n * token-resolution context forwarded to {@link resolveFilterTokens} so a\n * detail-page aggregate can scope its filter to the current object via\n * `@objectId` / `@object.<field>`.\n * @return {void}\n */\nexport function flattenAggFilter(target, filter, ctx) {\n\tif (!filter || typeof filter !== 'object') {\n\t\treturn\n\t}\n\tfilter = resolveFilterTokens(filter, ctx)\n\tfor (const [k, v] of Object.entries(filter)) {\n\t\tif (v && typeof v === 'object') {\n\t\t\tfor (const [op, ov] of Object.entries(v)) {\n\t\t\t\ttarget[`filter[${k}][${op}]`] = ov\n\t\t\t}\n\t\t} else if (v !== '' && v !== null && v !== undefined) {\n\t\t\ttarget[`filter[${k}]`] = v\n\t\t}\n\t}\n}\n\n/**\n * Fetch one aggregated scalar from OpenRegister.\n *\n * @param {object} source The aggregate descriptor.\n * @param {string} source.register The register slug.\n * @param {string} source.schema The schema slug.\n * @param {string} [source.metric] count | sum | avg | min | max (default count).\n * @param {string} [source.field] The numeric field (required for non-count metrics).\n * @param {object} [source.filter] The filter map.\n * @param {{objectId?: (string|number), object?: object, workspace?: object}} [ctx] Optional\n * token-resolution context (a detail page's object context) so the filter can\n * scope to the current object via `@objectId` / `@object.<field>`.\n * @return {Promise<number|null>} The aggregated value, or null when unavailable.\n */\nexport async function fetchAggregateValue(source, ctx) {\n\tconst s = source || {}\n\tif (!s.register || !s.schema) {\n\t\treturn null\n\t}\n\tconst [{ default: axios }, { generateUrl }] = await Promise.all([\n\t\timport('@nextcloud/axios'),\n\t\timport('@nextcloud/router'),\n\t])\n\tconst url = generateUrl(\n\t\t'/apps/openregister/api/objects/aggregations/{register}/{schema}/value',\n\t\t{ register: s.register, schema: s.schema },\n\t)\n\tconst params = { metric: s.metric || 'count' }\n\tif (s.field) {\n\t\tparams.field = s.field\n\t}\n\tflattenAggFilter(params, s.filter || {}, ctx)\n\tconst res = await axios.get(url, { params })\n\treturn (res && res.data && res.data.value !== undefined) ? res.data.value : null\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE;AACtD,CAAC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;AAC5C,EAAE,MAAM;AACR,EAAE;AACF,CAAC,MAAM,GAAG,mBAAmB,CAAC,MAAM,EAAE,GAAG,EAAC;AAC1C,CAAC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AAC9C,EAAE,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;AAClC,GAAG,KAAK,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;AAC7C,IAAI,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,GAAE;AACtC,IAAI;AACJ,GAAG,MA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,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI;AACjF;;;;"}
1
+ {"version":3,"file":"fetchAggregate.js","sources":["../../../src/utils/fetchAggregate.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * Shared helper for the abstract data widgets (CnStatWidget, CnDeltaWidget,\n * CnGaugeWidget, …) — fetches ONE scalar from OpenRegister's ad-hoc aggregation\n * `/value` endpoint given a `{ register, schema, metric, field, filter }`\n * descriptor. Filter values run through `resolveFilterTokens` first, so relative\n * tokens (`@me`, `@monthStart`, `@currentFiscalYear`, …) resolve at fetch time.\n *\n * @module utils/fetchAggregate\n */\n\nimport { resolveFilterTokens } from './resolveFilterTokens.js'\n\n/**\n * Flatten a filter map into operator-aware `filter[key]` / `filter[key][op]`\n * query params (the OpenRegister aggregation filter vocabulary). Resolves\n * relative tokens before writing.\n *\n * @param {object} target The params object to write into.\n * @param {object} filter The filter map.\n * @param {{objectId?: (string|number), object?: object, workspace?: object}} [ctx] Optional\n * token-resolution context forwarded to {@link resolveFilterTokens} so a\n * detail-page aggregate can scope its filter to the current object via\n * `@objectId` / `@object.<field>`.\n * @return {void}\n */\nexport function flattenAggFilter(target, filter, ctx) {\n\tif (!filter || typeof filter !== 'object') {\n\t\treturn\n\t}\n\tfilter = resolveFilterTokens(filter, ctx)\n\tfor (const [k, v] of Object.entries(filter)) {\n\t\tif (v && typeof v === 'object') {\n\t\t\tfor (const [op, ov] of Object.entries(v)) {\n\t\t\t\ttarget[`filter[${k}][${op}]`] = ov\n\t\t\t}\n\t\t} else if (v !== '' && v !== null && v !== undefined) {\n\t\t\ttarget[`filter[${k}]`] = v\n\t\t}\n\t}\n}\n\n/**\n * Fetch one aggregated scalar from OpenRegister.\n *\n * @param {object} source The aggregate descriptor.\n * @param {string} source.register The register slug.\n * @param {string} source.schema The schema slug.\n * @param {string} [source.metric] count | sum | avg | min | max (default count).\n * @param {string} [source.field] The numeric field (required for non-count metrics).\n * @param {object} [source.filter] The filter map.\n * @param {{objectId?: (string|number), object?: object, workspace?: object}} [ctx] Optional\n * token-resolution context (a detail page's object context) so the filter can\n * scope to the current object via `@objectId` / `@object.<field>`.\n * @return {Promise<number|null>} The aggregated value, or null when unavailable.\n */\nexport async function fetchAggregateValue(source, ctx) {\n\tconst s = source || {}\n\tif (!s.register || !s.schema) {\n\t\treturn null\n\t}\n\tconst [{ default: axios }, { generateUrl }] = await Promise.all([\n\t\timport('@nextcloud/axios'),\n\t\timport('@nextcloud/router'),\n\t])\n\tconst url = generateUrl(\n\t\t'/apps/openregister/api/objects/aggregations/{register}/{schema}/value',\n\t\t{ register: s.register, schema: s.schema },\n\t)\n\tconst params = { metric: s.metric || 'count' }\n\tif (s.field) {\n\t\tparams.field = s.field\n\t}\n\tflattenAggFilter(params, s.filter || {}, ctx)\n\tconst res = await axios.get(url, { params })\n\treturn (res && res.data && res.data.value !== undefined) ? res.data.value : null\n}\n\n/**\n * Fetch the object count per distinct value of one field, in ONE request,\n * from OpenRegister's `/grouped` aggregation endpoint.\n *\n * @param {object} source The grouped descriptor.\n * @param {string} source.register The register slug.\n * @param {string} source.schema The schema slug.\n * @param {string} source.groupBy The field to group on.\n * @param {object} [source.filter] The filter map.\n * @param {{objectId?: (string|number), object?: object, workspace?: object}} [ctx] Optional\n * token-resolution context for the filter.\n * @return {Promise<Array<{key: string, count: number}>>} One entry per group; [] when the source is incomplete.\n * @spec openspec/changes/workplace-dashboard-primitives/specs/workplace-dashboard-primitives/spec.md#requirement-stacked-bar-widget\n */\nexport async function fetchGroupedCounts(source, ctx) {\n\tconst s = source || {}\n\tif (!s.register || !s.schema || !s.groupBy) {\n\t\treturn []\n\t}\n\tconst [{ default: axios }, { generateUrl }] = await Promise.all([\n\t\timport('@nextcloud/axios'),\n\t\timport('@nextcloud/router'),\n\t])\n\tconst url = generateUrl(\n\t\t'/apps/openregister/api/objects/aggregations/{register}/{schema}/grouped',\n\t\t{ register: s.register, schema: s.schema },\n\t)\n\tconst params = { groupBy: s.groupBy, metric: 'count' }\n\tflattenAggFilter(params, s.filter || {}, ctx)\n\tconst res = await axios.get(url, { params })\n\tconst groups = (res && res.data && Array.isArray(res.data.groups)) ? res.data.groups : []\n\treturn groups\n\t\t.filter((g) => g && g.key !== null && g.key !== undefined && g.key !== '')\n\t\t.map((g) => ({ key: String(g.key), count: Number(g.value) || 0 }))\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE;AACtD,CAAC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;AAC5C,EAAE,MAAM;AACR,EAAE;AACF,CAAC,MAAM,GAAG,mBAAmB,CAAC,MAAM,EAAE,GAAG,EAAC;AAC1C,CAAC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AAC9C,EAAE,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;AAClC,GAAG,KAAK,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;AAC7C,IAAI,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,GAAE;AACtC,IAAI;AACJ,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,EAAE;AACxD,GAAG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