@datagouv/components-next 1.0.2-dev.13 → 1.0.2-dev.131

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 (111) hide show
  1. package/README.md +7 -6
  2. package/assets/main.css +4 -0
  3. package/dist/{Control-DuZJdKV_.js → Control-b-43UT2B.js} +10 -10
  4. package/dist/{Datafair.client-8haHXl47.js → Datafair.client-CFl7MKdB.js} +4 -4
  5. package/dist/{Event--kp8kMdJ.js → Event-py_AAwJY.js} +35 -35
  6. package/dist/{Image-34hvypZI.js → Image-BHQYZWzH.js} +23 -23
  7. package/dist/JsonPreview.client-CowJU7XP.js +40 -0
  8. package/dist/{Map-BjUnLyj8.js → Map-CtP7leHl.js} +1742 -1602
  9. package/dist/{MapContainer.client-l6HuXTHR.js → MapContainer.client-CgdBWq2S.js} +37 -38
  10. package/dist/{OSM-s40W6sQ2.js → OSM-gdDSIsDA.js} +15 -23
  11. package/dist/{PdfPreview.client-4OueK-2Z.js → PdfPreview.client-Dm4l4fyb.js} +823 -855
  12. package/dist/Pmtiles.client-DsjzH41p.js +26123 -0
  13. package/dist/PreviewWrapper.vue_vue_type_script_setup_true_lang-BgFVrfFi.js +61 -0
  14. package/dist/{ScaleLine-KW-nXqp3.js → ScaleLine-hG-FhNqy.js} +2 -2
  15. package/dist/{Tile-DbNFNPfU.js → Tile-D6rFonpT.js} +164 -167
  16. package/dist/{TileImage-BsXBxMtq.js → TileImage-cfrEgz5y.js} +131 -119
  17. package/dist/{View-BR92hTWP.js → View-vp7vDb9q.js} +482 -421
  18. package/dist/XmlPreview.client-DBceFnA1.js +34 -0
  19. package/dist/{common-PJfpC179.js → common-C8efyyuc.js} +57 -57
  20. package/dist/components-next.css +1 -52
  21. package/dist/components-next.js +172 -143
  22. package/dist/components.css +2 -2
  23. package/dist/{index-CVTIoZQ0.js → index-DWmJJEjk.js} +21855 -15827
  24. package/dist/{leaflet-src-7m1mB8LI.js → leaflet-src-CGmV0V-K.js} +162 -164
  25. package/dist/main-CQREzlRN.js +72634 -0
  26. package/dist/{proj-DsetBcW7.js → proj-CsjVeojN.js} +663 -627
  27. package/dist/{text-clamp.esm-B5kW_XMt.js → text-clamp.esm-DVseBqZZ.js} +4 -4
  28. package/dist/{tilecoord-Db24Px13.js → tilecoord-CPcQJnrF.js} +258 -249
  29. package/dist/{vue3-json-viewer-BXwup7nO.js → vue3-json-viewer-CJLQFzXZ.js} +10 -16
  30. package/dist/{vue3-xml-viewer.common-CWer_T5-.js → vue3-xml-viewer.common-d08lX8ER.js} +1 -1
  31. package/package.json +50 -36
  32. package/src/chart.ts +5 -0
  33. package/src/components/ActivityList/ActivityList.vue +3 -2
  34. package/src/components/Chart/ChartViewer.vue +227 -0
  35. package/src/components/Chart/ChartViewerWrapper.vue +174 -0
  36. package/src/components/DataserviceCard.vue +3 -0
  37. package/src/components/DatasetCard.vue +9 -4
  38. package/src/components/Form/Listbox.vue +101 -0
  39. package/src/components/Form/SearchableSelect.vue +2 -1
  40. package/src/components/InfiniteLoader.vue +53 -0
  41. package/src/components/ObjectCardHeader.vue +11 -4
  42. package/src/components/OpenApiViewer/ContentTypeSelect.vue +48 -0
  43. package/src/components/OpenApiViewer/EndpointRequest.vue +164 -0
  44. package/src/components/OpenApiViewer/EndpointResponses.vue +149 -0
  45. package/src/components/OpenApiViewer/OpenApiViewer.vue +308 -0
  46. package/src/components/OpenApiViewer/SchemaPanel.vue +53 -0
  47. package/src/components/OpenApiViewer/SchemaTree.vue +77 -0
  48. package/src/components/OpenApiViewer/openapi.ts +150 -0
  49. package/src/components/OrganizationNameWithCertificate.vue +3 -2
  50. package/src/components/Pagination.vue +8 -5
  51. package/src/components/RadioInput.vue +7 -2
  52. package/src/components/ReadMore.vue +1 -1
  53. package/src/components/ResourceAccordion/DataStructure.vue +11 -33
  54. package/src/components/ResourceAccordion/Downloads.vue +160 -0
  55. package/src/components/ResourceAccordion/JsonPreview.client.vue +23 -104
  56. package/src/components/ResourceAccordion/MapContainer.client.vue +1 -3
  57. package/src/components/ResourceAccordion/Metadata.vue +1 -2
  58. package/src/components/ResourceAccordion/PdfPreview.client.vue +24 -87
  59. package/src/components/ResourceAccordion/Pmtiles.client.vue +3 -1
  60. package/src/components/ResourceAccordion/Preview.vue +11 -11
  61. package/src/components/ResourceAccordion/PreviewWrapper.vue +82 -0
  62. package/src/components/ResourceAccordion/ResourceAccordion.vue +12 -111
  63. package/src/components/ResourceAccordion/XmlPreview.client.vue +16 -98
  64. package/src/components/ResourceExplorer/ResourceExplorer.vue +22 -19
  65. package/src/components/ResourceExplorer/ResourceExplorerSidebar.vue +2 -2
  66. package/src/components/ResourceExplorer/ResourceExplorerViewer.vue +50 -148
  67. package/src/components/ResourceExplorer/ResourceSelector.vue +113 -0
  68. package/src/components/ReuseCard.vue +12 -4
  69. package/src/components/Search/GlobalSearch.vue +217 -115
  70. package/src/components/Search/SearchInput.vue +5 -4
  71. package/src/components/TabularExplorer/TabularCell.vue +51 -0
  72. package/src/components/TabularExplorer/TabularCellPopover.vue +170 -0
  73. package/src/components/TabularExplorer/TabularExplorer.vue +1106 -0
  74. package/src/components/TabularExplorer/TabularFilterContent.vue +353 -0
  75. package/src/components/TabularExplorer/TabularFilterPopover.vue +106 -0
  76. package/src/components/TabularExplorer/types.ts +86 -0
  77. package/src/composables/useHasTabularData.ts +13 -0
  78. package/src/composables/useMetrics.ts +1 -1
  79. package/src/composables/useResourceCapabilities.ts +1 -1
  80. package/src/composables/useSearchFilter.ts +120 -0
  81. package/src/composables/useStableQueryParams.ts +38 -6
  82. package/src/composables/useTabularProfile.ts +70 -0
  83. package/src/config.ts +20 -3
  84. package/src/functions/activities.ts +3 -3
  85. package/src/functions/api.ts +20 -42
  86. package/src/functions/api.types.ts +1 -0
  87. package/src/functions/charts.ts +79 -0
  88. package/src/functions/datasets.ts +0 -17
  89. package/src/functions/metrics.ts +6 -4
  90. package/src/functions/resources.ts +61 -1
  91. package/src/functions/tabular.ts +171 -0
  92. package/src/functions/tabularApi.ts +96 -11
  93. package/src/main.ts +95 -9
  94. package/src/types/dataservices.ts +2 -0
  95. package/src/types/pages.ts +0 -5
  96. package/src/types/posts.ts +2 -2
  97. package/src/types/reports.ts +5 -1
  98. package/src/types/resources.ts +0 -1
  99. package/src/types/search.ts +63 -1
  100. package/src/types/site.ts +5 -3
  101. package/src/types/ui.ts +2 -0
  102. package/src/types/users.ts +2 -1
  103. package/src/types/visualizations.ts +93 -0
  104. package/assets/swagger-themes/newspaper.css +0 -1670
  105. package/dist/JsonPreview.client-D53pj9Cw.js +0 -72
  106. package/dist/Pmtiles.client-4j3VTYkz.js +0 -25185
  107. package/dist/Swagger.client-DPBmsH9q.js +0 -4
  108. package/dist/XmlPreview.client-XElkoA4F.js +0 -64
  109. package/dist/main-BbT-LUXy.js +0 -105854
  110. package/src/components/ResourceAccordion/Swagger.client.vue +0 -48
  111. package/src/functions/pagination.ts +0 -9
