@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, primary
12
- * types, region resolution, and rich tagged messages.
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 G, showError as K, useState as H } from "nuxt/app";
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 M } from "vue-i18n";
4
+ import { useI18n as w } from "vue-i18n";
5
5
  import { createError as q } from "h3";
6
- let w;
6
+ let k;
7
7
  function Z() {
8
- return w || (w = G().public.cmcApiUrl, w);
8
+ return k || (k = L().public.cmcApiUrl, k);
9
9
  }
10
10
  function aa() {
11
- const a = Z(), n = D(a, {
11
+ const a = Z(), i = D(a, {
12
12
  headers: {}
13
13
  });
14
14
  function t(e) {
15
- n.options.headers = {
16
- ...n.options.headers ?? {},
15
+ i.options.headers = {
16
+ ...i.options.headers ?? {},
17
17
  Authorization: `Bearer ${e}`
18
18
  };
19
19
  }
20
- function i() {
21
- n.options.headers && delete n.options.headers.Authorization;
20
+ function n() {
21
+ i.options.headers && delete i.options.headers.Authorization;
22
22
  }
23
- return { http: n, setToken: t, clearToken: i };
23
+ return { http: i, setToken: t, clearToken: n };
24
24
  }
25
- function P(a) {
26
- return Object.entries(a).sort(([n], [t]) => n.localeCompare(t)).map(([n, t]) => `${n}=${t}`).join("|");
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 n = v({}), t = v({}), i = v({}), e = v({}), o = a.getItemId ?? ((r) => {
30
- const l = r.id;
31
- if (l === void 0)
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 l;
35
+ return d;
36
36
  });
37
- function d(r) {
37
+ function l(r) {
38
38
  return !!e.value[r];
39
39
  }
40
- async function u(r, l) {
41
- e.value[r] = l;
40
+ async function c(r, d) {
41
+ e.value[r] = d;
42
42
  try {
43
- const s = await l;
44
- return delete i.value[r], s;
45
- } catch (s) {
46
- throw i.value[r] = s, s;
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, l = {}) {
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: s = !1 } = l;
55
- if (n.value[r] && !s)
56
- return n.value[r];
57
- const c = e.value[r];
58
- if (c)
59
- return c;
60
- const B = a.fetchOne, k = (async () => {
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 C = await B(r), b = a.enrichItem ? a.enrichItem(C) : C;
63
- return n.value[r] = b, delete i.value[r], n.value[r];
64
- } catch (C) {
65
- i.value[r] = C;
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] = k, k;
71
+ return e.value[r] = S, S;
72
72
  }
73
73
  function p(r) {
74
- const l = P(r), s = t.value[l];
75
- if (s)
74
+ const d = T(r), o = t.value[d];
75
+ if (o)
76
76
  return {
77
- items: s.itemIds.map((c) => n.value[c]).filter((c) => c !== void 0),
78
- total: s.total,
79
- hasMore: s.hasMore,
80
- page: s.page,
81
- limit: s.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, l = {}) {
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 s = P(r), { force: c = !1 } = l;
88
- if (t.value[s] && !c)
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[s];
90
+ const B = e.value[o];
91
91
  if (B)
92
92
  return await B, p(r);
93
- const k = a.fetchPage, C = (async () => {
93
+ const S = a.fetchPage, A = (async () => {
94
94
  try {
95
- const b = await k(r), R = [];
95
+ const b = await S(r), R = [];
96
96
  for (const E of b.items) {
97
- const y = a.enrichItem ? a.enrichItem(E) : E, T = o(y);
98
- n.value[T] = y, R.push(T);
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[s] = {
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 i.value[s];
106
+ }, delete n.value[o];
107
107
  } catch (b) {
108
- i.value[s] = b;
108
+ n.value[o] = b;
109
109
  } finally {
110
- delete e.value[s];
110
+ delete e.value[o];
111
111
  }
112
112
  })();
113
- return e.value[s] = C, await C, p(r);
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 l = await a.createMutation(r), s = a.enrichItem ? a.enrichItem(l) : l, c = o(s);
119
- return n.value[c] = s, t.value = {}, s;
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, l) {
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 s = a.updateMutation, c = await u(r, (async () => s(r, l))()), B = a.enrichItem ? a.enrichItem(c) : c;
125
- return n.value[r] = B, B;
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 A(r) {
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 l = a.removeMutation;
131
- await u(r, (async () => l(r))()), delete n.value[r];
132
- for (const s of Object.values(t.value)) {
133
- const c = s.itemIds.indexOf(r);
134
- c !== -1 && (s.itemIds.splice(c, 1), s.total = Math.max(0, s.total - 1));
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 I() {
138
- i.value = {};
137
+ function M() {
138
+ n.value = {};
139
139
  }
140
- function S() {
141
- n.value = {}, t.value = {}, i.value = {}, e.value = {};
140
+ function I() {
141
+ i.value = {}, t.value = {}, n.value = {}, e.value = {};
142
142
  }
143
- return { items: n, views: t, errors: i, isPending: d, list: m, reset: S, retrieve: f, getView: p, track: u, create: h, update: g, remove: A, clearErrors: I };
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, n) {
146
- const t = (i) => {
147
- const e = a.value, o = i.target;
148
- !e || !o || e.contains(o) || n();
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 } = M();
158
- function n(t, i = null) {
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 (i && e[i])
163
- return e[i];
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 n;
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: n, data: t }) => {
311
- const i = n || "An unexpected error occurred", e = q({
310
+ }, ta = ({ code: a, message: i, data: t }) => {
311
+ const n = i || "An unexpected error occurred", e = q({
312
312
  statusCode: a,
313
- statusMessage: i,
314
- message: i,
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 } = G().public;
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 } = M();
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(i) {
336
+ async function a(n) {
337
337
  await Promise.all(
338
- i.map(
339
- (e) => new Promise((o) => {
340
- if (!e) return o(null);
341
- const d = new Image();
342
- d.onload = () => o(null), d.onerror = () => o(null), d.src = e;
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(i, e) {
348
- return e.split(".").reduce((o, d) => o && typeof o == "object" && d in o ? o[d] : "", i) ?? "";
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(i, e, o) {
350
+ function t(n, e, s) {
351
351
  if (import.meta.server)
352
- return async (u) => {
353
- i.value = !0;
352
+ return async (c) => {
353
+ n.value = !0;
354
354
  };
355
- const d = H(
355
+ const l = H(
356
356
  `${e}LoadedImageCache`,
357
357
  () => ({})
358
358
  );
359
- return async (u) => {
360
- if (!u) {
361
- i.value = !1;
359
+ return async (c) => {
360
+ if (!c) {
361
+ n.value = !1;
362
362
  return;
363
363
  }
364
- const f = o.map((h) => n(u, h)), p = `${e}|${f.join("|")}`;
365
- if (d.value[p]) {
366
- i.value = !0;
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
- i.value = !1;
369
+ n.value = !1;
370
370
  const m = f.filter(Boolean).map(String);
371
- await a(m), d.value[p] = !0, i.value = !0;
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
- }, $ = "FR";
379
- function j(a) {
380
- const n = a.trim().replace("_", "-"), [t, i] = n.split("-");
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: i?.toUpperCase() ?? ""
383
+ region: n?.toUpperCase() ?? ""
384
384
  };
385
385
  }
386
- function L(a) {
386
+ function G(a) {
387
387
  return a.toString().trim().toUpperCase();
388
388
  }
389
389
  function da() {
390
- function a(n, t) {
390
+ function a(i, t) {
391
391
  if (!t.length) return;
392
- const i = t.map(L), e = new Set(i), { language: o, region: d } = j(n), u = [];
393
- d && u.push(d);
394
- const f = J[o];
395
- f?.length && u.push(...f.map(L)), o && u.push(o.toUpperCase()), u.push($);
396
- for (const p of u)
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 i[0];
399
+ return n[0];
400
400
  }
401
401
  return { getRegionFromLocale: a };
402
402
  }
403
403
  function ua() {
404
- const { t: a } = M();
405
- function n(t, i) {
406
- const e = a(t), o = [], u = i.map((g) => g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), f = new RegExp(`\\[(${u})\\]([\\s\\S]*?)\\[\\/\\1\\]`, "g"), p = i.reduce((g, A) => (g[A] = !1, g), {});
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: A, 1: I, 2: S } = h;
410
- g > m && o.push({ text: e.slice(m, g), ...p }), S && I && o.push({ text: S, ...p, [I]: !0 }), m = g + A.length, h = f.exec(e);
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 && o.push({ text: e.slice(m), ...p }), o;
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 { getPrimaryTypeTranslation: e };
414
+ return { parse: i };
425
415
  }
426
- function ca(a, n, t = 768) {
427
- const i = v(t - 1), e = N(
428
- () => i.value >= t ? n : a
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 o = () => {
432
- i.value = window.innerWidth;
421
+ const s = () => {
422
+ n.value = window.innerWidth;
433
423
  };
434
424
  z(() => {
435
- o(), window.addEventListener("resize", o);
425
+ s(), window.addEventListener("resize", s);
436
426
  }), O(() => {
437
- window.removeEventListener("resize", o);
427
+ window.removeEventListener("resize", s);
438
428
  });
439
429
  }
440
- return { size: e, windowWidth: i };
430
+ return { size: e, windowWidth: n };
441
431
  }
442
- function pa() {
443
- const { locale: a } = M();
444
- function n(t, i = "fr") {
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[i] ?? "";
437
+ return t[e] ?? t[n] ?? "";
448
438
  }
449
- return n;
439
+ return i;
450
440
  }
451
441
  export {
452
- P as getViewKey,
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 usePrimaryTypeTranslation,
463
- ca as useResponsiveSize,
452
+ la as useResponsiveSize,
464
453
  ea as useStore,
465
- pa as useTranslate
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 Record<string, unknown>>(areImagesLoaded: Ref<boolean>, cacheKeyPrefix: string, fields: string[]) => (_watchedObject: T | undefined) => Promise<void>;
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,7 +1,7 @@
1
1
  {
2
2
  "name": "@choosemycompany/lib",
3
3
  "description": "Shared composables, stores and types for ChooseMyCompany front apps",
4
- "version": "0.3.1",
4
+ "version": "0.4.0",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "packageManager": "pnpm@10.17.0",
@@ -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
- };