@choosemycompany/lib 0.4.0 → 0.5.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/dist/index.js +8 -8
- package/dist/store/useStore.d.ts +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { mande as D } from "mande";
|
|
2
2
|
import { useRuntimeConfig as L, showError as K, useState as H } from "nuxt/app";
|
|
3
3
|
import { ref as v, onMounted as z, onBeforeUnmount as F, computed as N, onUnmounted as O } from "vue";
|
|
4
|
-
import { useI18n as
|
|
4
|
+
import { useI18n as k } from "vue-i18n";
|
|
5
5
|
import { createError as q } from "h3";
|
|
6
|
-
let
|
|
6
|
+
let w;
|
|
7
7
|
function Z() {
|
|
8
|
-
return
|
|
8
|
+
return w || (w = L().public.cmcApiUrl, w);
|
|
9
9
|
}
|
|
10
10
|
function aa() {
|
|
11
11
|
const a = Z(), i = D(a, {
|
|
@@ -140,7 +140,7 @@ function ea(a) {
|
|
|
140
140
|
function I() {
|
|
141
141
|
i.value = {}, t.value = {}, n.value = {}, e.value = {};
|
|
142
142
|
}
|
|
143
|
-
return { items: i, views: t, errors: n, isPending: l, list: m, reset: I, retrieve: f, getView: p,
|
|
143
|
+
return { items: i, views: t, errors: n, isPending: l, list: m, reset: I, retrieve: f, getView: p, withPending: c, create: h, update: g, remove: C, clearErrors: M };
|
|
144
144
|
}
|
|
145
145
|
function na(a, i) {
|
|
146
146
|
const t = (n) => {
|
|
@@ -154,7 +154,7 @@ function na(a, i) {
|
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
function ia() {
|
|
157
|
-
const { locale: a } =
|
|
157
|
+
const { locale: a } = k();
|
|
158
158
|
function i(t, n = null) {
|
|
159
159
|
const e = x[t.trim().toUpperCase()];
|
|
160
160
|
if (!e)
|
|
@@ -329,7 +329,7 @@ function ra() {
|
|
|
329
329
|
}
|
|
330
330
|
const U = "https://5509641.hs-sites-eu1.com";
|
|
331
331
|
function oa() {
|
|
332
|
-
const { locale: a } =
|
|
332
|
+
const { locale: a } = k();
|
|
333
333
|
return { contactUrl: N(() => a.value === "fr" ? `${U}/contact` : `${U}/${a.value}/contact`) };
|
|
334
334
|
}
|
|
335
335
|
function sa() {
|
|
@@ -401,7 +401,7 @@ function da() {
|
|
|
401
401
|
return { getRegionFromLocale: a };
|
|
402
402
|
}
|
|
403
403
|
function ua() {
|
|
404
|
-
const { t: a } =
|
|
404
|
+
const { t: a } = k();
|
|
405
405
|
function i(t, n) {
|
|
406
406
|
const e = a(t), s = [], c = n.map((g) => g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), f = new RegExp(`\\[(${c})\\]([\\s\\S]*?)\\[\\/\\1\\]`, "g"), p = n.reduce((g, C) => (g[C] = !1, g), {});
|
|
407
407
|
let m = 0, h = f.exec(e);
|
|
@@ -430,7 +430,7 @@ function la(a, i, t = 768) {
|
|
|
430
430
|
return { size: e, windowWidth: n };
|
|
431
431
|
}
|
|
432
432
|
function ca() {
|
|
433
|
-
const { locale: a } =
|
|
433
|
+
const { locale: a } = k();
|
|
434
434
|
function i(t, n = "fr") {
|
|
435
435
|
if (!t) return "";
|
|
436
436
|
const e = a.value;
|
package/dist/store/useStore.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export type Store<Id extends IdKey, Item, Params extends ViewKeyParams, CreatePa
|
|
|
43
43
|
items: Ref<StoreItems<Id, Item>>;
|
|
44
44
|
/** Cached pages, keyed by `getViewKey(params)`. Each stores `itemIds[]` + pagination meta. */
|
|
45
45
|
views: Ref<StoreViews<Id>>;
|
|
46
|
-
/** Latest error per key (id for retrieve, view key for list, arbitrary for `
|
|
46
|
+
/** Latest error per key (id for retrieve, view key for list, arbitrary for `withPending`). */
|
|
47
47
|
errors: Ref<StoreErrors>;
|
|
48
48
|
/** Returns `true` if there is an in-flight promise registered under `key`. */
|
|
49
49
|
isPending: (key: ViewKey | Id) => boolean;
|
|
@@ -54,12 +54,12 @@ export type Store<Id extends IdKey, Item, Params extends ViewKeyParams, CreatePa
|
|
|
54
54
|
/** Synchronous lookup: rebuilds a `View<Item>` from the cache without fetching. */
|
|
55
55
|
getView: (params: Params) => View<Item> | undefined;
|
|
56
56
|
/** Wraps an arbitrary promise in the store's pending + error lifecycle under `key`. */
|
|
57
|
-
|
|
57
|
+
withPending: <T>(key: ViewKey | Id, promise: Promise<T>) => Promise<T>;
|
|
58
58
|
/** Calls `createMutation`, inserts the item into `items`, and invalidates all views. */
|
|
59
59
|
create: (payload: CreatePayload) => Promise<Item>;
|
|
60
|
-
/** Calls `updateMutation` (
|
|
60
|
+
/** Calls `updateMutation` (wrapped in `withPending(id)`), replaces `items[id]`. */
|
|
61
61
|
update: (id: Id, patch: UpdatePatch) => Promise<Item>;
|
|
62
|
-
/** Calls `removeMutation` (
|
|
62
|
+
/** Calls `removeMutation` (wrapped in `withPending(id)`), deletes `items[id]`, removes id from every view. */
|
|
63
63
|
remove: (id: Id) => Promise<void>;
|
|
64
64
|
/** Clears every entry from `errors`. */
|
|
65
65
|
clearErrors: () => void;
|
package/package.json
CHANGED