@datagouv/components-next 1.2.0 → 1.4.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 (138) hide show
  1. package/README.md +7 -6
  2. package/dist/{Control-ZFh5ta_U.js → Control-B9WQxlpJ.js} +1 -1
  3. package/dist/{Datafair.client-rf4T1IkA.js → Datafair.client-D_6yzJUG.js} +9 -9
  4. package/dist/{Event-DSQcW7OF.js → Event-iXDrp-fy.js} +11 -11
  5. package/dist/{Image-BijNEG0p.js → Image-mNMBOofs.js} +5 -5
  6. package/dist/ImagePreview.client-B0iPhFm3.js +36 -0
  7. package/dist/{JsonPreview.client-dzar6iuh.js → JsonPreview.client-DSl1kiwC.js} +5 -5
  8. package/dist/{Map-BUtPf5GN.js → Map-BfqKMw0S.js} +1306 -1166
  9. package/dist/{MapContainer.client-D-MoRNhG.js → MapContainer.client-BSfpk_rT.js} +15 -15
  10. package/dist/{OSM-D4MTdBtk.js → OSM-CcrUhItr.js} +15 -23
  11. package/dist/{PdfPreview.client-DoDYLmJD.js → PdfPreview.client-BANFeM6K.js} +441 -434
  12. package/dist/Pmtiles.client-DH9ZrsZR.js +26333 -0
  13. package/dist/PreviewWrapper.vue_vue_type_script_setup_true_lang-I8EZCgzp.js +60 -0
  14. package/dist/{ScaleLine-hJQIqcZm.js → ScaleLine-VGQ7nkMS.js} +2 -2
  15. package/dist/{Tile-Dcl7oIVu.js → Tile-CSpn0Ca8.js} +153 -156
  16. package/dist/{TileImage-BJeHipMX.js → TileImage-CpbaEFwd.js} +143 -131
  17. package/dist/{View-xp_P_OHw.js → View-BYBpt-AU.js} +167 -117
  18. package/dist/{XmlPreview.client-cOhwff6P.js → XmlPreview.client-KCB5mwVf.js} +5 -5
  19. package/dist/{common-BjQlan3k.js → common-BoeTUnDZ.js} +26 -26
  20. package/dist/components-next.css +1 -52
  21. package/dist/components-next.js +201 -170
  22. package/dist/components.css +2 -2
  23. package/dist/{index-NofRBuyf.js → index-DHWzX5vK.js} +5999 -5472
  24. package/dist/{leaflet-src-7m1mB8LI.js → leaflet-src-pVQfonBI.js} +162 -164
  25. package/dist/{main-Iz1ZCL6k.js → main-BDcYkhOc.js} +36671 -29402
  26. package/dist/{proj-CsNo9yH1.js → proj-DxGbobp7.js} +312 -296
  27. package/dist/{text-clamp.esm-B5kW_XMt.js → text-clamp.esm-DVseBqZZ.js} +4 -4
  28. package/dist/{tilecoord-A0fLnBZr.js → tilecoord-DvX7WWiA.js} +264 -255
  29. package/dist/{vue3-json-viewer-BXwup7nO.js → vue3-json-viewer-CJLQFzXZ.js} +10 -16
  30. package/dist/{vue3-xml-viewer.common-tVI9uXUz.js → vue3-xml-viewer.common-Bdcn54ST.js} +1 -1
  31. package/package.json +40 -39
  32. package/src/components/ActivityList/ActivityList.vue +21 -12
  33. package/src/components/AppLink.vue +3 -0
  34. package/src/components/BannerAction.vue +6 -2
  35. package/src/components/Chart/ChartViewer.vue +111 -17
  36. package/src/components/Chart/ChartViewerWrapper.vue +28 -16
  37. package/src/components/ChartCard.vue +112 -0
  38. package/src/components/CopyButton.vue +6 -2
  39. package/src/components/DataserviceCard.vue +23 -6
  40. package/src/components/DataserviceQuality.vue +82 -0
  41. package/src/components/DataserviceQualityInline.vue +31 -0
  42. package/src/components/DataserviceQualityTooltipContent.vue +79 -0
  43. package/src/components/DatasetCard.vue +17 -6
  44. package/src/components/DatasetInformation/DatasetTemporalitySection.vue +7 -4
  45. package/src/components/DatasetQuality.vue +11 -11
  46. package/src/components/DatasetQualityInline.vue +2 -2
  47. package/src/components/DatasetQualityTooltipContent.vue +1 -1
  48. package/src/components/DiscussionMessageCard.vue +14 -15
  49. package/src/components/Form/SchemaSelect.vue +2 -0
  50. package/src/components/FormattedDate.vue +69 -0
  51. package/src/components/LoadingBlock.vue +4 -1
  52. package/src/components/ObjectCard.vue +4 -1
  53. package/src/components/ObjectCardOwner.vue +13 -1
  54. package/src/components/Pagination.vue +18 -58
  55. package/src/components/Placeholder.vue +3 -2
  56. package/src/components/PostCard.vue +13 -15
  57. package/src/components/ResourceAccordion/Datafair.client.vue +1 -1
  58. package/src/components/ResourceAccordion/Downloads.vue +19 -7
  59. package/src/components/ResourceAccordion/ImagePreview.client.vue +48 -0
  60. package/src/components/ResourceAccordion/MapContainer.client.vue +1 -8
  61. package/src/components/ResourceAccordion/Metadata.vue +21 -5
  62. package/src/components/ResourceAccordion/PdfPreview.client.vue +36 -12
  63. package/src/components/ResourceAccordion/PdfSkeleton.vue +44 -0
  64. package/src/components/ResourceAccordion/Pmtiles.client.vue +30 -19
  65. package/src/components/ResourceAccordion/Preview.vue +8 -4
  66. package/src/components/ResourceAccordion/PreviewWrapper.vue +17 -10
  67. package/src/components/ResourceAccordion/ResourceAccordion.vue +31 -11
  68. package/src/components/ResourceExplorer/ResourceExplorer.vue +105 -210
  69. package/src/components/ResourceExplorer/ResourceExplorerHeader.vue +79 -0
  70. package/src/components/ResourceExplorer/ResourceExplorerSidebar.vue +104 -71
  71. package/src/components/ResourceExplorer/ResourceExplorerViewer.vue +140 -184
  72. package/src/components/ResourceExplorer/ResourceMainAction.vue +240 -0
  73. package/src/components/ResourceExplorer/ResourceSelector.vue +24 -86
  74. package/src/components/ResourceExplorer/ResourceViewerHeader.vue +124 -0
  75. package/src/components/ResourceExplorer/ResourceViewerSkeleton.vue +96 -0
  76. package/src/components/ResourceListItem.vue +168 -0
  77. package/src/components/ReuseCard.vue +18 -6
  78. package/src/components/ReuseDetails.vue +2 -2
  79. package/src/components/ReuseHorizontalCard.vue +4 -3
  80. package/src/components/SchemaCard.vue +10 -1
  81. package/src/components/Search/Filter/AccessTypeFilter.vue +2 -2
  82. package/src/components/Search/GlobalSearch.vue +28 -10
  83. package/src/components/Search/SearchInput.vue +1 -1
  84. package/src/components/Search/Sidemenu.vue +4 -3
  85. package/src/components/SmallChart.vue +11 -10
  86. package/src/components/StatBox.vue +13 -5
  87. package/src/components/TabularExplorer/TabularActiveFilters.vue +79 -0
  88. package/src/components/TabularExplorer/TabularCell.vue +7 -8
  89. package/src/components/TabularExplorer/TabularCellPopover.vue +21 -5
  90. package/src/components/TabularExplorer/TabularColumnsMenu.vue +112 -0
  91. package/src/components/TabularExplorer/TabularDateField.vue +41 -0
  92. package/src/components/TabularExplorer/TabularDateFilter.vue +403 -0
  93. package/src/components/TabularExplorer/TabularExplorer.vue +127 -780
  94. package/src/components/TabularExplorer/TabularFilterContent.vue +48 -38
  95. package/src/components/TabularExplorer/TabularFilterPopover.vue +27 -32
  96. package/src/components/TabularExplorer/TabularMobileFilterButton.vue +21 -0
  97. package/src/components/TabularExplorer/TabularMobileFilters.vue +150 -0
  98. package/src/components/TabularExplorer/TabularRowsInfo.vue +31 -0
  99. package/src/components/TabularExplorer/TabularSkeleton.vue +92 -0
  100. package/src/components/TabularExplorer/TabularTable.vue +484 -0
  101. package/src/components/TabularExplorer/TabularToolbar.vue +25 -0
  102. package/src/components/TabularExplorer/types.ts +40 -28
  103. package/src/components/TabularExplorer/useColumnMetadata.ts +98 -0
  104. package/src/components/TabularExplorer/useTabularContext.ts +82 -0
  105. package/src/components/TopicCard.vue +15 -14
  106. package/src/composables/useActiveDescendant.ts +5 -0
  107. package/src/composables/useDatasetResources.ts +164 -0
  108. package/src/composables/useHasTabularData.ts +2 -1
  109. package/src/composables/useResizable.ts +46 -0
  110. package/src/composables/useResourceCapabilities.ts +48 -40
  111. package/src/composables/useSearchFilter.ts +7 -5
  112. package/src/composables/useTranslation.ts +24 -9
  113. package/src/config.ts +1 -0
  114. package/src/functions/api.ts +13 -7
  115. package/src/functions/charts.ts +32 -1
  116. package/src/functions/dates.ts +26 -7
  117. package/src/functions/helpers.ts +15 -0
  118. package/src/functions/metrics.ts +57 -56
  119. package/src/functions/owned.ts +21 -0
  120. package/src/functions/paginate.ts +46 -0
  121. package/src/functions/resourceCapabilities.ts +34 -0
  122. package/src/functions/resources.ts +88 -0
  123. package/src/functions/schemas.ts +27 -0
  124. package/src/functions/scroll.ts +20 -0
  125. package/src/functions/tabular.ts +222 -5
  126. package/src/functions/tabularApi.ts +1 -43
  127. package/src/main.ts +32 -6
  128. package/src/types/dataservices.ts +15 -0
  129. package/src/types/organizations.ts +10 -0
  130. package/src/types/resources.ts +0 -1
  131. package/src/types/reuses.ts +12 -1
  132. package/src/types/search.ts +2 -2
  133. package/src/types/visualizations.ts +5 -0
  134. package/dist/Pmtiles.client-Dzm01Zfm.js +0 -25185
  135. package/dist/PreviewWrapper.vue_vue_type_script_setup_true_lang-BRNYswg3.js +0 -61
  136. /package/src/components/{DatasetQualityItem.vue → QualityItem.vue} +0 -0
  137. /package/src/components/{DatasetQualityItemWarning.vue → QualityItemWarning.vue} +0 -0
  138. /package/src/components/{DatasetQualityScore.vue → QualityScore.vue} +0 -0
