@data-fair/lib-vue 1.15.6 → 1.16.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.
package/fetch.d.ts CHANGED
@@ -5,7 +5,8 @@ type UseFetchOptions = {
5
5
  watch?: Boolean;
6
6
  notifError?: Boolean;
7
7
  };
8
- export declare function useFetch<T>(url: string | Ref<string> | (() => string), options?: UseFetchOptions): {
8
+ type OptionalUrl = string | null | undefined;
9
+ export declare function useFetch<T>(url: OptionalUrl | Ref<OptionalUrl> | (() => OptionalUrl), options?: UseFetchOptions): {
9
10
  data: Ref<T | null>;
10
11
  loading: Ref<boolean>;
11
12
  initialized: Ref<boolean>;
package/fetch.js CHANGED
@@ -7,6 +7,7 @@ export function useFetch (url, options = {}) {
7
7
  if (typeof url === 'function') { url = computed(url) }
8
8
  const fullUrl = computed(() => {
9
9
  let fullUrl = isRef(url) ? url.value : url
10
+ if (!fullUrl) { return null }
10
11
  const query = isRef(options.query) ? options.query.value : options.query
11
12
  if (query) { fullUrl = withQuery(fullUrl, query) }
12
13
  return fullUrl
@@ -17,6 +18,7 @@ export function useFetch (url, options = {}) {
17
18
  const error = shallowRef(null)
18
19
  let abortController
19
20
  const refresh = async () => {
21
+ if (!fullUrl.value) { return null }
20
22
  initialized.value = true
21
23
  error.value = null
22
24
  if (abortController) { abortController.abort() }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-fair/lib-vue",
3
- "version": "1.15.6",
3
+ "version": "1.16.0",
4
4
  "description": "Composables and other utilities for Vue applications in the data-fair stack.",
5
5
  "main": "index.js",
6
6
  "files": [
package/ui-notif.d.ts CHANGED
@@ -22,25 +22,7 @@ export declare function getErrorCode(error: any): number;
22
22
  export declare function getErrorMsg(error: any): string;
23
23
  export declare function getFullNotif(notif: PartialUiNotif, defaultType?: UiNotifBase['type']): UiNotif;
24
24
  export declare const getUiNotif: () => {
25
- notification: Readonly<import("vue").Ref<{
26
- readonly type?: ("default" | "info" | "success" | "warning") | undefined;
27
- readonly msg: string;
28
- } | {
29
- readonly type: "error";
30
- readonly msg: string;
31
- readonly error?: any;
32
- readonly errorMsg: string;
33
- readonly clientError?: boolean | undefined;
34
- } | null, {
35
- readonly type?: ("default" | "info" | "success" | "warning") | undefined;
36
- readonly msg: string;
37
- } | {
38
- readonly type: "error";
39
- readonly msg: string;
40
- readonly error?: any;
41
- readonly errorMsg: string;
42
- readonly clientError?: boolean | undefined;
43
- } | null>>;
25
+ notification: import("vue").ShallowRef<UiNotif | null, UiNotif | null>;
44
26
  sendUiNotif: (partialNotif: PartialUiNotif) => void;
45
27
  };
46
28
  export declare const uiNotifKey: unique symbol;
package/ui-notif.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // simple composable to display store a UI notification
2
2
  // this will be transmitted to frame parent if available (compatible with v-iframe uiNotification message type)
3
3
  // or can be displayed locally by @data-fair/lib-vuetify/ui-notif.vue
4
- import { shallowRef, readonly, inject } from 'vue'
4
+ import { shallowRef, inject } from 'vue'
5
5
  import inIframe from '@data-fair/lib-utils/in-iframe.js'
6
6
  export function getErrorCode (error) {
7
7
  if (typeof error === 'string') { return 500 }
@@ -47,7 +47,7 @@ export const getUiNotif = () => {
47
47
  console.log('iframe notification', notif)
48
48
  }
49
49
  }
50
- return { notification: readonly(notification), sendUiNotif }
50
+ return { notification, sendUiNotif }
51
51
  }
52
52
  // uses pattern for SSR friendly plugin/composable, cf https://antfu.me/posts/composable-vue-vueday-2021#shared-state-ssr-friendly
53
53
  export const uiNotifKey = Symbol('uiNotif')