@@ -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 { b as Ke } from "./main-BbT-LUXy.js";
1
+ import { b8 as Ke } from "./main-CQREzlRN.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.0.2-dev.13",
3
+ "version": "1.0.2-dev.131",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -10,29 +10,37 @@
10
10
  "yarn": "use-pnpm-instead"
11
11
  },
12
12
  "main": "./src/main.ts",
13
+ "exports": {
14
+ ".": "./src/main.ts",
15
+ "./chart": "./src/chart.ts",
16
+ "./assets/*": "./assets/*",
17
+ "./dist/*": "./dist/*"
18
+ },
19
+ "sideEffects": false,
13
20
  "files": [
14
21
  "assets",
15
22
  "dist",
16
23
  "src"
17
24
  ],
18
25
  "dependencies": {
19
- "@floating-ui/vue": "^1.1.8",
20
- "@types/leaflet": "^1.9.17",
26
+ "@floating-ui/vue": "^1.1.11",
21
27
  "@headlessui/vue": "^1.7.23",
22
- "@remixicon/vue": "^4.5.0",
28
+ "@remixicon/vue": "^4.9.0",
23
29
  "@types/hast": "^3.0.4",
24
- "@vueuse/core": "^13.1.0",
25
- "@vueuse/router": "^13.1.0",
26
- "chart.js": "^4.4.8",
27
- "dompurify": "^3.2.5",
28
- "geopf-extensions-openlayers": "^1.0.0-beta.5",
30
+ "@types/leaflet": "^1.9.21",
31
+ "@vueuse/core": "^14.3.0",
32
+ "@vueuse/router": "^14.3.0",
33
+ "chart.js": "^4.5.1",
34
+ "dompurify": "^3.4.7",
35
+ "echarts": "^6.1.0",
36
+ "geopf-extensions-openlayers": "1.0.0-beta.11",
29
37
  "leaflet": "^1.9.4",
30
- "maplibre-gl": "^5.6.2",
31
- "ofetch": "^1.4.1",
32
- "ol": "^10.6.1",
38
+ "maplibre-gl": "^5.24.0",
39
+ "ofetch": "^1.5.1",
40
+ "ol": "^10.9.0",
33
41
  "pdfjs-dist": "^4.10.38",
34
- "pmtiles": "^4.3.0",
35
- "popmotion": "^11.0",
42
+ "pmtiles": "^4.4.1",
43
+ "popmotion": "^11.0.5",
36
44
  "rehype-highlight": "^7.0.2",
37
45
  "rehype-raw": "^7.0.0",
38
46
  "rehype-sanitize": "^6.0.0",
@@ -45,38 +53,44 @@
45
53
  "remark-rehype": "^11.1.2",
46
54
  "strip-markdown": "^6.0.0",
47
55
  "stylefire": "^7.0.3",
48
- "swagger-ui-dist": "^5.27.1",
49
56
  "unified": "^11.0.5",
50
- "unist-util-visit": "^5.0.0",
51
- "vue": "^3.5.13",
57
+ "unist-util-visit": "^5.1.0",
52
58
  "vue-content-loader": "^2.0.1",
53
- "vue-router": "^4.5.0",
54
59
  "vue-sonner": "^2.0.9",
55
60
  "vue3-json-viewer": "^2.4.1",
56
61
  "vue3-text-clamp": "^0.1.2",
57
- "vue3-xml-viewer": "^0.0.14"
62
+ "vue3-xml-viewer": "^0.0.14",
63
+ "yaml": "^2.9.0"
58
64
  },