@@ -1,4 +1,4 @@
1
- import { defineComponent as T, ref as k, onMounted as J, h as g, watch as F, computed as O, inject as $, provide as q, createElementBlock as _, openBlock as N, normalizeClass as S, toDisplayString as A, resolveComponent as ie, createCommentVNode as Y, createElementVNode as z, renderSlot as ce, createTextVNode as pe, createVNode as fe, nextTick as de } from "vue";
1
+ import { defineComponent as T, ref as k, onMounted as J, h as g, watch as F, computed as O, inject as $, provide as q, openBlock as _, createElementBlock as N, toDisplayString as A, normalizeClass as S, resolveComponent as ie, createElementVNode as z, renderSlot as ce, createTextVNode as pe, createCommentVNode as Y, createVNode as fe, nextTick as de } from "vue";
2
2
  const ve = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/, X = T({
3
3
  name: "JsonString",
4
4
  props: {
@@ -66,7 +66,7 @@ const ve = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)
66
66
  },
67
67
  setup(e) {
68
68
  const y = e, c = O(() => y.jsonValue === null ? "null" : "undefined");
69
- return (p, d) => (N(), _("span", ye, A(c.value), 1));
69
+ return (p, d) => (_(), N("span", ye, A(c.value), 1));
70
70
  }
71
71
  }), he = /* @__PURE__ */ T({
72
72
  __name: "json-number",
@@ -79,7 +79,7 @@ const ve = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)
79
79
  },
