@choosemycompany/lib 0.3.1 → 0.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.
|
@@ -28,5 +28,5 @@ type Translation = Record<string, string>;
|
|
|
28
28
|
* @returns A reactive `translate` function — using it inside a `computed`
|
|
29
29
|
* re-runs when the locale changes.
|
|
30
30
|
*/
|
|
31
|
-
export declare function useTranslate(): (translations: Translation, fallback?: Language) => string;
|
|
31
|
+
export declare function useTranslate(): (translations: Translation | null, fallback?: Language) => string;
|
|
32
32
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* - **HTTP** — {@link useHttp}: thin `mande` wrapper bound to the CMC API base URL.
|
|
9
9
|
* - **Store** — {@link useStore}, {@link getViewKey}: typed cache for `retrieve` /
|
|
10
10
|
* `list` workflows with single-flight, per-key errors, and CRUD mutations.
|
|
11
|
-
* - **i18n** — locale-aware translators for plain strings, country names,
|
|
12
|
-
*
|
|
11
|
+
* - **i18n** — locale-aware translators for plain strings, country names,
|
|
12
|
+
* region resolution, and rich tagged messages.
|
|
13
13
|
* - **UI** — small DOM / window-aware helpers: outside-click detection, responsive
|
|
14
14
|
* sizing, image-cache watcher.
|
|
15
15
|
* - **Errors** — {@link showAndThrowError}: Nuxt error trigger shorthand.
|
|
@@ -27,7 +27,6 @@ export { useHubspotContactUrl } from './analytics/useHubspotContactUrl';
|
|
|
27
27
|
export { useImageCacheWatcherCallback } from './ui/useImageCacheWatcherCallback';
|
|
28
28
|
export { useLocaleHelpers } from './i18n/useLocaleHelpers';
|
|
29
29
|
export { useParseTranslation } from './i18n/useParseTranslation';
|
|
30
|
-
export { usePrimaryTypeTranslation } from './i18n/usePrimaryTypeTranslation';
|
|
31
30
|
export { useResponsiveSize } from './ui/useResponsiveSize';
|
|
32
31
|
export { useTranslate } from './i18n/useTranslate';
|
|
33
32
|
export type { StoreOptions, RetrieveOptions, ListOptions, ViewKeyParams, View, ViewOptions, } from './store/types';
|
package/dist/index.js
CHANGED
|
@@ -1,151 +1,151 @@
|
|
|
1
1
|
import { mande as D } from "mande";
|
|
2
|
-
import { useRuntimeConfig as
|
|
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 w } from "vue-i18n";
|
|
5
5
|
import { createError as q } from "h3";
|
|
6
|
-
let
|
|
6
|
+
let k;
|
|
7
7
|
function Z() {
|
|
8
|
-
return
|
|
8
|
+
return k || (k = L().public.cmcApiUrl, k);
|
|
9
9
|
}
|
|
10
10
|
function aa() {
|
|
11
|
-
const a = Z(),
|
|
11
|
+
const a = Z(), i = D(a, {
|
|
12
12
|
headers: {}
|
|
13
13
|
});
|
|
14
14
|
function t(e) {
|
|
15
|
-
|
|
16
|
-
...
|
|
15
|
+
i.options.headers = {
|
|
16
|
+
...i.options.headers ?? {},
|
|
17
17
|
Authorization: `Bearer ${e}`
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
20
|
+
function n() {
|
|
21
|
+
i.options.headers && delete i.options.headers.Authorization;
|
|
22
22
|
}
|
|
23
|
-
return { http:
|
|
23
|
+
return { http: i, setToken: t, clearToken: n };
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
return Object.entries(a).sort(([
|
|
25
|
+
function T(a) {
|
|
26
|
+
return Object.entries(a).sort(([i], [t]) => i.localeCompare(t)).map(([i, t]) => `${i}=${t}`).join("|");
|
|
27
27
|
}
|
|
28
28
|
function ea(a) {
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
29
|
+
const i = v({}), t = v({}), n = v({}), e = v({}), s = a.getItemId ?? ((r) => {
|
|
30
|
+
const d = r.id;
|
|
31
|
+
if (d === void 0)
|
|
32
32
|
throw new Error(
|
|
33
33
|
"useStore: no `getItemId` option provided and item has no `id` property. Either pass `getItemId` in the store options, or expose an `id` field on your items."
|
|
34
34
|
);
|
|
35
|
-
return
|
|
35
|
+
return d;
|
|
36
36
|
});
|
|
37
|
-
function
|
|
37
|
+
function l(r) {
|
|
38
38
|
return !!e.value[r];
|
|
39
39
|
}
|
|
40
|
-
async function
|
|
41
|
-
e.value[r] =
|
|
40
|
+
async function c(r, d) {
|
|
41
|
+
e.value[r] = d;
|
|
42
42
|
try {
|
|
43
|
-
const
|
|
44
|
-
return delete
|
|
45
|
-
} catch (
|
|
46
|
-
throw
|
|
43
|
+
const o = await d;
|
|
44
|
+
return delete n.value[r], o;
|
|
45
|
+
} catch (o) {
|
|
46
|
+
throw n.value[r] = o, o;
|
|
47
47
|
} finally {
|
|
48
48
|
delete e.value[r];
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
async function f(r,
|
|
51
|
+
async function f(r, d = {}) {
|
|
52
52
|
if (!a.fetchOne)
|
|
53
53
|
throw new Error("useStore.retrieve called but fetchOne is not defined in store options");
|
|
54
|
-
const { force:
|
|
55
|
-
if (
|
|
56
|
-
return
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
return
|
|
60
|
-
const B = a.fetchOne,
|
|
54
|
+
const { force: o = !1 } = d;
|
|
55
|
+
if (i.value[r] && !o)
|
|
56
|
+
return i.value[r];
|
|
57
|
+
const u = e.value[r];
|
|
58
|
+
if (u)
|
|
59
|
+
return u;
|
|
60
|
+
const B = a.fetchOne, S = (async () => {
|
|
61
61
|
try {
|
|
62
|
-
const
|
|
63
|
-
return
|
|
64
|
-
} catch (
|
|
65
|
-
|
|
62
|
+
const A = await B(r), b = a.enrichItem ? a.enrichItem(A) : A;
|
|
63
|
+
return i.value[r] = b, delete n.value[r], i.value[r];
|
|
64
|
+
} catch (A) {
|
|
65
|
+
n.value[r] = A;
|
|
66
66
|
return;
|
|
67
67
|
} finally {
|
|
68
68
|
delete e.value[r];
|
|
69
69
|
}
|
|
70
70
|
})();
|
|
71
|
-
return e.value[r] =
|
|
71
|
+
return e.value[r] = S, S;
|
|
72
72
|
}
|
|
73
73
|
function p(r) {
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
74
|
+
const d = T(r), o = t.value[d];
|
|
75
|
+
if (o)
|
|
76
76
|
return {
|
|
77
|
-
items:
|
|
78
|
-
total:
|
|
79
|
-
hasMore:
|
|
80
|
-
page:
|
|
81
|
-
limit:
|
|
77
|
+
items: o.itemIds.map((u) => i.value[u]).filter((u) => u !== void 0),
|
|
78
|
+
total: o.total,
|
|
79
|
+
hasMore: o.hasMore,
|
|
80
|
+
page: o.page,
|
|
81
|
+
limit: o.limit
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
async function m(r,
|
|
84
|
+
async function m(r, d = {}) {
|
|
85
85
|
if (!a.fetchPage)
|
|
86
86
|
throw new Error("useStore.list called but fetchPage is not defined in store options");
|
|
87
|
-
const
|
|
88
|
-
if (t.value[
|
|
87
|
+
const o = T(r), { force: u = !1 } = d;
|
|
88
|
+
if (t.value[o] && !u)
|
|
89
89
|
return p(r);
|
|
90
|
-
const B = e.value[
|
|
90
|
+
const B = e.value[o];
|
|
91
91
|
if (B)
|
|
92
92
|
return await B, p(r);
|
|
93
|
-
const
|
|
93
|
+
const S = a.fetchPage, A = (async () => {
|
|
94
94
|
try {
|
|
95
|
-
const b = await
|
|
95
|
+
const b = await S(r), R = [];
|
|
96
96
|
for (const E of b.items) {
|
|
97
|
-
const y = a.enrichItem ? a.enrichItem(E) : E,
|
|
98
|
-
|
|
97
|
+
const y = a.enrichItem ? a.enrichItem(E) : E, P = s(y);
|
|
98
|
+
i.value[P] = y, R.push(P);
|
|
99
99
|
}
|
|
100
|
-
t.value[
|
|
100
|
+
t.value[o] = {
|
|
101
101
|
itemIds: R,
|
|
102
102
|
total: b.total,
|
|
103
103
|
hasMore: b.hasMore,
|
|
104
104
|
page: b.page,
|
|
105
105
|
limit: b.limit
|
|
106
|
-
}, delete
|
|
106
|
+
}, delete n.value[o];
|
|
107
107
|
} catch (b) {
|
|
108
|
-
|
|
108
|
+
n.value[o] = b;
|
|
109
109
|
} finally {
|
|
110
|
-
delete e.value[
|
|
110
|
+
delete e.value[o];
|
|
111
111
|
}
|
|
112
112
|
})();
|
|
113
|
-
return e.value[
|
|
113
|
+
return e.value[o] = A, await A, p(r);
|
|
114
114
|
}
|
|
115
115
|
async function h(r) {
|
|
116
116
|
if (!a.createMutation)
|
|
117
117
|
throw new Error("useStore.create called but createMutation is not defined in store options");
|
|
118
|
-
const
|
|
119
|
-
return
|
|
118
|
+
const d = await a.createMutation(r), o = a.enrichItem ? a.enrichItem(d) : d, u = s(o);
|
|
119
|
+
return i.value[u] = o, t.value = {}, o;
|
|
120
120
|
}
|
|
121
|
-
async function g(r,
|
|
121
|
+
async function g(r, d) {
|
|
122
122
|
if (!a.updateMutation)
|
|
123
123
|
throw new Error("useStore.update called but updateMutation is not defined in store options");
|
|
124
|
-
const
|
|
125
|
-
return
|
|
124
|
+
const o = a.updateMutation, u = await c(r, (async () => o(r, d))()), B = a.enrichItem ? a.enrichItem(u) : u;
|
|
125
|
+
return i.value[r] = B, B;
|
|
126
126
|
}
|
|
127
|
-
async function
|
|
127
|
+
async function C(r) {
|
|
128
128
|
if (!a.removeMutation)
|
|
129
129
|
throw new Error("useStore.remove called but removeMutation is not defined in store options");
|
|
130
|
-
const
|
|
131
|
-
await
|
|
132
|
-
for (const
|
|
133
|
-
const
|
|
134
|
-
|
|
130
|
+
const d = a.removeMutation;
|
|
131
|
+
await c(r, (async () => d(r))()), delete i.value[r];
|
|
132
|
+
for (const o of Object.values(t.value)) {
|
|
133
|
+
const u = o.itemIds.indexOf(r);
|
|
134
|
+
u !== -1 && (o.itemIds.splice(u, 1), o.total = Math.max(0, o.total - 1));
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
function
|
|
138
|
-
|
|
137
|
+
function M() {
|
|
138
|
+
n.value = {};
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
|
|
140
|
+
function I() {
|
|
141
|
+
i.value = {}, t.value = {}, n.value = {}, e.value = {};
|
|
142
142
|
}
|
|
143
|
-
return { items:
|
|
143
|
+
return { items: i, views: t, errors: n, isPending: l, list: m, reset: I, retrieve: f, getView: p, track: c, create: h, update: g, remove: C, clearErrors: M };
|
|
144
144
|
}
|
|
145
|
-
function na(a,
|
|
146
|
-
const t = (
|
|
147
|
-
const e = a.value,
|
|
148
|
-
!e || !
|
|
145
|
+
function na(a, i) {
|
|
146
|
+
const t = (n) => {
|
|
147
|
+
const e = a.value, s = n.target;
|
|
148
|
+
!e || !s || e.contains(s) || i();
|
|
149
149
|
};
|
|
150
150
|
z(() => {
|
|
151
151
|
document.addEventListener("click", t);
|
|
@@ -154,20 +154,20 @@ function na(a, n) {
|
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
function ia() {
|
|
157
|
-
const { locale: a } =
|
|
158
|
-
function
|
|
157
|
+
const { locale: a } = w();
|
|
158
|
+
function i(t, n = null) {
|
|
159
159
|
const e = x[t.trim().toUpperCase()];
|
|
160
160
|
if (!e)
|
|
161
161
|
throw new Error(`Unknown country code: ${t}`);
|
|
162
|
-
if (
|
|
163
|
-
return e[
|
|
162
|
+
if (n && e[n])
|
|
163
|
+
return e[n];
|
|
164
164
|
if (e[a.value])
|
|
165
165
|
return e[a.value];
|
|
166
166
|
if (a.value !== "en" && e.en)
|
|
167
167
|
return e.en;
|
|
168
168
|
throw new Error(`Unknown country code: ${t}`);
|
|
169
169
|
}
|
|
170
|
-
return
|
|
170
|
+
return i;
|
|
171
171
|
}
|
|
172
172
|
const x = {
|
|
173
173
|
AD: { en: "Andorra", fr: "Andorre", es: "Andorra", de: "Andorra", it: "Andorra", pt: "Andorra", da: "Andorra" },
|
|
@@ -307,17 +307,17 @@ const x = {
|
|
|
307
307
|
ZA: { en: "South Africa", fr: "Afrique Du Sud", es: "Sudáfrica", de: "Südafrika", it: "Sudafrica", pt: "África Do Sul", da: "Sydafrika" },
|
|
308
308
|
ZM: { en: "Zambia", fr: "Zambie", es: "Zambia", de: "Sambia", it: "Zambia", pt: "Zâmbia", da: "Zambia" },
|
|
309
309
|
ZW: { en: "Zimbabwe", fr: "Zimbabwe", es: "Zimbabue", de: "Simbabwe", it: "Zimbabwe", pt: "Zimbábue", da: "Zimbabwe" }
|
|
310
|
-
}, ta = ({ code: a, message:
|
|
311
|
-
const
|
|
310
|
+
}, ta = ({ code: a, message: i, data: t }) => {
|
|
311
|
+
const n = i || "An unexpected error occurred", e = q({
|
|
312
312
|
statusCode: a,
|
|
313
|
-
statusMessage:
|
|
314
|
-
message:
|
|
313
|
+
statusMessage: n,
|
|
314
|
+
message: n,
|
|
315
315
|
data: t
|
|
316
316
|
});
|
|
317
317
|
throw K(e), e;
|
|
318
318
|
}, V = "ilcJCL_lmpwcEJfSkKND";
|
|
319
319
|
function ra() {
|
|
320
|
-
const { gtagId: a } =
|
|
320
|
+
const { gtagId: a } = L().public;
|
|
321
321
|
return { reportConversion: () => {
|
|
322
322
|
if (typeof window > "u" || typeof window.gtag > "u" || !a)
|
|
323
323
|
return;
|
|
@@ -329,127 +329,117 @@ 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 } = w();
|
|
333
333
|
return { contactUrl: N(() => a.value === "fr" ? `${U}/contact` : `${U}/${a.value}/contact`) };
|
|
334
334
|
}
|
|
335
335
|
function sa() {
|
|
336
|
-
async function a(
|
|
336
|
+
async function a(n) {
|
|
337
337
|
await Promise.all(
|
|
338
|
-
|
|
339
|
-
(e) => new Promise((
|
|
340
|
-
if (!e) return
|
|
341
|
-
const
|
|
342
|
-
|
|
338
|
+
n.map(
|
|
339
|
+
(e) => new Promise((s) => {
|
|
340
|
+
if (!e) return s(null);
|
|
341
|
+
const l = new Image();
|
|
342
|
+
l.onload = () => s(null), l.onerror = () => s(null), l.src = e;
|
|
343
343
|
})
|
|
344
344
|
)
|
|
345
345
|
);
|
|
346
346
|
}
|
|
347
|
-
function n
|
|
348
|
-
return e.split(".").reduce((
|
|
347
|
+
function i(n, e) {
|
|
348
|
+
return e.split(".").reduce((s, l) => s && typeof s == "object" && l in s ? s[l] : "", n) ?? "";
|
|
349
349
|
}
|
|
350
|
-
function t(
|
|
350
|
+
function t(n, e, s) {
|
|
351
351
|
if (import.meta.server)
|
|
352
|
-
return async (
|
|
353
|
-
|
|
352
|
+
return async (c) => {
|
|
353
|
+
n.value = !0;
|
|
354
354
|
};
|
|
355
|
-
const
|
|
355
|
+
const l = H(
|
|
356
356
|
`${e}LoadedImageCache`,
|
|
357
357
|
() => ({})
|
|
358
358
|
);
|
|
359
|
-
return async (
|
|
360
|
-
if (!
|
|
361
|
-
|
|
359
|
+
return async (c) => {
|
|
360
|
+
if (!c) {
|
|
361
|
+
n.value = !1;
|
|
362
362
|
return;
|
|
363
363
|
}
|
|
364
|
-
const f =
|
|
365
|
-
if (
|
|
366
|
-
|
|
364
|
+
const f = s.map((h) => i(c, h)), p = `${e}|${f.join("|")}`;
|
|
365
|
+
if (l.value[p]) {
|
|
366
|
+
n.value = !0;
|
|
367
367
|
return;
|
|
368
368
|
}
|
|
369
|
-
|
|
369
|
+
n.value = !1;
|
|
370
370
|
const m = f.filter(Boolean).map(String);
|
|
371
|
-
await a(m),
|
|
371
|
+
await a(m), l.value[p] = !0, n.value = !0;
|
|
372
372
|
};
|
|
373
373
|
}
|
|
374
374
|
return t;
|
|
375
375
|
}
|
|
376
376
|
const J = {
|
|
377
377
|
en: ["US", "UK"]
|
|
378
|
-
},
|
|
379
|
-
function
|
|
380
|
-
const
|
|
378
|
+
}, j = "FR";
|
|
379
|
+
function $(a) {
|
|
380
|
+
const i = a.trim().replace("_", "-"), [t, n] = i.split("-");
|
|
381
381
|
return {
|
|
382
382
|
language: t?.toLowerCase() ?? "",
|
|
383
|
-
region:
|
|
383
|
+
region: n?.toUpperCase() ?? ""
|
|
384
384
|
};
|
|
385
385
|
}
|
|
386
|
-
function
|
|
386
|
+
function G(a) {
|
|
387
387
|
return a.toString().trim().toUpperCase();
|
|
388
388
|
}
|
|
389
389
|
function da() {
|
|
390
|
-
function a(
|
|
390
|
+
function a(i, t) {
|
|
391
391
|
if (!t.length) return;
|
|
392
|
-
const
|
|
393
|
-
|
|
394
|
-
const f = J[
|
|
395
|
-
f?.length &&
|
|
396
|
-
for (const p of
|
|
392
|
+
const n = t.map(G), e = new Set(n), { language: s, region: l } = $(i), c = [];
|
|
393
|
+
l && c.push(l);
|
|
394
|
+
const f = J[s];
|
|
395
|
+
f?.length && c.push(...f.map(G)), s && c.push(s.toUpperCase()), c.push(j);
|
|
396
|
+
for (const p of c)
|
|
397
397
|
if (e.has(p))
|
|
398
398
|
return p;
|
|
399
|
-
return
|
|
399
|
+
return n[0];
|
|
400
400
|
}
|
|
401
401
|
return { getRegionFromLocale: a };
|
|
402
402
|
}
|
|
403
403
|
function ua() {
|
|
404
|
-
const { t: a } =
|
|
405
|
-
function
|
|
406
|
-
const e = a(t),
|
|
404
|
+
const { t: a } = w();
|
|
405
|
+
function i(t, n) {
|
|
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);
|
|
408
408
|
for (; h; ) {
|
|
409
|
-
const { index: g, 0:
|
|
410
|
-
g > m &&
|
|
409
|
+
const { index: g, 0: C, 1: M, 2: I } = h;
|
|
410
|
+
g > m && s.push({ text: e.slice(m, g), ...p }), I && M && s.push({ text: I, ...p, [M]: !0 }), m = g + C.length, h = f.exec(e);
|
|
411
411
|
}
|
|
412
|
-
return m < e.length &&
|
|
413
|
-
}
|
|
414
|
-
return { parse: n };
|
|
415
|
-
}
|
|
416
|
-
function la(a) {
|
|
417
|
-
const { t: n, te: t, tm: i } = M();
|
|
418
|
-
function e(o, d) {
|
|
419
|
-
const u = `${o}.${d}`, f = `${o}.${a[0]}`;
|
|
420
|
-
return t(u) ? n(u) : t(f) ? n(f) : typeof i(o) == "string" ? n(o, {
|
|
421
|
-
primaryType: n(`common.primary-type.${d}`).toLowerCase()
|
|
422
|
-
}) : "";
|
|
412
|
+
return m < e.length && s.push({ text: e.slice(m), ...p }), s;
|
|
423
413
|
}
|
|
424
|
-
return {
|
|
414
|
+
return { parse: i };
|
|
425
415
|
}
|
|
426
|
-
function
|
|
427
|
-
const
|
|
428
|
-
() =>
|
|
416
|
+
function la(a, i, t = 768) {
|
|
417
|
+
const n = v(t - 1), e = N(
|
|
418
|
+
() => n.value >= t ? i : a
|
|
429
419
|
);
|
|
430
420
|
if (import.meta.client) {
|
|
431
|
-
const
|
|
432
|
-
|
|
421
|
+
const s = () => {
|
|
422
|
+
n.value = window.innerWidth;
|
|
433
423
|
};
|
|
434
424
|
z(() => {
|
|
435
|
-
|
|
425
|
+
s(), window.addEventListener("resize", s);
|
|
436
426
|
}), O(() => {
|
|
437
|
-
window.removeEventListener("resize",
|
|
427
|
+
window.removeEventListener("resize", s);
|
|
438
428
|
});
|
|
439
429
|
}
|
|
440
|
-
return { size: e, windowWidth:
|
|
430
|
+
return { size: e, windowWidth: n };
|
|
441
431
|
}
|
|
442
|
-
function
|
|
443
|
-
const { locale: a } =
|
|
444
|
-
function
|
|
432
|
+
function ca() {
|
|
433
|
+
const { locale: a } = w();
|
|
434
|
+
function i(t, n = "fr") {
|
|
445
435
|
if (!t) return "";
|
|
446
436
|
const e = a.value;
|
|
447
|
-
return t[e] ?? t[
|
|
437
|
+
return t[e] ?? t[n] ?? "";
|
|
448
438
|
}
|
|
449
|
-
return
|
|
439
|
+
return i;
|
|
450
440
|
}
|
|
451
441
|
export {
|
|
452
|
-
|
|
442
|
+
T as getViewKey,
|
|
453
443
|
ta as showAndThrowError,
|
|
454
444
|
na as useClickOutside,
|
|
455
445
|
ia as useCountriesTranslation,
|
|
@@ -459,8 +449,7 @@ export {
|
|
|
459
449
|
sa as useImageCacheWatcherCallback,
|
|
460
450
|
da as useLocaleHelpers,
|
|
461
451
|
ua as useParseTranslation,
|
|
462
|
-
la as
|
|
463
|
-
ca as useResponsiveSize,
|
|
452
|
+
la as useResponsiveSize,
|
|
464
453
|
ea as useStore,
|
|
465
|
-
|
|
454
|
+
ca as useTranslate
|
|
466
455
|
};
|
|
@@ -31,4 +31,4 @@ import { Ref } from 'vue';
|
|
|
31
31
|
* // Template: <ProfileCard v-show="imagesLoaded" :profile="profile" />
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
export declare function useImageCacheWatcherCallback(): <T extends
|
|
34
|
+
export declare function useImageCacheWatcherCallback(): <T extends object>(areImagesLoaded: Ref<boolean>, cacheKeyPrefix: string, fields: string[]) => (_watchedObject: T | undefined) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a `getPrimaryTypeTranslation(baseKey, primaryType)` helper for
|
|
3
|
-
* resolving copy that varies per **primary type** (a CMC concept: the kind of
|
|
4
|
-
* entity a page is about — `school`, `company`, `agency`, …).
|
|
5
|
-
*
|
|
6
|
-
* Translators authoring locale files have three ways to supply a string for a
|
|
7
|
-
* given `baseKey` + `primaryType` pair; the helper tries them in order:
|
|
8
|
-
*
|
|
9
|
-
* 1. **Specific key** — `{baseKey}.{primaryType}` (e.g. `cta.subscribe.school`)
|
|
10
|
-
* 2. **Per-type fallback** — `{baseKey}.{primaryTypes[0]}` (the first declared
|
|
11
|
-
* primary type acts as the default copy when a specific override is missing)
|
|
12
|
-
* 3. **Generic key with interpolation** — `{baseKey}` rendered with a
|
|
13
|
-
* `{primaryType}` placeholder filled by the lowercased translation of
|
|
14
|
-
* `common.primary-type.{primaryType}`
|
|
15
|
-
*
|
|
16
|
-
* Returns `""` if all three strategies miss.
|
|
17
|
-
*
|
|
18
|
-
* @typeParam T - Tuple/array of accepted primary type literals.
|
|
19
|
-
* @param primaryTypes - Authoritative list of supported primary types. The
|
|
20
|
-
* **first** entry is the per-type fallback (strategy #2).
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* const PRIMARY_TYPES = ['school', 'company', 'agency'] as const
|
|
25
|
-
* const { getPrimaryTypeTranslation } = usePrimaryTypeTranslation(PRIMARY_TYPES)
|
|
26
|
-
*
|
|
27
|
-
* // locale: { cta: { subscribe: { school: 'Join the school', company: 'Join the company' } } }
|
|
28
|
-
* getPrimaryTypeTranslation('cta.subscribe', 'school') // → 'Join the school'
|
|
29
|
-
* getPrimaryTypeTranslation('cta.subscribe', 'agency') // → falls back to school's copy
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare function usePrimaryTypeTranslation<T extends string>(primaryTypes: readonly T[]): {
|
|
33
|
-
getPrimaryTypeTranslation: (baseKey: string, primaryType: T) => string;
|
|
34
|
-
};
|