@datagouv/components-next 0.1.4 → 0.1.5

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.
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as C, defineAsyncComponent as S, ref as u, computed as w, onMounted as N, createElementBlock as f, openBlock as n, createBlock as d, createCommentVNode as T, createVNode as i, unref as t, toDisplayString as c, withCtx as h, createElementVNode as m } from "vue";
2
- import { d as P, u as E, a as v, F as g } from "./main-CarU0Io9.js";
2
+ import { d as P, u as E, a as v, F as g } from "./main-B4RtnYXi.js";
3
3
  const q = { class: "fr-text--xs" }, B = { key: 0 }, O = {
4
4
  key: 1,
5
5
  class: "text-gray-medium"
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, useTemplateRef, ref as ref$2, onMounted, createBlock, createElementBlock, openBlock, withCtx, createVNode, createElementVNode, unref, toDisplayString } from "vue";
2
- import { c as commonjsGlobal, g as getDefaultExportFromCjs$1, u as useTranslation, a as _sfc_main$1, F as Fe } from "./main-CarU0Io9.js";
2
+ import { c as commonjsGlobal, g as getDefaultExportFromCjs$1, u as useTranslation, a as _sfc_main$1, F as Fe } from "./main-B4RtnYXi.js";
3
3
  const ObjectEventType = {
4
4
  /**
5
5
  * Triggered when a property is changed.
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as B, defineAsyncComponent as q, ref as a, computed as w, onMounted as L, createElementBlock as p, openBlock as s, createBlock as f, createCommentVNode as O, createVNode as u, unref as t, toDisplayString as c, withCtx as d, createElementVNode as g } from "vue";
2
- import { d as S, u as $, a as h, F as m } from "./main-CarU0Io9.js";
2
+ import { d as S, u as $, a as h, F as m } from "./main-B4RtnYXi.js";
3
3
  const N = { class: "text-xs" }, V = { key: 0 }, A = {
4
4
  key: 1,
5
5
  class: "text-gray-medium"
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as ig, ref as rg, computed as Ol, useTemplateRef as ng, onMounted as ag, createElementBlock as Th, openBlock as nu, createBlock as sg, withCtx as wd, createVNode as Td, createElementVNode as ha, unref as La, toDisplayString as jl, createCommentVNode as og, createTextVNode as lg } from "vue";
2
- import { g as cg, u as ug, b as hg, d as pg, e as dg, f as fg, a as mg, F as gg, h as _g, i as yg, K as xg, t as vg } from "./main-CarU0Io9.js";
2
+ import { g as cg, u as ug, b as hg, d as pg, e as dg, f as fg, a as mg, F as gg, h as _g, i as yg, K as xg, t as vg } from "./main-B4RtnYXi.js";
3
3
  var tn = Uint8Array, So = Uint16Array, bg = Int32Array, Dd = new tn([
4
4
  0,
5
5
  0,
@@ -0,0 +1,4 @@
1
+ import { _ as f } from "./main-B4RtnYXi.js";
2
+ export {
3
+ f as default
4
+ };
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as b, defineAsyncComponent as L, ref as u, computed as w, onMounted as T, createElementBlock as f, openBlock as r, createBlock as m, createCommentVNode as P, createVNode as i, unref as t, toDisplayString as c, withCtx as h, createElementVNode as d } from "vue";
2
- import { d as E, u as M, a as v, F as g } from "./main-CarU0Io9.js";
2
+ import { d as E, u as M, a as v, F as g } from "./main-B4RtnYXi.js";
3
3
  const q = { class: "fr-text--xs" }, B = { key: 0 }, S = {
4
4
  key: 1,
5
5
  class: "text-gray-medium"
@@ -10,7 +10,7 @@ const q = { class: "fr-text--xs" }, B = { key: 0 }, S = {
10
10
  },
11
11
  setup(k) {
12
12
  const z = L(
13
- () => import("./vue3-xml-viewer.common-Cqxs_s2H.js").then((e) => e.v).then((e) => e.default || e.XmlViewer)
13
+ () => import("./vue3-xml-viewer.common-CaMSbbOr.js").then((e) => e.v).then((e) => e.default || e.XmlViewer)
14
14
  ), s = k, x = E(), { t: l } = M(), a = u(null), p = u(!1), n = u(null), y = u(!1), _ = w(() => {
15
15
  if (s.resource.filesize)
16
16
  return s.resource.filesize;
@@ -1,4 +1,4 @@
1
- import { am as e, k as t, l as i, m as n, n as o, o as r, p as l, i as c, ak as T, an as g, C as u, aa as d, a9 as C, D as O, q as m, r as R, s as p, v as I, w as E, x as y, y as A, z as D, A as S, ao as L, B as v, E as P, aD as h, ap as N, G as b, H as f, I as z, J as B, al as _, L as w, M as G, N as H, aB as M, O as U, R as k, P as x, Q as F, S as Q, a as V, T as W, _ as Y, U as j, V as q, W as J, X, Y as K, $ as Z, Z as $, a0 as aa, aq as sa, a1 as ea, j as ta, aE as ia, a4 as na, af as oa, au as ra, aJ as la, ah as ca, a8 as Ta, ab as ga, ay as ua, ax as da, av as Ca, at as Oa, f as ma, e as Ra, ad as pa, az as Ia, aC as Ea, aA as ya, ae as Aa, aH as Da, aG as Sa, as as La, ac as va, aw as Pa, ar as ha, a6 as Na, a5 as ba, ai as fa, ag as za, a7 as Ba, t as _a, aj as wa, a2 as Ga, d as Ha, aF as Ma, b as Ua, aI as ka, aK as xa, aL as Fa, aM as Qa, a3 as Va, u as Wa } from "./main-CarU0Io9.js";
1
+ import { am as e, k as t, l as i, m as n, n as o, o as r, p as l, i as c, ak as T, an as g, C as u, aa as d, a9 as C, D as O, q as m, r as R, s as p, v as I, w as E, x as y, y as A, z as D, A as S, ao as L, B as v, E as P, aD as h, ap as N, G as b, H as f, I as z, J as B, al as _, L as w, M as G, N as H, aB as M, O as U, R as k, P as x, Q as F, S as Q, a as V, T as W, _ as Y, U as j, V as q, W as J, X, Y as K, $ as Z, Z as $, a0 as aa, aq as sa, a1 as ea, j as ta, aE as ia, a4 as na, af as oa, au as ra, aJ as la, ah as ca, a8 as Ta, ab as ga, ay as ua, ax as da, av as Ca, at as Oa, f as ma, e as Ra, ad as pa, az as Ia, aC as Ea, aA as ya, ae as Aa, aH as Da, aG as Sa, as as La, ac as va, aw as Pa, ar as ha, a6 as Na, a5 as ba, ai as fa, ag as za, a7 as Ba, t as _a, aj as wa, a2 as Ga, d as Ha, aF as Ma, b as Ua, aI as ka, aK as xa, aL as Fa, aM as Qa, a3 as Va, u as Wa } from "./main-B4RtnYXi.js";
2
2
  export {
3
3
  e as ASSOCIATION,
4
4
  t as ActivityList,
@@ -706,11 +706,14 @@ async function yu(e, r) {
706
706
  try {
707
707
  p.value = await oh(h, {
708
708
  baseURL: i.apiBase,
709
- onRequest({ options: m }) {
710
- m.headers.set("Content-Type", "application/json"), m.headers.set("Accept", "application/json"), m.credentials = "include", i.devApiKey && m.headers.set("X-API-KEY", i.devApiKey), l && (m.params || (m.params = {}), m.params.lang = l);
711
- },
712
- async onResponseError() {
709
+ onRequest(m) {
710
+ i.onRequest && (Array.isArray(i.onRequest) ? i.onRequest.forEach((y) => y(m)) : i.onRequest(m));
711
+ const { options: v } = m;
712
+ v.headers.set("Content-Type", "application/json"), v.headers.set("Accept", "application/json"), v.credentials = "include", i.devApiKey && v.headers.set("X-API-KEY", i.devApiKey), l && (v.params || (v.params = {}), v.params.lang = l);
713
713
  },
714
+ onRequestError: i.onRequestError,
715
+ onResponse: i.onResponse,
716
+ onResponseError: i.onResponseError,
714
717
  ...f
715
718
  }), c.value = "success";
716
719
  } catch (m) {
@@ -49133,7 +49136,7 @@ const Exe = ["y"], Nxe = ["y"], zxe = ["y"], Zxe = ["y"], Axe = ["y"], Rxe = ["y
49133
49136
  canEdit: { type: Boolean, default: !1 }
49134
49137
  },
49135
49138
  setup(e) {
49136
- const r = ["parquet", "pmtiles", "geojson"], i = e, l = t0(), p = j7(() => import("./Swagger.client-BuBFNfiL.js")), C = j7(() => import("./MapContainer.client-D4dQoauJ.js")), c = j7(() => import("./Pmtiles.client-Cx6JUqT9.js")), d = j7(() => import("./JsonPreview.client-D6ptqXOA.js")), o = j7(() => import("./PdfPreview.client-DTUPMgrP.js")), h = j7(() => import("./XmlPreview.client-DDSXyn0x.js")), { t: f } = mn(), { formatRelativeIfRecentDate: m } = ol(), v = tt(() => {
49139
+ const r = ["parquet", "pmtiles", "geojson"], i = e, l = t0(), p = j7(() => import("./Swagger.client-CvnsGulf.js")), C = j7(() => import("./MapContainer.client-DDuBnXd4.js")), c = j7(() => import("./Pmtiles.client-DC_vN9Xz.js")), d = j7(() => import("./JsonPreview.client-C9-SHa9z.js")), o = j7(() => import("./PdfPreview.client-uj2vRkxw.js")), h = j7(() => import("./XmlPreview.client-CvWagOUP.js")), { t: f } = mn(), { formatRelativeIfRecentDate: m } = ol(), v = tt(() => {
49137
49140
  const qe = i.resource.format?.toLowerCase();
49138
49141
  return qe === "json" || qe === "pdf" || qe === "xml";
49139
49142
  }), y = tt(() => l.tabularApiUrl && i.resource.extras["analysis:parsing:parsing_table"] && !i.resource.extras["analysis:parsing:error"] && (l.tabularAllowRemote || i.resource.filetype === "file")), L = tt(() => i.resource.extras["analysis:parsing:pmtiles_url"]), H = tt(() => lI(i.resource.format) ? i.resource.format : f("Fichier")), N = tt(() => Zve(i.resource)), z = tt(() => N.value === "wms"), A = tt(() => {
@@ -1,4 +1,4 @@
1
- import { g as Ke } from "./main-CarU0Io9.js";
1
+ import { g as Ke } from "./main-B4RtnYXi.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": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./src/main.ts",
package/src/config.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { inject, type Component, type InjectionKey } from 'vue'
2
2
  import type { UseFetchFunction } from './functions/api.types'
3
+ import type { FetchOptions } from 'ofetch'
3
4
 
4
5
  export type PluginConfig = {
5
6
  name: string // Name of the application (ex: data.gouv.fr)
@@ -18,6 +19,10 @@ export type PluginConfig = {
18
19
  tabularAllowRemote?: boolean
19
20
  tabularApiDataserviceId?: string
20
21
  customUseFetch?: UseFetchFunction | null
22
+ onRequest?: FetchOptions['onRequest']
23
+ onRequestError?: FetchOptions['onRequestError']
24
+ onResponse?: FetchOptions['onResponse']
25
+ onResponseError?: FetchOptions['onResponseError']
21
26
  textClamp?: string | Component | null
22
27
  appLink?: Component | null
23
28
  clientOnly?: Component | null
@@ -26,9 +26,18 @@ export async function useFetch<DataT, ErrorT = never>(
26
26
  const fetchOptions = reactive(options ?? {})
27
27
  status.value = 'pending'
28
28
  try {
29
- data.value = await ofetch(urlValue, {
29
+ data.value = await ofetch<DataT | null>(urlValue, {
30
30
  baseURL: config.apiBase,
31
- onRequest({ options }) {
31
+ onRequest(param) {
32
+ if (config.onRequest) {
33
+ if (Array.isArray(config.onRequest)) {
34
+ config.onRequest.forEach(r => r(param))
35
+ }
36
+ else {
37
+ config.onRequest(param)
38
+ }
39
+ }
40
+ const { options } = param
32
41
  options.headers.set('Content-Type', 'application/json')
33
42
  options.headers.set('Accept', 'application/json')
34
43
  options.credentials = 'include'
@@ -43,30 +52,9 @@ export async function useFetch<DataT, ErrorT = never>(
43
52
  options.params['lang'] = locale
44
53
  }
45
54
  },
46
- async onResponseError() {
47
- // TODO redirect to login outside Nuxt?
48
- // if (response.status === 401) {
49
- // await nuxtApp.runWithContext(() => navigateTo(localePath('/login')))
50
- // }
51
-
52
- // let message
53
- // try {
54
- // if ('error' in response._data) {
55
- // message = response._data.error
56
- // }
57
- // else if ('message' in response._data) {
58
- // message = response._data.message
59
- // }
60
- // }
61
- // catch (e) {
62
- // console.error(e)
63
- // // eslint-disable-next-line @typescript-eslint/no-unused-vars
64
- // message = t(`L'API a retourné une erreur inattendue`)
65
- // }
66
-
67
- // TODO Toast outside Nuxt
68
- // toast.error(message)
69
- },
55
+ onRequestError: config.onRequestError,
56
+ onResponse: config.onResponse,
57
+ onResponseError: config.onResponseError,
70
58
  ...fetchOptions,
71
59
  })
72
60
  status.value = 'success'
@@ -1,4 +0,0 @@
1
- import { _ as f } from "./main-CarU0Io9.js";
2
- export {
3
- f as default
4
- };