59
65
  "devDependencies": {
60
66
  "@intlify/cli": "^0.13.1",
61
- "@tailwindcss/cli": "^4.0.8",
62
- "@tailwindcss/typography": "^0.5.16",
63
- "@tsconfig/node22": "^22.0.0",
67
+ "@tailwindcss/cli": "^4.3.0",
68
+ "@tailwindcss/typography": "^0.5.19",
69
+ "@tsconfig/node22": "^22.0.5",
64
70
  "@types/geojson": "^7946.0.16",
65
- "@types/node": "^22.13.1",
66
- "@vitejs/plugin-vue": "^6.0",
71
+ "@types/node": "^22.19.19",
72
+ "@vitejs/plugin-vue": "^6.0.7",
67
73
  "@vue/eslint-config-prettier": "^10.2.0",
68
- "@vue/eslint-config-typescript": "^14.3.0",
69
- "@vue/tsconfig": "^0.8.0",
70
- "eslint": "^9.18.0",
71
- "eslint-plugin-vue": "^10.0",
72
- "jiti": "^2.4.2",
73
- "npm-run-all2": "^8.0",
74
- "prettier": "^3.0.0",
75
- "tailwindcss": "^4.0.8",
76
- "typescript": "^5.7.3",
77
- "vite": "^7.0",
78
- "vite-plugin-vue-devtools": "^8.0",
79
- "vue-tsc": "^3.0"
74
+ "@vue/eslint-config-typescript": "^14.7.0",
75
+ "@vue/tsconfig": "^0.8.1",
76
+ "eslint": "^9.39.4",
77
+ "eslint-plugin-vue": "^10.9.1",
78
+ "jiti": "^2.7.0",
79
+ "npm-run-all2": "^8.0.4",
80
+ "openapi-types": "^12.1.3",
81
+ "prettier": "^3.8.3",
82
+ "tailwindcss": "^4.3.0",
83
+ "typescript": "^5.9.3",
84
+ "vite": "^7.3.3",
85
+ "vite-plugin-vue-devtools": "^8.1.2",
86
+ "vue": "^3.5.35",
87
+ "vue-router": "^5.0.7",
88
+ "vue-tsc": "^3.3.2"
89
+ },
90
+ "peerDependencies": {
91
+ "vue": "^3.5.13",
92
+ "vue-router": "^4.5.0 || ^5.0.0",
93
+ "echarts": "^6.0.0"
80
94
  },