80
80
  setup(e) {
81
81
  const y = e, c = O(() => Number.isInteger(y.jsonValue));
82
- return (p, d) => (N(), _("span", {
82
+ return (p, d) => (_(), N("span", {
83
83
  class: S(["jv-item", "jv-number", c.value ? "jv-number-integer" : "jv-number-float"])
84
84
  }, A(e.jsonValue.toString()), 3));
85
85
  }
@@ -95,7 +95,7 @@ const ve = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)
95
95
  }
96
96
  },
97
97
  setup(e) {
98
- return (y, c) => (N(), _("span", ge, A(e.jsonValue.toString()), 1));
98
+ return (y, c) => (_(), N("span", ge, A(e.jsonValue.toString()), 1));
99
99
  }
100
100
  }), je = T({
101
101
  name: "JsonObject",
@@ -277,7 +277,7 @@ const ve = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)
277
277
  }
278
278
  },
279
279
  setup(e) {
280
- return (y, c) => (N(), _("span", {
280
+ return (y, c) => (_(), N("span", {
281
281
  class: S(["jv-item", "jv-function"]),
282
282
  title: e.jsonValue.toString()
283
283
  }, " <function> ", 8, Ee));
@@ -295,7 +295,7 @@ const ve = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)
295
295
  },
296
296
  setup(e) {
297
297
  const y = e, c = $("timeformat", (d) => d.toLocaleString()), p = O(() => c(y.jsonValue));
298
- return (d, i) => (N(), _("span", ke, ' "' + A(p.value) + '" ', 1));
298
+ return (d, i) => (_(), N("span", ke, ' "' + A(p.value) + '" ', 1));
299
299
  }
300
300
  }), Te = {
301
301
  class: /* @__PURE__ */ S(["jv-item", "jv-regexp"])
@@ -309,7 +309,7 @@ const ve = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)
309
309
  }
310
310
  },
311
311
  setup(e) {
312
- return (y, c) => (N(), _("span", Te, A(e.jsonValue.toString()), 1));
312
+ return (y, c) => (_(), N("span", Te, A(e.jsonValue.toString()), 1));
313
313
  }