81
95
  "scarfSettings": {
82
96
  "enabled": false
package/src/chart.ts ADDED
@@ -0,0 +1,5 @@
1
+ import ChartViewer from './components/Chart/ChartViewer.vue'
2
+ import ChartViewerWrapper from './components/Chart/ChartViewerWrapper.vue'
3
+ import SmallChart from './components/SmallChart.vue'
4
+
5
+ export { ChartViewer, ChartViewerWrapper, SmallChart }
@@ -77,6 +77,9 @@
77
77
  v-bind="{ class: '', activity }"
78
78
  >
79
79
  {{ getActivityTranslation(activity) }}
80
+ <template v-if="'resource_id' in activity.extras">
81
+ {{ activity.extras.resource_id }}
82
+ </template>
80
83
  </slot>
81
84
  </p>
82
85
  <p class="m-0 flex-none text-xs text-gray-medium">
@@ -90,7 +93,6 @@
90
93
  :total-results="activities.total"
91
94
  :page-size="activities.page_size"
92
95
  :page="activities.page"
93
- :link="getLink"
94
96
  @change="(newPage: number) => page = newPage"
95
97
  />
96
98
  </template>
@@ -117,7 +119,6 @@ import { useTranslation } from '../../composables/useTranslation'
117
119
  import { getActivityTranslation } from '../../functions/activities'
118
120
  import { useFetch } from '../../functions/api'
119
121
  import { useFormatDate } from '../../functions/dates'
120
- import { getLink } from '../../functions/pagination'
121
122
  import type { PaginatedArray } from '../../types/api'
122
123
  import type { Activity } from '../../types/activity'
123
124
  import Avatar from '../Avatar.vue'
@@ -0,0 +1,227 @@
1
+ <template>
2
+ <div
3
+ ref="chartContainer"
4
+ class="w-full min-h-96"
5
+ />
6
+ </template>
7
+
8
+ <script setup lang="ts">
9
+ import { format, use, type ComposeOption } from 'echarts/core'
10
+ import { CanvasRenderer } from 'echarts/renderers'
11
+ import { LineChart, BarChart, type BarSeriesOption, type LineSeriesOption } from 'echarts/charts'
12
+ import { TitleComponent, TooltipComponent, LegendComponent, GridComponent, DatasetComponent } from 'echarts/components'
13
+ import { init, type ECharts as EChartsType } from 'echarts'
14
+ import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
15
+ import { summarize } from '../../functions/helpers'
16
+ import type { Chart, XAxis, YAxis, XAxisForm, ChartForApi } from '../../types/visualizations'
17
+ import { useTranslation } from '../../composables/useTranslation'
18
+
19
+ use([CanvasRenderer, LineChart, BarChart, TitleComponent, TooltipComponent, LegendComponent, GridComponent, DatasetComponent])
20
+
21
+ const props = defineProps<{
22
+ chart: Chart | ChartForApi
23
+ series: {
24
+ data: Record<string, Array<Record<string, unknown>>>
25
+ columns: Record<string, Array<{ name: string, type: string }>>
26
+ }
27
+ }>()
28
+
29
+ const { locale } = useTranslation()
30
+ const chartContainer = ref<HTMLElement | null>(null)
31
+ let echartsInstance: EChartsType | null = null
32
+
33
+ function mapXAxisType(xAxis: XAxis | XAxisForm): 'category' | 'value' {
34
+ if (!xAxis) return 'category'
35
+ return xAxis.type === 'continuous' ? 'value' : 'category'
36
+ }
37
+
38
+ function buildYAxisFormatter(yAxis: YAxis): ((value: number) => string) | undefined {
39
+ return (value: number) => {
40
+ const v = summarize(value)
41
+ if (!yAxis.unit) return v
42
+ if (yAxis.unit_position === 'prefix') return `${yAxis.unit} ${v}`
43
+ return `${v} ${yAxis.unit}`
44
+ }
45
+ }
46
+
47
+ const echartsOption = computed(() => {
48
+ const seriesCount = props.chart.series.length
49
+ if (!props.chart.series || seriesCount === 0) return
50
+
51
+ const seriesArray = props.chart.series.map((s) => {
52
+ const xColumn = s.column_x_name_override ?? props.chart.x_axis.column_x
53
+ const yColumn = s.aggregate_y ? `${s.column_y}__${s.aggregate_y}` : s.column_y
54
+ const resourceId = s.resource_id
55
+
56
+ const resourceColumns = props.series.columns[resourceId]
57
+ if (!xColumn || !yColumn || !resourceId || !s.type || !props.series.data[resourceId] || !resourceColumns) {
58
+ return null
59
+ }
60
+
61
+ const sortedData = [...props.series.data[resourceId]]
62
+ const sortBy = props.chart.x_axis.sort_x_by
63
+ const sortDirection = props.chart.x_axis.sort_x_direction ?? 'asc'
64
+
65
+ if (sortBy && sortDirection && props.chart.x_axis.column_x) {
66
+ const sortKey = sortBy === 'axis_x' ? xColumn : yColumn
67
+ sortedData.sort((a, b) => {
68
+ const valA = a[sortKey]
69
+ const valB = b[sortKey]
70
+
71
+ const aNullish = valA === null || valA === undefined
72
+ const bNullish = valB === null || valB === undefined
73
+ if (aNullish && bNullish) return 0
74
+ if (aNullish) return sortDirection === 'asc' ? -1 : 1
75
+ if (bNullish) return sortDirection === 'asc' ? 1 : -1
76
+
77
+ if (valA instanceof Date && valB instanceof Date) {
78
+ const timeA = valA.getTime()
79
+ const timeB = valB.getTime()
80
+ if (timeA < timeB) return sortDirection === 'asc' ? -1 : 1
81
+ if (timeA > timeB) return sortDirection === 'asc' ? 1 : -1
82
+ return 0
83
+ }
84
+
85
+ if (typeof valA === 'boolean' && typeof valB === 'boolean') {
86
+ if (valA === valB) return 0
87
+ // false comes before true in ascending order
88
+ if (valB) return sortDirection === 'asc' ? -1 : 1
89
+ return sortDirection === 'asc' ? 1 : -1
90
+ }
91
+
92
+ const numA = Number(valA)
93
+ const numB = Number(valB)
94
+ const bothNumeric = !isNaN(numA) && !isNaN(numB)
95
+
96
+ if (bothNumeric) {
97
+ if (numA < numB) return sortDirection === 'asc' ? -1 : 1
98
+ if (numA > numB) return sortDirection === 'asc' ? 1 : -1
99
+ return 0
100
+ }
101
+
102
+ const strA = String(valA)
103
+ const strB = String(valB)
104
+ return strA.localeCompare(strB, locale, {
105
+ sensitivity: 'base',
106
+ numeric: true,
107
+ }) * (sortDirection === 'asc' ? 1 : -1)
108
+ })
109
+ }
110
+
111
+ return {
112
+ series: {
113
+ type: s.type === 'histogram' ? 'bar' : 'line',
114
+ dimensions: s.aggregate_y ? [xColumn, yColumn] : resourceColumns.map(c => c.name),
115
+ name: yColumn,
116
+ encode: {
117
+ x: xColumn,
118
+ y: yColumn,
119
+ },
120
+ } as LineSeriesOption | BarSeriesOption,
121
+ data: {
122
+ source: sortedData,
123
+ dimensions: s.aggregate_y ? [xColumn, yColumn] : resourceColumns.map(c => c.name),
124
+ },
125
+ }
126
+ })
127
+
128
+ const seriesData = {
129
+ series: [] as Array<LineSeriesOption | BarSeriesOption>,
130
+ data: [] as Array<Record<string, unknown>>,
131
+ }
132
+
133
+ for (const curr of seriesArray) {
134
+ if (!curr) continue
135
+ seriesData.series.push(curr.series)
136
+ seriesData.data.push(curr.data)
137
+ }
138
+
139
+ return {
140
+ dataset: [...seriesData.data],
141
+ textStyle: {
142
+ fontFamily: 'Marianne, arial, sans-serif',
143
+ },
144
+ color: '#000091',
145
+ tooltip: {
146
+ trigger: 'axis' as const,
147
+ formatter: (params: Array<{ value: Record<string, unknown>, axisValueLabel: string, seriesName: string }>) => {
148
+ let tooltip = ''
149
+ const formatter = new Intl.NumberFormat('fr-FR')
150
+ for (const param of params) {
151
+ const seriesName = param.seriesName
152
+ tooltip += `${format.encodeHTML(param.axisValueLabel)}: <strong>${formatter.format(Number(param.value[seriesName]))}</strong><br>`
153
+ }
154
+ return tooltip
155
+ },
156
+ },
157
+ legend: {
158
+ show: false,
159
+ bottom: 0,
160
+ },
161
+ grid: {
162
+ top: 60,
163
+ bottom: 40,
164
+ left: 20,
165
+ right: 20,
166
+ containLabel: true,
167
+ },
168
+ xAxis: {
169
+ type: mapXAxisType(props.chart.x_axis),
170
+ name: (props.chart.x_axis as XAxis).column_x,
171
+ },
172
+ yAxis: {
173
+ type: 'value' as const,
174
+ name: props.chart.y_axis.label ?? undefined,
175
+ min: props.chart.y_axis.min ?? undefined,
176
+ max: props.chart.y_axis.max ?? undefined,
177
+ axisLabel: {
178
+ formatter: buildYAxisFormatter(props.chart.y_axis),
179
+ },
180
+ },
181
+ series: seriesData.series,
182
+ } satisfies ComposeOption<
183
+ | BarSeriesOption
184
+ | LineSeriesOption
185
+ >
186
+ })
187
+
188
+ onMounted(() => {
189
+ if (chartContainer.value) {
190
+ echartsInstance = init(chartContainer.value)
191
+ updateChart()
192
+ }
193
+ })
194
+
195
+ onUnmounted(() => {
196
+ if (echartsInstance) {
197
+ echartsInstance.dispose()
198
+ echartsInstance = null
199
+ }
200
+ })
201
+
202
+ watch(() => props.chart, updateChart, { deep: true })
203
+
204
+ watch(() => props.series, updateChart, { deep: true })
205
+
206
+ function updateChart() {
207
+ if (!echartsInstance) return
208
+ const option = echartsOption.value
209
+ if (option) {
210
+ echartsInstance.setOption(option, { notMerge: true })
211
+ }
212
+ }
213
+
214
+ const handleResize = () => {
215
+ if (echartsInstance) {
216
+ echartsInstance.resize()
217
+ }
218
+ }
219
+
220
+ onMounted(() => {
221
+ window.addEventListener('resize', handleResize)
222
+ })
223
+
224
+ onUnmounted(() => {
225
+ window.removeEventListener('resize', handleResize)
226
+ })
227
+ </script>
@@ -0,0 +1,174 @@
1
+ <template>
2
+ <LoadingBlock
3
+ :status="status"
4
+ :data="series"
5
+ >
6
+ <template #default="{ data }">
7
+ <ChartViewer
8
+ :chart="chart"
9
+ :series="data"
10
+ />
11
+ </template>
12
+ <template #error>
13
+ <div class="text-center py-8 text-gray-500">
14
+ {{ t('Une erreur est survenue lors du chargement des données du graphique.') }}
15
+ </div>
16
+ </template>
17
+ </LoadingBlock>
18
+ </template>
19
+
20
+ <script setup lang="ts">
21
+ import { computed, reactive, ref, watch } from 'vue'
22
+ import ChartViewer from './ChartViewer.vue'
23
+ import LoadingBlock from '../../components/LoadingBlock.vue'
24
+ import { useComponentsConfig } from '../../config'
25
+ import { fetchTabularData, useGetProfile } from '../../functions/tabularApi'
26
+ import type { Chart, ChartForApi, ColumnsDefinition } from '../../types/visualizations'
27
+ import { useTranslation } from '../../composables/useTranslation'
28
+ import { watchDebounced } from '@vueuse/shared'
29
+ import { buildColumnsFromProfile } from '../../functions/charts'
30
+
31
+ const props = defineProps<{
32
+ chart: Chart | ChartForApi
33
+ }>()
34
+
35
+ const { t } = useTranslation()
36
+ const config = useComponentsConfig()
37
+ const getProfile = useGetProfile()
38
+
39
+ const status = ref<'idle' | 'pending' | 'success' | 'error'>('idle')
40
+ const error = ref<Error | null>(null)
41
+
42
+ const pendingOperations = ref(0)
43
+
44
+ const series = reactive<{
45
+ data: Record<string, Array<Record<string, unknown>>>
46
+ columns: ColumnsDefinition
47
+ }>({
48
+ data: {},
49
+ columns: {},
50
+ })
51
+
52
+ const resourceIds = computed(() => {
53
+ return props.chart.series
54
+ .filter(s => s.resource_id)
55
+ .map(s => s.resource_id)
56
+ })
57
+
58
+ async function fetchSeriesProfile() {
59
+ pendingOperations.value++
60
+ status.value = 'pending'
61
+ error.value = null
62
+
63
+ try {
64
+ if (props.chart.series.length === 0) {
65
+ status.value = 'success'
66
+ series.data = {}
67
+ series.columns = {}
68
+ return
69
+ }
70
+
71
+ const fetchPromises = props.chart.series
72
+ .filter(serie => serie.resource_id)
73
+ .map(async (serie) => {
74
+ return {
75
+ id: serie.resource_id,
76
+ profile: await getProfile(serie.resource_id),
77
+ }
78
+ })
79
+
80
+ const results = (await Promise.allSettled(fetchPromises))
81
+ .filter(r => r.status === 'fulfilled')
82
+ .map(r => r.value)
83
+ series.columns = Object.fromEntries(results.map(result => [
84
+ result.id,
85
+ buildColumnsFromProfile(result.profile),
86
+ ]))
87
+ }
88
+ catch (err) {
89
+ error.value = err instanceof Error ? err : new Error('Failed to fetch series profile')
90
+ status.value = 'error'
91
+ console.error(err)
92
+ series.columns = {}
93
+ series.data = {}
94
+ }
95
+ finally {
96
+ pendingOperations.value--
97
+ }
98
+ }
99
+
100
+ async function fetchSeriesData() {
101
+ pendingOperations.value++
102
+ status.value = 'pending'
103
+ error.value = null
104
+
105
+ try {
106
+ if (props.chart.series.length === 0 || !props.chart.x_axis.column_x) {
107
+ status.value = 'success'
108
+ series.data = {}
109
+ return
110
+ }
111
+
112
+ const fetchPromises = props.chart.series
113
+ .filter((serie) => {
114
+ const xColumn = serie.column_x_name_override ?? props.chart.x_axis.column_x
115
+ return xColumn && serie.resource_id && serie.column_y
116
+ })
117
+ .map(async (serie) => {
118
+ const xColumn = serie.column_x_name_override ?? props.chart.x_axis.column_x
119
+ return {
120
+ id: serie.resource_id,
121
+ data: await fetchTabularData(config, {
122
+ columns: serie.aggregate_y ? undefined : [xColumn, serie.column_y],
123
+ resourceId: serie.resource_id,
124
+ page: 1,
125
+ pageSize: 100,
126
+ groupBy: xColumn,
127
+ aggregation: serie.column_y && serie.aggregate_y
128
+ ? {
129
+ column: serie.column_y,
130
+ type: serie.aggregate_y,
131
+ }
132
+ : undefined,
133
+ filters: serie.filters ?? undefined,
134
+ }),
135
+ }
136
+ })
137
+
138
+ const results = (await Promise.allSettled(fetchPromises))
139
+ .filter(r => r.status === 'fulfilled')
140
+ .map(r => r.value)
141
+ series.data = Object.fromEntries(results.map(result => [
142
+ result.id,
143
+ result.data.data,
144
+ ]))
145
+ }
146
+ catch (err) {
147
+ error.value = err instanceof Error ? err : new Error('Failed to fetch series data')
148
+ status.value = 'error'
149
+ series.data = {}
150
+ }
151
+ finally {
152
+ pendingOperations.value--
153
+ }
154
+ }
155
+
156
+ watch(resourceIds, async () => {
157
+ await fetchSeriesProfile()
158
+ }, { immediate: true })
159
+
160
+ watchDebounced([
161
+ () => props.chart.series,
162
+ () => props.chart.x_axis.column_x,
163
+ ], async () => {
164
+ await fetchSeriesData()
165
+ }, { debounce: config.searchDebounce ?? 300, immediate: true, deep: true })
166
+
167
+ watch(pendingOperations, (count) => {
168
+ if (count === 0) {
169
+ if (error.value === null && status.value === 'pending') {
170
+ status.value = 'success'
171
+ }
172
+ }
173
+ })
174
+ </script>
@@ -53,6 +53,7 @@
53
53
  <ObjectCardHeader
54
54
  :icon="isTabularApi ? RiSparklingLine : RiTerminalLine"
55
55
  :url="dataserviceUrl || dataservice.self_web_url"
56
+ :title-tag="titleTag"
56
57
  >
57
58
  {{ dataservice.title }}
58
59
  </ObjectCardHeader>
@@ -115,6 +116,7 @@ import { useComponentsConfig } from '../config'
115
116
  import { useFormatDate } from '../functions/dates'
116
117
  import { summarize } from '../functions/helpers'
117
118
  import type { Dataservice } from '../types/dataservices'
119
+ import type { TitleTag } from '../types/ui'
118
120
  import { useTranslation } from '../composables/useTranslation'
119
121
  import OrganizationLogo from './OrganizationLogo.vue'
120
122
  import Avatar from './Avatar.vue'
@@ -130,6 +132,7 @@ type Props = {
130
132
  dataserviceUrl?: RouteLocationRaw
131
133
  organizationUrl?: RouteLocationRaw
132
134
  showDescription?: boolean
135
+ titleTag?: TitleTag
133
136
  }
134
137
 
135
138
  const props = withDefaults(defineProps<Props>(), {