314
314
  }), I = T({
315
315
  name: "JsonBox",
@@ -421,12 +421,6 @@ function _e(e) {
421
421
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
422
422
  }
423
423
  var H = { exports: {} };
424
- /*!
425
- * clipboard.js v2.0.11
426
- * https://clipboardjs.com/
427
- *
428
- * Licensed MIT © Zeno Rocha
429
- */
430
424
  var Ne = H.exports, Z;
431
425
  function Oe() {
432
426
  return Z || (Z = 1, (function(e, y) {
@@ -1041,10 +1035,10 @@ const Me = /* @__PURE__ */ _e(Ae), Ve = function(e, y) {
1041
1035
  };
1042
1036
  function Re(e, y, c, p, d, i) {
1043
1037
  const n = ie("json-box");
1044
- return N(), _("div", {
1038
+ return _(), N("div", {
1045
1039
  class: S(e.jvClass)
1046
1040
  }, [
1047
- e.copyable ? (N(), _("div", {
1041
+ e.copyable ? (_(), N("div", {
1048
1042
  key: 0,
1049
1043
  class: S(`jv-tooltip ${e.copyText.align || "right"}`)
1050
1044
  }, [
@@ -1067,7 +1061,7 @@ function Re(e, y, c, p, d, i) {
1067
1061
  "preview-mode": e.previewMode
1068
1062
  }, null, 8, ["value", "sort", "preview-mode"])
1069
1063
  ], 2),
1070
- e.expandableCode && e.boxed ? (N(), _("div", {
1064
+ e.expandableCode && e.boxed ? (_(), N("div", {
1071
1065
  key: 1,
1072
1066
  class: "jv-more",
1073
1067
  onClick: y[0] || (y[0] = (...t) => e.toggleExpandCode && e.toggleExpandCode(...t))
@@ -1,4 +1,4 @@
1
- import { c as Ke } from "./main-Iz1ZCL6k.js";
1
+ import { g as Ke } from "./main-BDcYkhOc.js";
2
2
  import We from "vue";
3
3
  function Fe(I, K) {
4
4
  for (var V = 0; V < K.length; V++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datagouv/components-next",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -23,28 +23,31 @@
23
23
  "src"
24
24
  ],
25
25
  "dependencies": {
26
- "@floating-ui/vue": "^1.1.11",
26
+ "@floating-ui/vue": "^2.0.1",
27
27
  "@headlessui/vue": "^1.7.23",
28
- "@remixicon/vue": "^4.5.0",
29
- "@types/hast": "^3.0.4",
30
- "@types/leaflet": "^1.9.17",
31
- "@vueuse/core": "^14.2.1",
32
- "@vueuse/router": "^14.2.1",
33
- "chart.js": "^4.4.8",
34
- "dompurify": "^3.2.5",
35
- "geopf-extensions-openlayers": "^1.0.0-beta.10",
28
+ "@internationalized/date": "^3.12.4",
29
+ "@remixicon/vue": "^4.9.0",
30
+ "@types/hast": "^3.0.5",
31
+ "@types/leaflet": "^1.9.22",
32
+ "@vueuse/core": "^14.4.0",
33
+ "@vueuse/router": "^14.4.0",
34
+ "chart.js": "^4.5.1",
35
+ "dompurify": "^3.4.15",
36
+ "echarts": "^6.1.0",
37
+ "geopf-extensions-openlayers": "1.0.0-beta.11",
36
38
  "leaflet": "^1.9.4",
37
- "maplibre-gl": "^5.6.2",
38
- "ofetch": "^1.4.1",
39
- "ol": "^10.6.1",
39
+ "maplibre-gl": "^5.24.0",
40
+ "ofetch": "^1.5.1",
41
+ "ol": "^10.10.0",
40
42
  "pdfjs-dist": "^4.10.38",
41
- "pmtiles": "^4.3.0",
42
- "popmotion": "^11.0",
43
+ "pmtiles": "^4.5.0",
44
+ "popmotion": "^11.0.5",
43
45
  "rehype-highlight": "^7.0.2",
44
46
  "rehype-raw": "^7.0.0",
45
47
  "rehype-sanitize": "^6.0.0",
46
48
  "rehype-slug": "^6.0.0",
47
49
  "rehype-stringify": "^10.0.1",
50
+ "reka-ui": "^2.10.4",
48
51
  "remark-behead": "^3.1.0",
49
52
  "remark-breaks": "^4.0.0",
50
53
  "remark-gfm": "^4.0.1",
@@ -53,44 +56,42 @@
53
56
  "strip-markdown": "^6.0.0",
54
57
  "stylefire": "^7.0.3",
55
58
  "unified": "^11.0.5",
56
- "unist-util-visit": "^5.0.0",
59
+ "unist-util-visit": "^5.1.0",
57
60
  "vue-content-loader": "^2.0.1",
58
61
  "vue-sonner": "^2.0.9",
59
62
  "vue3-json-viewer": "^2.4.1",
60
63
  "vue3-text-clamp": "^0.1.2",
61
64
  "vue3-xml-viewer": "^0.0.14",
62
- "yaml": "^2.8.2"
65
+ "yaml": "^2.9.0"
63
66
  },
64
67
  "devDependencies": {
65
- "@intlify/cli": "^0.13.1",
66
- "@tailwindcss/cli": "^4.0.8",
67
- "@tailwindcss/typography": "^0.5.16",
68
- "@tsconfig/node22": "^22.0.0",
68
+ "@tailwindcss/cli": "^4.3.3",
69
+ "@tailwindcss/typography": "^0.5.20",
70
+ "@tsconfig/node22": "^22.0.6",
69
71
  "@types/geojson": "^7946.0.16",
70
- "@types/node": "^22.13.1",
71
- "@vitejs/plugin-vue": "^6.0",
72
+ "@types/node": "^22.20.2",
73
+ "@vitejs/plugin-vue": "^6.0.8",
72
74
  "@vue/eslint-config-prettier": "^10.2.0",
73
- "@vue/eslint-config-typescript": "^14.3.0",
74
- "@vue/tsconfig": "^0.8.0",
75
- "echarts": "^6.0.0",
76
- "eslint": "^9.18.0",
77
- "eslint-plugin-vue": "^10.0",
78
- "jiti": "^2.4.2",
79
- "npm-run-all2": "^8.0",
75
+ "@vue/eslint-config-typescript": "^14.9.0",
76
+ "@vue/tsconfig": "^0.8.1",
77
+ "eslint": "^9.39.5",
78
+ "eslint-plugin-vue": "^10.11.0",
79
+ "jiti": "^2.7.0",
80
+ "npm-run-all2": "^8.0.4",
80
81
  "openapi-types": "^12.1.3",
81
- "prettier": "^3.0.0",
82
- "tailwindcss": "^4.0.8",
82
+ "prettier": "^3.9.6",
83
+ "tailwindcss": "^4.3.3",
83
84
  "typescript": "^5.9.3",
84
- "vite": "^7.0",
85
- "vite-plugin-vue-devtools": "^8.0",
86
- "vue": "^3.5.33",
87
- "vue-router": "^5.0.4",
88
- "vue-tsc": "^3.0"
85
+ "vite": "^7.3.6",
86
+ "vite-plugin-vue-devtools": "^8.2.1",
87
+ "vue": "^3.5.42",
88
+ "vue-router": "^5.3.1",
89
+ "vue-tsc": "^3.3.11"
89
90
  },
90
91
  "peerDependencies": {
92
+ "echarts": "^6.0.0",
91
93
  "vue": "^3.5.13",
92
- "vue-router": "^4.5.0 || ^5.0.0",
93
- "echarts": "^6.0.0"
94
+ "vue-router": "^4.5.0 || ^5.0.0"
94
95
  },
95
96
  "scarfSettings": {
96
97
  "enabled": false
@@ -12,7 +12,10 @@
12
12
  class="my-1"
13
13
  >
14
14
  <p class="pl-3 mb-1 text-xs text-gray-medium">
15
- {{ month }}
15
+ <FormattedDate
16
+ :date="month"
17
+ :options="{ dateStyle: undefined, year: 'numeric', month: 'long', day: undefined }"
18
+ />
16
19
  </p>
17
20
  <ul
18
21
  class="space-y-2 p-0 m-0"
@@ -82,9 +85,15 @@
82
85
  </template>
83
86
  </slot>
84
87
  </p>
85
- <p class="m-0 flex-none text-xs text-gray-medium">
86
- {{ t('le {date}', { date: formatDate(activity.created_at) }) }}
87
- </p>
88
+ <TranslationT
89
+ tag="p"
90
+ class="m-0 flex-none text-xs text-gray-medium"
91
+ keypath="le {date}"
92
+ >
93
+ <template #date>
94
+ <FormattedDate :date="activity.created_at" />
95
+ </template>
96
+ </TranslationT>
88
97
  </div>
89
98
  </li>
90
99
  </ul>
@@ -118,13 +127,14 @@ import { useRoute } from 'vue-router'
118
127
  import { useTranslation } from '../../composables/useTranslation'
119
128
  import { getActivityTranslation } from '../../functions/activities'
120
129
  import { useFetch } from '../../functions/api'
121
- import { useFormatDate } from '../../functions/dates'
122
130
  import type { PaginatedArray } from '../../types/api'
123
131
  import type { Activity } from '../../types/activity'
124
132
  import Avatar from '../Avatar.vue'
125
133
  import LoadingBlock from '../LoadingBlock.vue'
126
134
  import Pagination from '../Pagination.vue'
127
135
  import PaddedContainer from '../PaddedContainer.vue'
136
+ import FormattedDate from '../FormattedDate.vue'
137
+ import TranslationT from '../TranslationT.vue'
128
138
  import listSrc from '../../../assets/illustrations/list.svg?url'
129
139
 
130
140
  const props = defineProps<{
@@ -133,7 +143,6 @@ const props = defineProps<{
133
143
  }>()
134
144
 
135
145
  const route = useRoute()
136
- const { formatDate } = useFormatDate()
137
146
  const { t } = useTranslation()
138
147
 
139
148
  const page = ref(parseInt(route.query.page as string | undefined ?? '1', 10))
@@ -146,13 +155,13 @@ const { data: activities, status } = await useFetch<PaginatedArray<Activity>>('/
146
155
  },
147
156
  })
148
157
 
158
+ // Grouping on a month read in the reader's timezone would change both the number of
159
+ // groups and their keys between the server render and the browser's — a mismatch on
160
+ // the children themselves, which no `data-allow-mismatch` covers. The `YYYY-MM` the
161
+ // timestamp starts with is the same string for everyone; the month is worded from it
162
+ // at render time.
149
163
  const groupedActivities = computed(() => activities.value?.data.reduce((grouped, activity) => {
150
- const activityMonth = formatDate(activity.created_at, {
151
- dateStyle: undefined,
152
- day: undefined,
153
- month: 'long',
154
- year: 'numeric',
155
- })
164
+ const activityMonth = activity.created_at.slice(0, 7)
156
165
  if (!grouped[activityMonth]) {
157
166
  grouped[activityMonth] = []
158
167
  }
@@ -3,6 +3,7 @@
3
3
  :is="config?.appLink"
4
4
  v-if="config.appLink"
5
5
  :to
6
+ :replace
6
7
  >
7
8
  <slot />
8
9
  </component>
@@ -18,6 +19,7 @@
18
19
  <RouterLink
19
20
  v-else
20
21
  :to
22
+ :replace
21
23
  ><slot /></RouterLink>
22
24
  </template>
23
25
 
@@ -33,6 +35,7 @@ const { locale } = useTranslation()
33
35
 
34
36
  const props = defineProps<{
35
37
  to: string | RouteLocationRaw | null | undefined
38
+ replace?: boolean
36
39
  }>()
37
40
 
38
41
  const isExternal = computed(() => {
@@ -10,7 +10,9 @@
10
10
  >
11
11
  <div>
12
12
  <div class="text-gray-900">
13
- {{ title }}
13
+ <slot name="title">
14
+ {{ title }}
15
+ </slot>
14
16
  </div>
15
17
  <div
16
18
  v-if="$slots.default"
@@ -34,7 +36,9 @@ export const bannerActionTypeKey = Symbol() as InjectionKey<'primary' | 'danger'
34
36
  <script setup lang="ts">
35
37
  const props = defineProps<{
36
38
  type: 'primary' | 'danger' | 'warning'
37
- title: string
39
+ // Optional so the title can be a slot, for instance to make it the toggle of a
40
+ // disclosure whose panel lives in the banner
41
+ title?: string
38
42
  }>()
39
43
 
40
44
  provide(bannerActionTypeKey, props.type)
@@ -13,7 +13,8 @@ import { TitleComponent, TooltipComponent, LegendComponent, GridComponent, Datas
13
13
  import { init, type ECharts as EChartsType } from 'echarts'
14
14
  import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
15
15
  import { summarize } from '../../functions/helpers'
16
- import type { Chart, XAxis, YAxis, XAxisForm, ChartForApi } from '../../types/visualizations'
16
+ import { useFormatDate } from '../../functions/dates'
17
+ import type { Chart, ColumnDefinition, ColumnsDefinition, XAxis, YAxis, XAxisForm, ChartForApi } from '../../types/visualizations'
17
18
  import { useTranslation } from '../../composables/useTranslation'
18
19
 
19
20
  use([CanvasRenderer, LineChart, BarChart, TitleComponent, TooltipComponent, LegendComponent, GridComponent, DatasetComponent])
@@ -22,17 +23,26 @@ const props = defineProps<{
22
23
  chart: Chart | ChartForApi
23
24
  series: {
24
25
  data: Record<string, Array<Record<string, unknown>>>
25
- columns: Record<string, Array<string>>
26
+ columns: ColumnsDefinition
26
27
  }
27
28
  }>()
28
29
 
29
30
  const { locale } = useTranslation()
31
+ const { formatDate } = useFormatDate()
30
32
  const chartContainer = ref<HTMLElement | null>(null)
31
33
  let echartsInstance: EChartsType | null = null
32
34
 
33
- function mapXAxisType(xAxis: XAxis | XAxisForm): 'category' | 'value' {
35
+ function capture(): string | null {
36
+ return echartsInstance?.getDataURL() ?? null
37
+ }
38
+
39
+ defineExpose({ capture })
40
+
41
+ // ECharts has a dedicated 'time' axis type for continuous date values.
42
+ function mapXAxisType(xAxis: XAxis | XAxisForm): 'category' | 'value' | 'time' {
34
43
  if (!xAxis) return 'category'
35
- return (xAxis.type ?? 'discrete') === 'continuous' ? 'value' : 'category'
44
+ if (xAxis.type !== 'continuous') return 'category'
45
+ return isDateAxis.value ? 'time' : 'value'
36
46
  }
37
47
 
38
48
  function buildYAxisFormatter(yAxis: YAxis): ((value: number) => string) | undefined {
@@ -44,6 +54,77 @@ function buildYAxisFormatter(yAxis: YAxis): ((value: number) => string) | undefi
44
54
  }
45
55
  }
46
56
 
57
+ function buildXAxisFormatter(column: ColumnDefinition | null, options?: Intl.DateTimeFormatOptions): ((value: string | number | Date) => string) | undefined {
58
+ if (column?.type !== 'date') return undefined
59
+ return (value: string | number | Date) => {
60
+ if (value === null || value === undefined) return ''
61
+ const date = value instanceof Date ? value : new Date(value)
62
+ if (Number.isNaN(date.getTime())) return String(value)
63
+ return formatDate(date, options ?? { dateStyle: 'short' })
64
+ }
65
+ }
66
+
67
+ function parseXValueAsDate(row: Record<string, unknown>, xColumn: string): Record<string, unknown> {
68
+ const value = row[xColumn]
69
+ if (value === null || value === undefined || value instanceof Date) return row
70
+ if (typeof value === 'string') {
71
+ const date = new Date(value)
72
+ if (!Number.isNaN(date.getTime())) {
73
+ return { ...row, [xColumn]: date }
74
+ }
75
+ }
76
+ return row
77
+ }
78
+
79
+ const xAxisColumn = computed(() => {
80
+ const columnName = props.chart.x_axis.column_x
81
+ if (!columnName) return null
82
+ for (const columns of Object.values(props.series.columns)) {
83
+ const column = columns.find(c => c.name === columnName)
84
+ if (column) return column
85
+ }
86
+ return null
87
+ })
88
+
89
+ const isDateAxis = computed(() => xAxisColumn.value?.type === 'date')
90
+
91
+ const xAxisBounds = computed(() => {
92
+ const columnName = props.chart.x_axis.column_x
93
+ if (!columnName) return { min: undefined, max: undefined }
94
+
95
+ let min: number | undefined
96
+ let max: number | undefined
97
+
98
+ for (const s of props.chart.series) {
99
+ const xColumn = s.column_x_name_override ?? columnName
100
+ const data = props.series.data[s.resource_id]
101
+ if (!data) continue
102
+
103
+ for (const row of data) {
104
+ const value = row[xColumn]
105
+ if (value === null || value === undefined) continue
106
+
107
+ let numericValue: number | undefined
108
+ if (value instanceof Date) {
109
+ numericValue = value.getTime()
110
+ }
111
+ else if (isDateAxis.value && typeof value === 'string') {
112
+ numericValue = new Date(value).getTime()
113
+ }
114
+ else {
115
+ numericValue = Number(value)
116
+ }
117
+
118
+ if (numericValue === undefined || Number.isNaN(numericValue)) continue
119
+
120
+ if (min === undefined || numericValue < min) min = numericValue
121
+ if (max === undefined || numericValue > max) max = numericValue
122
+ }
123
+ }
124
+
125
+ return { min, max }
126
+ })
127
+
47
128
  const echartsOption = computed(() => {
48
129
  const seriesCount = props.chart.series.length
49
130
  if (!props.chart.series || seriesCount === 0) return
@@ -53,16 +134,20 @@ const echartsOption = computed(() => {
53
134
  const yColumn = s.aggregate_y ? `${s.column_y}__${s.aggregate_y}` : s.column_y
54
135
  const resourceId = s.resource_id
55
136
 
56
- if (!xColumn || !yColumn || !resourceId || !s.type || !props.series.data[resourceId] || !props.series.columns[resourceId]) {
137
+ const resourceColumns = props.series.columns[resourceId]
138
+ if (!xColumn || !yColumn || !resourceId || !s.type || !props.series.data[resourceId] || !resourceColumns) {
57
139
  return null
58
140
  }
59
141
 
60
- const sortedData = [...props.series.data[resourceId]]
61
- const sortBy = props.chart.x_axis.sort_x_by
142
+ const rawData = props.series.data[resourceId]
143
+ const sortedData = isDateAxis.value
144
+ ? rawData.map(row => parseXValueAsDate(row, xColumn))
145
+ : [...rawData]
146
+ const sortBy = props.chart.x_axis.sort_x_by ?? (isDateAxis.value ? 'axis_x' : null)
62
147
  const sortDirection = props.chart.x_axis.sort_x_direction ?? 'asc'
63
148
 
64
149
  if (sortBy && sortDirection && props.chart.x_axis.column_x) {
65
- const sortKey = sortBy === 'axis_x' ? xColumn : yColumn
150
+ const sortKey = sortBy === 'axis_y' ? yColumn : xColumn
66
151
  sortedData.sort((a, b) => {
67
152
  const valA = a[sortKey]
68
153
  const valB = b[sortKey]
@@ -110,7 +195,7 @@ const echartsOption = computed(() => {
110
195
  return {
111
196
  series: {
112
197
  type: s.type === 'histogram' ? 'bar' : 'line',
113
- dimensions: s.aggregate_y ? [xColumn, yColumn] : props.series.columns[resourceId],
198
+ dimensions: s.aggregate_y ? [xColumn, yColumn] : resourceColumns.map(c => c.name),
114
199
  name: yColumn,
115
200
  encode: {
116
201
  x: xColumn,
@@ -119,7 +204,7 @@ const echartsOption = computed(() => {
119
204
  } as LineSeriesOption | BarSeriesOption,
120
205
  data: {
121
206
  source: sortedData,
122
- dimensions: s.aggregate_y ? [xColumn, yColumn] : props.series.columns[resourceId],
207
+ dimensions: s.aggregate_y ? [xColumn, yColumn] : resourceColumns.map(c => c.name),
123
208
  },
124
209
  }
125
210
  })
@@ -135,26 +220,30 @@ const echartsOption = computed(() => {
135
220
  seriesData.data.push(curr.data)
136
221
  }
137
222
 
223
+ const xAxisType = mapXAxisType(props.chart.x_axis)
224
+
138
225
  return {
139
226
  dataset: [...seriesData.data],
140
- title: {
141
- text: props.chart.title,
142
- left: 'center',
227
+ textStyle: {
228
+ fontFamily: 'Marianne, arial, sans-serif',
143
229
  },
230
+ color: '#000091',
144
231
  tooltip: {
145
232
  trigger: 'axis' as const,
146
233
  formatter: (params: Array<{ value: Record<string, unknown>, axisValueLabel: string, seriesName: string }>) => {
147
234
  let tooltip = ''
148
- const formatter = new Intl.NumberFormat('fr-FR')
235
+ const valueFormatter = new Intl.NumberFormat(locale)
236
+ const xAxisFormatter = buildXAxisFormatter(xAxisColumn.value, { dateStyle: 'medium' })
149
237
  for (const param of params) {
150
238
  const seriesName = param.seriesName
151
- tooltip += `${format.encodeHTML(param.axisValueLabel)}: <strong>${formatter.format(Number(param.value[seriesName]))}</strong><br>`
239
+ const axisLabel = xAxisFormatter ? xAxisFormatter(param.axisValueLabel) : param.axisValueLabel
240
+ tooltip += `${format.encodeHTML(String(axisLabel))}: <strong>${valueFormatter.format(Number(param.value[seriesName]))}</strong><br>`
152
241
  }
153
242
  return tooltip
154
243
  },
155
244
  },
156
245
  legend: {
157
- show: seriesData.series.length > 1,
246
+ show: false,
158
247
  bottom: 0,
159
248
  },
160
249
  grid: {
@@ -165,8 +254,13 @@ const echartsOption = computed(() => {
165
254
  containLabel: true,
166
255
  },
167
256
  xAxis: {
168
- type: mapXAxisType(props.chart.x_axis),
257
+ type: xAxisType,
169
258
  name: (props.chart.x_axis as XAxis).column_x,
259
+ min: xAxisType !== 'category' ? xAxisColumn.value?.min ?? xAxisBounds.value.min ?? undefined : undefined,
260
+ max: xAxisType !== 'category' ? xAxisColumn.value?.max ?? xAxisBounds.value.max ?? undefined : undefined,
261
+ axisLabel: xAxisType === 'time'
262
+ ? { formatter: buildXAxisFormatter(xAxisColumn.value) }
263
+ : undefined,
170
264
  },
171
265
  yAxis: {
172
266
  type: 'value' as const,
@@ -5,6 +5,7 @@
5
5
  >
6
6
  <template #default="{ data }">
7
7
  <ChartViewer
8
+ ref="chartViewerRef"
8
9
  :chart="chart"
9
10
  :series="data"
10
11
  />
@@ -18,23 +19,28 @@
18
19
  </template>
19
20
 
20
21
  <script setup lang="ts">
21
- import { reactive, ref, watch } from 'vue'
22
+ import { computed, reactive, ref, watch } from 'vue'
22
23
  import ChartViewer from './ChartViewer.vue'
23
24
  import LoadingBlock from '../../components/LoadingBlock.vue'
24
25
  import { useComponentsConfig } from '../../config'
25
26
  import { fetchTabularData, useGetProfile } from '../../functions/tabularApi'
26
- import type { Chart, ChartForApi } from '../../types/visualizations'
27
+ import type { Chart, ChartForApi, ColumnsDefinition } from '../../types/visualizations'
27
28
  import { useTranslation } from '../../composables/useTranslation'
29
+ import { watchDebounced } from '@vueuse/shared'
30
+ import { buildColumnsFromProfile } from '../../functions/charts'
28
31
 
29
32
  const props = defineProps<{
30
33
  chart: Chart | ChartForApi
31
34
  }>()
32
35
 
33
- const emit = defineEmits<{
34
- columns: [columns: Record<string, Array<string>>]
35
- }>()
36
-
37
36
  const { t } = useTranslation()
37
+ const chartViewerRef = ref<InstanceType<typeof ChartViewer> | null>(null)
38
+
39
+ function capture(): string | null {
40
+ return chartViewerRef.value?.capture() ?? null
41
+ }
42
+
43
+ defineExpose({ capture })
38
44
  const config = useComponentsConfig()
39
45
  const getProfile = useGetProfile()
40
46
 
@@ -45,12 +51,18 @@ const pendingOperations = ref(0)
45
51
 
46
52
  const series = reactive<{
47
53
  data: Record<string, Array<Record<string, unknown>>>
48
- columns: Record<string, Array<string>>
54
+ columns: ColumnsDefinition
49
55
  }>({
50
56
  data: {},
51
57
  columns: {},
52
58
  })
53
59
 
60
+ const resourceIds = computed(() => {
61
+ return props.chart.series
62
+ .filter(s => s.resource_id)
63
+ .map(s => s.resource_id)
64
+ })
65
+
54
66
  async function fetchSeriesProfile() {
55
67
  pendingOperations.value++
56
68
  status.value = 'pending'
@@ -78,7 +90,7 @@ async function fetchSeriesProfile() {
78
90
  .map(r => r.value)
79
91
  series.columns = Object.fromEntries(results.map(result => [
80
92
  result.id,
81
- result.profile.profile.header,
93
+ buildColumnsFromProfile(result.profile),
82
94
  ]))
83
95
  }
84
96
  catch (err) {
@@ -86,6 +98,7 @@ async function fetchSeriesProfile() {
86
98
  status.value = 'error'
87
99
  console.error(err)
88
100
  series.columns = {}
101
+ series.data = {}
89
102
  }
90
103
  finally {
91
104
  pendingOperations.value--
@@ -148,17 +161,16 @@ async function fetchSeriesData() {
148
161
  }
149
162
  }
150
163
 
151
- watch(() => props.chart.series, async () => {
164
+ watch(resourceIds, async () => {
152
165
  await fetchSeriesProfile()
153
- }, { immediate: true, deep: true })
166
+ }, { immediate: true })
154
167
 
155
- watch([() => props.chart.series, () => props.chart.x_axis.column_x], async () => {
168
+ watchDebounced([
169
+ () => props.chart.series,
170
+ () => props.chart.x_axis.column_x,
171
+ ], async () => {
156
172
  await fetchSeriesData()
157
- }, { immediate: true, deep: true })
158
-
159
- watch(() => series.columns, () => {
160
- emit('columns', series.columns)
161
- })
173
+ }, { debounce: config.searchDebounce ?? 300, immediate: true, deep: true })
162
174
 
163
175
  watch(pendingOperations, (count) => {
164
176
  if (count === 0) {