@loczer/storefront-sdk 0.221.0 → 0.222.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.
Files changed (40) hide show
  1. package/dist/StorefrontContext.d.ts +2 -2
  2. package/dist/StorefrontProvider.d.ts +2 -2
  3. package/dist/components/Header/index.d.ts.map +1 -1
  4. package/dist/components/Header/index.js +118 -126
  5. package/dist/components/LanguageSelector/index.d.ts +7 -0
  6. package/dist/components/LanguageSelector/index.d.ts.map +1 -0
  7. package/dist/components/LanguageSelector/index.js +69 -0
  8. package/dist/components/StorefrontCartPanel/index.d.ts +2 -8
  9. package/dist/components/StorefrontCartPanel/index.d.ts.map +1 -1
  10. package/dist/components/StorefrontCartPanel/index.js +65 -107
  11. package/dist/i18n/I18nProvider.d.ts +3 -2
  12. package/dist/i18n/I18nProvider.d.ts.map +1 -1
  13. package/dist/i18n/I18nProvider.js +61 -64
  14. package/dist/i18n/en.d.ts +2 -2
  15. package/dist/i18n/en.js +2 -2
  16. package/dist/i18n/fr.d.ts +2 -2
  17. package/dist/i18n/fr.js +2 -2
  18. package/dist/i18n/languages.d.ts +15 -0
  19. package/dist/i18n/languages.d.ts.map +1 -0
  20. package/dist/i18n/languages.js +26 -0
  21. package/dist/index.d.ts +33 -24
  22. package/dist/index.js +50 -49
  23. package/dist/lib/cartSummary.d.ts +2 -5
  24. package/dist/lib/cartSummary.d.ts.map +1 -1
  25. package/dist/lib/cartSummary.js +5 -11
  26. package/dist/pages/BookingPage.d.ts.map +1 -1
  27. package/dist/pages/BookingPage.js +150 -148
  28. package/dist/pages/CheckoutPage.d.ts.map +1 -1
  29. package/dist/pages/CheckoutPage.js +1 -2
  30. package/dist/pages/ContractSaleDocumentPage.d.ts +2 -3
  31. package/dist/pages/ContractSaleDocumentPage.d.ts.map +1 -1
  32. package/dist/pages/ContractSaleDocumentPage.js +18 -17
  33. package/dist/pages/checkout/components/CheckoutSummaryColumn.d.ts +2 -2
  34. package/dist/pages/checkout/components/CheckoutSummaryColumn.d.ts.map +1 -1
  35. package/dist/pages/checkout/components/CheckoutSummaryColumn.js +14 -15
  36. package/dist/storefront.css +1 -1
  37. package/dist/storefrontSchemas.d.ts +2 -2
  38. package/dist/storefrontSchemas.d.ts.map +1 -1
  39. package/dist/storefrontSchemas.js +95 -94
  40. package/package.json +1 -1
@@ -4,97 +4,97 @@ import { Button as n } from "../../ui/button.js";
4
4
  import { Input as r } from "../../ui/input.js";
5
5
  import { Card as i } from "../../ui/card.js";
6
6
  import { ProductWarningNotice as a } from "../ProductWarningNotice/index.js";
7
- import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
8
- import { Link as l } from "@rpcbase/router";
9
- import { useTranslation as u } from "react-i18next";
10
- import { cn as d } from "@rpcbase/ui";
11
- import { ArrowRight as f, Trash2 as p } from "lucide-react";
7
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
8
+ import { Link as c } from "@rpcbase/router";
9
+ import { useTranslation as l } from "react-i18next";
10
+ import { cn as u } from "@rpcbase/ui";
11
+ import { ArrowRight as d, Trash2 as f } from "lucide-react";
12
12
  //#region src/components/StorefrontCartPanel/index.tsx
13
- function m({ lines: m, itemCount: h, totalPerBaseUnitMinor: g, baseUnitLabel: _, estimatedTotalMinor: v, discountedEstimatedTotalMinor: y, discountAmountMinor: b, lateReturnSurchargeMinor: x, couponCode: S, durationInBaseUnitLabel: C, title: w, description: T, checkoutPath: E, showCheckoutAction: D = !1, showClearAction: O = !1, editable: k = !0, summaryAddon: A, pricingSummary: j, stickyTopClassName: M = "top-24", onQuantityChange: N, onRemove: P, onClear: F }) {
14
- let { t: I, i18n: L } = u();
15
- return /* @__PURE__ */ c(i, {
16
- className: d("sticky border-slate-200 bg-white shadow-sm", M),
17
- children: [/* @__PURE__ */ c("div", {
13
+ function p({ lines: p, itemCount: m, baseUnitLabel: h, totalMinor: g, title: _, description: v, checkoutPath: y, showCheckoutAction: b = !1, showClearAction: x = !1, editable: S = !0, summaryAddon: C, pricingSummary: w, stickyTopClassName: T = "top-24", onQuantityChange: E, onRemove: D, onClear: O }) {
14
+ let { t: k, i18n: A } = l();
15
+ return /* @__PURE__ */ s(i, {
16
+ className: u("sticky border-slate-200 bg-white shadow-sm", T),
17
+ children: [/* @__PURE__ */ s("div", {
18
18
  className: "border-b border-slate-200 px-4 py-4",
19
- children: [/* @__PURE__ */ c("div", {
19
+ children: [/* @__PURE__ */ s("div", {
20
20
  className: "flex items-center justify-between gap-3",
21
- children: [/* @__PURE__ */ s("p", {
21
+ children: [/* @__PURE__ */ o("p", {
22
22
  className: "text-sm font-semibold text-slate-950",
23
- children: /* @__PURE__ */ s("span", { children: w ?? I("cart_title") })
24
- }), /* @__PURE__ */ s(t, {
23
+ children: /* @__PURE__ */ o("span", { children: _ ?? k("cart_title") })
24
+ }), /* @__PURE__ */ o(t, {
25
25
  variant: "outline",
26
26
  className: "border-slate-200 bg-white text-slate-700",
27
- children: /* @__PURE__ */ s("span", { children: I("cart_items_count", { count: h }) })
27
+ children: /* @__PURE__ */ o("span", { children: k("cart_items_count", { count: m }) })
28
28
  })]
29
- }), T ? /* @__PURE__ */ s("p", {
29
+ }), v ? /* @__PURE__ */ o("p", {
30
30
  className: "mt-1 text-xs text-slate-600",
31
- children: /* @__PURE__ */ s("span", { children: T })
31
+ children: /* @__PURE__ */ o("span", { children: v })
32
32
  }) : null]
33
- }), /* @__PURE__ */ c("div", {
33
+ }), /* @__PURE__ */ s("div", {
34
34
  className: "grid gap-3 p-4",
35
35
  children: [
36
- m.length === 0 ? /* @__PURE__ */ s("p", {
36
+ p.length === 0 ? /* @__PURE__ */ o("p", {
37
37
  className: "text-sm text-slate-600",
38
- children: /* @__PURE__ */ s("span", { children: I("cart_empty") })
39
- }) : /* @__PURE__ */ s("ul", {
38
+ children: /* @__PURE__ */ o("span", { children: k("cart_empty") })
39
+ }) : /* @__PURE__ */ o("ul", {
40
40
  className: "divide-y divide-slate-200",
41
- children: m.map((i) => {
42
- let o = e(i.unitPriceMinor, L.language), l = i.insufficientCapacity === !0, u = i.availabilityIssue === "quantity_unavailable" ? I("availability_quantity_unavailable") : I("availability_out_of_stock");
43
- return /* @__PURE__ */ c("li", {
41
+ children: p.map((i) => {
42
+ let c = e(i.unitPriceMinor, A.language), l = i.insufficientCapacity === !0, u = i.availabilityIssue === "quantity_unavailable" ? k("availability_quantity_unavailable") : k("availability_out_of_stock");
43
+ return /* @__PURE__ */ s("li", {
44
44
  className: "flex items-start justify-between gap-3 py-4 first:pt-0 last:pb-0",
45
- children: [/* @__PURE__ */ c("div", {
45
+ children: [/* @__PURE__ */ s("div", {
46
46
  className: "flex min-w-0 flex-1 flex-col gap-1",
47
47
  children: [
48
- /* @__PURE__ */ s("p", {
48
+ /* @__PURE__ */ o("p", {
49
49
  className: "truncate text-sm font-medium text-slate-950",
50
- children: /* @__PURE__ */ s("span", { children: i.productName })
50
+ children: /* @__PURE__ */ o("span", { children: i.productName })
51
51
  }),
52
- i.productVariantLabel ? /* @__PURE__ */ s("p", {
52
+ i.productVariantLabel ? /* @__PURE__ */ o("p", {
53
53
  className: "text-xs text-slate-600",
54
- children: /* @__PURE__ */ s("span", { children: `${I(i.productVariantIsSize ? "product_size_label" : "product_variant_label")}: ${i.productVariantLabel}` })
54
+ children: /* @__PURE__ */ o("span", { children: `${k(i.productVariantIsSize ? "product_size_label" : "product_variant_label")}: ${i.productVariantLabel}` })
55
55
  }) : null,
56
- i.productVariantDescription ? /* @__PURE__ */ s("p", {
56
+ i.productVariantDescription ? /* @__PURE__ */ o("p", {
57
57
  className: "text-xs text-slate-500",
58
- children: /* @__PURE__ */ s("span", { children: i.productVariantDescription })
58
+ children: /* @__PURE__ */ o("span", { children: i.productVariantDescription })
59
59
  }) : null,
60
- /* @__PURE__ */ s(a, { warning: i.productWarning }),
61
- /* @__PURE__ */ s("p", {
60
+ /* @__PURE__ */ o(a, { warning: i.productWarning }),
61
+ /* @__PURE__ */ o("p", {
62
62
  className: "text-xs text-slate-600",
63
- children: /* @__PURE__ */ s("span", { children: I("cart_line_meta", {
63
+ children: /* @__PURE__ */ o("span", { children: k("cart_line_meta", {
64
64
  quantity: i.quantity,
65
- price: o,
66
- unit: _
65
+ price: c,
66
+ unit: h
67
67
  }) })
68
68
  }),
69
- l ? /* @__PURE__ */ s("div", {
69
+ l ? /* @__PURE__ */ o("div", {
70
70
  className: "flex flex-col items-start gap-1 pt-1",
71
- children: /* @__PURE__ */ s(t, {
71
+ children: /* @__PURE__ */ o(t, {
72
72
  variant: "destructive",
73
- children: /* @__PURE__ */ s("span", { children: u })
73
+ children: /* @__PURE__ */ o("span", { children: u })
74
74
  })
75
75
  }) : null
76
76
  ]
77
- }), k ? /* @__PURE__ */ c("div", {
77
+ }), S ? /* @__PURE__ */ s("div", {
78
78
  className: "flex items-center gap-2",
79
- children: [N ? /* @__PURE__ */ s(r, {
79
+ children: [E ? /* @__PURE__ */ o(r, {
80
80
  type: "number",
81
81
  min: 1,
82
82
  max: 99,
83
83
  value: i.quantity,
84
84
  onChange: (e) => {
85
85
  let t = Number(e.target.value);
86
- N(i.key, Number.isFinite(t) ? t : 0);
86
+ E(i.key, Number.isFinite(t) ? t : 0);
87
87
  },
88
88
  className: "h-9 w-16",
89
- "aria-label": I("quantity_label")
90
- }) : null, P ? /* @__PURE__ */ s(n, {
89
+ "aria-label": k("quantity_label")
90
+ }) : null, D ? /* @__PURE__ */ o(n, {
91
91
  type: "button",
92
92
  variant: "ghost",
93
93
  size: "icon",
94
94
  className: "h-8 w-8 text-slate-500 hover:bg-slate-50 hover:text-slate-700",
95
- onClick: () => P(i.key),
96
- "aria-label": I("remove_from_cart"),
97
- children: /* @__PURE__ */ s(p, {
95
+ onClick: () => D(i.key),
96
+ "aria-label": k("remove_from_cart"),
97
+ children: /* @__PURE__ */ o(f, {
98
98
  className: "h-4 w-4",
99
99
  "aria-hidden": "true"
100
100
  })
@@ -103,77 +103,35 @@ function m({ lines: m, itemCount: h, totalPerBaseUnitMinor: g, baseUnitLabel: _,
103
103
  }, i.key);
104
104
  })
105
105
  }),
106
- A,
107
- j ?? /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ c("div", {
106
+ C,
107
+ w ?? (typeof g == "number" ? /* @__PURE__ */ s("div", {
108
108
  className: "flex items-center justify-between gap-3 border-t border-slate-200 pt-3 text-sm",
109
- children: [/* @__PURE__ */ s("p", {
109
+ children: [/* @__PURE__ */ o("p", {
110
110
  className: "text-slate-700",
111
- children: /* @__PURE__ */ s("span", { children: I("cart_total_per_unit", { unit: _ }) })
112
- }), /* @__PURE__ */ s("p", {
111
+ children: /* @__PURE__ */ o("span", { children: k("cart_total") })
112
+ }), /* @__PURE__ */ o("p", {
113
113
  className: "font-semibold text-slate-950",
114
- children: /* @__PURE__ */ s("span", { children: e(g, L.language) })
114
+ children: /* @__PURE__ */ o("span", { children: e(g, A.language) })
115
115
  })]
116
- }), typeof v == "number" ? /* @__PURE__ */ c(o, { children: [
117
- C ? /* @__PURE__ */ c("div", {
118
- className: "flex items-center justify-between gap-3 text-sm",
119
- children: [/* @__PURE__ */ s("p", {
120
- className: "text-slate-700",
121
- children: /* @__PURE__ */ s("span", { children: I("checkout_estimated_duration") })
122
- }), /* @__PURE__ */ s(t, {
123
- variant: "outline",
124
- className: "border-slate-200 bg-white text-slate-700",
125
- children: /* @__PURE__ */ s("span", { children: C })
126
- })]
127
- }) : null,
128
- typeof b == "number" && b > 0 ? /* @__PURE__ */ c("div", {
129
- className: "flex items-center justify-between gap-3 text-sm",
130
- children: [/* @__PURE__ */ s("p", {
131
- className: "text-success",
132
- children: /* @__PURE__ */ s("span", { children: I("checkout_coupon_discount", { code: S ?? "" }) })
133
- }), /* @__PURE__ */ s("p", {
134
- className: "font-semibold text-success",
135
- children: /* @__PURE__ */ s("span", { children: `-${e(b, L.language)}` })
136
- })]
137
- }) : null,
138
- typeof x == "number" && x > 0 ? /* @__PURE__ */ c("div", {
139
- className: "flex items-center justify-between gap-3 text-sm",
140
- children: [/* @__PURE__ */ s("p", {
141
- className: "text-slate-700",
142
- children: /* @__PURE__ */ s("span", { children: I("checkout_late_return_fee") })
143
- }), /* @__PURE__ */ s("p", {
144
- className: "font-semibold text-slate-950",
145
- children: /* @__PURE__ */ s("span", { children: `+${e(x, L.language)}` })
146
- })]
147
- }) : null,
148
- /* @__PURE__ */ c("div", {
149
- className: "flex items-center justify-between gap-3 text-sm",
150
- children: [/* @__PURE__ */ s("p", {
151
- className: "text-slate-700",
152
- children: /* @__PURE__ */ s("span", { children: I("checkout_estimated_total") })
153
- }), /* @__PURE__ */ s("p", {
154
- className: "font-semibold text-slate-950",
155
- children: /* @__PURE__ */ s("span", { children: e(y ?? v, L.language) })
156
- })]
157
- })
158
- ] }) : null] }),
159
- /* @__PURE__ */ c("div", {
116
+ }) : null),
117
+ /* @__PURE__ */ s("div", {
160
118
  className: "grid gap-2",
161
- children: [D && E ? /* @__PURE__ */ s(l, {
162
- to: E,
163
- className: d(m.length > 0 ? "block" : "hidden"),
164
- children: /* @__PURE__ */ c(n, {
119
+ children: [b && y ? /* @__PURE__ */ o(c, {
120
+ to: y,
121
+ className: u(p.length > 0 ? "block" : "hidden"),
122
+ children: /* @__PURE__ */ s(n, {
165
123
  className: "w-full gap-2",
166
- children: [/* @__PURE__ */ s("span", { children: I("checkout_button") }), /* @__PURE__ */ s(f, {
124
+ children: [/* @__PURE__ */ o("span", { children: k("checkout_button") }), /* @__PURE__ */ o(d, {
167
125
  className: "h-4 w-4",
168
126
  "aria-hidden": "true"
169
127
  })]
170
128
  })
171
- }) : null, O && F ? /* @__PURE__ */ s(n, {
129
+ }) : null, x && O ? /* @__PURE__ */ o(n, {
172
130
  type: "button",
173
131
  variant: "outline",
174
- className: d(m.length > 0 ? "w-full gap-2" : "hidden"),
175
- onClick: F,
176
- children: /* @__PURE__ */ s("span", { children: I("cart_clear") })
132
+ className: u(p.length > 0 ? "w-full gap-2" : "hidden"),
133
+ onClick: O,
134
+ children: /* @__PURE__ */ o("span", { children: k("cart_clear") })
177
135
  }) : null]
178
136
  })
179
137
  ]
@@ -181,4 +139,4 @@ function m({ lines: m, itemCount: h, totalPerBaseUnitMinor: g, baseUnitLabel: _,
181
139
  });
182
140
  }
183
141
  //#endregion
184
- export { m as StorefrontCartPanel };
142
+ export { p as StorefrontCartPanel };
@@ -1,5 +1,6 @@
1
- export type StorefrontI18nLanguage = "en" | "fr";
2
- export declare const normalizeStorefrontI18nLanguage: (language: unknown) => StorefrontI18nLanguage | null;
1
+ import { StorefrontI18nLanguage } from './languages';
2
+ export { normalizeStorefrontI18nLanguage } from './languages';
3
+ export type { StorefrontI18nLanguage } from './languages';
3
4
  export declare const resolveStorefrontI18nRequestLanguage: ({ cookieHeader, acceptLanguageHeader, configuredLanguages, configuredFallbackLanguage, }: {
4
5
  cookieHeader?: unknown;
5
6
  acceptLanguageHeader?: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"I18nProvider.d.ts","sourceRoot":"","sources":["../../src/i18n/I18nProvider.tsx"],"names":[],"mappings":"AAaA,MAAM,MAAM,sBAAsB,GAAG,IAAI,GAAG,IAAI,CAAA;AAShD,eAAO,MAAM,+BAA+B,GAAI,UAAU,OAAO,KAAG,sBAAsB,GAAG,IAI5F,CAAA;AAiED,eAAO,MAAM,oCAAoC,GAAI,0FAKlD;IACD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAA;IAC9C,0BAA0B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3C,KAAG,sBAGmF,CAAA;AA6BvF,eAAO,MAAM,4BAA4B,GACvC,sBAAsB,SAAS,MAAM,EAAE,GAAG,IAAI,EAC9C,6BAA6B,MAAM,GAAG,IAAI,KACzC,sBAUF,CAAA;AAgED,wBAAgB,YAAY,CAAC,EAC3B,eAAe,EACf,mBAAmB,EACnB,0BAA0B,EAC1B,QAAQ,GACT,EAAE;IACD,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAA;IAC9C,0BAA0B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,2CA+BA"}
1
+ {"version":3,"file":"I18nProvider.d.ts","sourceRoot":"","sources":["../../src/i18n/I18nProvider.tsx"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAA;AAC7D,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AA+EzD,eAAO,MAAM,oCAAoC,GAAI,0FAKlD;IACD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAA;IAC9C,0BAA0B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3C,KAAG,sBAGmF,CAAA;AA6BvF,eAAO,MAAM,4BAA4B,GACvC,sBAAsB,SAAS,MAAM,EAAE,GAAG,IAAI,EAC9C,6BAA6B,MAAM,GAAG,IAAI,KACzC,sBAUF,CAAA;AAgED,wBAAgB,YAAY,CAAC,EAC3B,eAAe,EACf,mBAAmB,EACnB,0BAA0B,EAC1B,QAAQ,GACT,EAAE;IACD,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAA;IAC9C,0BAA0B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,2CA+BA"}
@@ -1,101 +1,98 @@
1
- import { storefront as e } from "./en.js";
2
- import { storefront as t } from "./fr.js";
3
- import { useEffect as n, useRef as r, useState as i } from "react";
4
- import { jsx as a } from "react/jsx-runtime";
5
- import { I18nextProvider as o } from "react-i18next";
6
- import { createInstance as s } from "i18next";
1
+ import { STOREFRONT_I18N_LANGUAGE_CODES as e, normalizeStorefrontI18nLanguage as t } from "./languages.js";
2
+ import { storefront as n } from "./en.js";
3
+ import { storefront as r } from "./fr.js";
4
+ import { useEffect as i, useRef as a, useState as o } from "react";
5
+ import { jsx as s } from "react/jsx-runtime";
6
+ import { I18nextProvider as c } from "react-i18next";
7
+ import { createInstance as l } from "i18next";
7
8
  //#region src/i18n/I18nProvider.tsx
8
- var c = "storefront", l = "loczer_storefront_lng", u = "loczer_storefront_lng", d = 3600 * 24 * 365, f = ["en", "fr"], p = "en", m = {
9
- en: { [c]: e },
10
- fr: { [c]: t }
11
- }, h = (e) => {
12
- if (typeof e != "string") return null;
13
- let [t] = e.trim().toLowerCase().split(/[-_]/);
14
- return f.includes(t) ? t : null;
15
- }, g = (e, t) => {
16
- let n = h(t);
17
- if (n) return n;
18
- for (let t of e ?? []) {
19
- let e = h(t);
9
+ var u = "storefront", d = "loczer_storefront_lng", f = "loczer_storefront_lng", p = 3600 * 24 * 365, m = [...e], h = "en", g = {
10
+ en: { [u]: n },
11
+ fr: { [u]: r }
12
+ }, _ = (e, n) => {
13
+ let r = t(n);
14
+ if (r) return r;
15
+ for (let n of e ?? []) {
16
+ let e = t(n);
20
17
  if (e) return e;
21
18
  }
22
- return p;
23
- }, _ = (e) => {
24
- let t = Array.isArray(e) ? e.join(";") : typeof e == "string" ? e : "";
25
- for (let e of t.split(";")) {
26
- let [t, ...n] = e.trim().split("=");
27
- if (t !== u || n.length === 0) continue;
28
- let r = n.join("=");
19
+ return h;
20
+ }, v = (e) => {
21
+ let n = Array.isArray(e) ? e.join(";") : typeof e == "string" ? e : "";
22
+ for (let e of n.split(";")) {
23
+ let [n, ...r] = e.trim().split("=");
24
+ if (n !== f || r.length === 0) continue;
25
+ let i = r.join("=");
29
26
  try {
30
- return h(decodeURIComponent(r));
27
+ return t(decodeURIComponent(i));
31
28
  } catch {
32
- return h(r);
29
+ return t(i);
33
30
  }
34
31
  }
35
32
  return null;
36
- }, v = (e) => (Array.isArray(e) ? e.join(",") : typeof e == "string" ? e : "").split(",").map((e) => {
37
- let [t, ...n] = e.trim().split(";"), r = n.find((e) => e.trim().startsWith("q=")), i = r ? Number(r.trim().slice(2)) : 1;
33
+ }, y = (e) => (Array.isArray(e) ? e.join(",") : typeof e == "string" ? e : "").split(",").map((e) => {
34
+ let [n, ...r] = e.trim().split(";"), i = r.find((e) => e.trim().startsWith("q=")), a = i ? Number(i.trim().slice(2)) : 1;
38
35
  return {
39
- language: h(t),
40
- quality: Number.isFinite(i) ? i : 1
36
+ language: t(n),
37
+ quality: Number.isFinite(a) ? a : 1
41
38
  };
42
- }).filter((e) => !!e.language && e.quality > 0).sort((e, t) => t.quality - e.quality)[0]?.language ?? null, y = ({ cookieHeader: e, acceptLanguageHeader: t, configuredLanguages: n, configuredFallbackLanguage: r }) => _(e) ?? v(t) ?? g(n, r), b = () => {
39
+ }).filter((e) => !!e.language && e.quality > 0).sort((e, t) => t.quality - e.quality)[0]?.language ?? null, b = ({ cookieHeader: e, acceptLanguageHeader: t, configuredLanguages: n, configuredFallbackLanguage: r }) => v(e) ?? y(t) ?? _(n, r), x = () => {
43
40
  if (typeof window > "u") return null;
44
41
  try {
45
- return h(window.localStorage.getItem(l));
42
+ return t(window.localStorage.getItem(d));
46
43
  } catch {
47
44
  return null;
48
45
  }
49
- }, x = () => typeof document > "u" ? null : h(document.documentElement.lang), S = () => {
46
+ }, S = () => typeof document > "u" ? null : t(document.documentElement.lang), C = () => {
50
47
  if (typeof navigator > "u") return null;
51
48
  for (let e of navigator.languages ?? []) {
52
- let t = h(e);
53
- if (t) return t;
49
+ let n = t(e);
50
+ if (n) return n;
54
51
  }
55
- return h(navigator.language);
56
- }, C = (e, t) => typeof window > "u" ? g(e, t) : _(document.cookie) ?? x() ?? b() ?? S() ?? g(e, t), w = (e) => {
52
+ return t(navigator.language);
53
+ }, w = (e, t) => typeof window > "u" ? _(e, t) : v(document.cookie) ?? S() ?? x() ?? C() ?? _(e, t), T = (e) => {
57
54
  if (!(typeof window > "u")) {
58
55
  try {
59
- window.localStorage.setItem(l, e);
56
+ window.localStorage.setItem(d, e);
60
57
  } catch {}
61
- document.cookie = `${u}=${encodeURIComponent(e)}; Path=/; Max-Age=${d}; SameSite=Lax`;
58
+ document.cookie = `${f}=${encodeURIComponent(e)}; Path=/; Max-Age=${p}; SameSite=Lax`;
62
59
  }
63
- }, T = (e, t) => {
64
- let n = s();
60
+ }, E = (e, t) => {
61
+ let n = l();
65
62
  return n.init({
66
- resources: m,
63
+ resources: g,
67
64
  lng: e,
68
65
  fallbackLng: t,
69
- supportedLngs: f,
66
+ supportedLngs: m,
70
67
  nonExplicitSupportedLngs: !0,
71
68
  load: "languageOnly",
72
- ns: [c],
73
- defaultNS: c,
69
+ ns: [u],
70
+ defaultNS: u,
74
71
  interpolation: { escapeValue: !1 },
75
72
  react: { useSuspense: !1 },
76
73
  initAsync: !1
77
74
  }), n;
78
- }, E = null, D = null, O = (e, t) => {
79
- if (E && D === t) return E;
80
- let n = T(e, t);
81
- return n.on("languageChanged", (e) => {
82
- let r = h(e) ?? t;
83
- w(r), r !== e && n.changeLanguage(r);
84
- }), E = n, D = t, n;
75
+ }, D = null, O = null, k = (e, n) => {
76
+ if (D && O === n) return D;
77
+ let r = E(e, n);
78
+ return r.on("languageChanged", (e) => {
79
+ let i = t(e) ?? n;
80
+ T(i), i !== e && r.changeLanguage(i);
81
+ }), D = r, O = n, r;
85
82
  };
86
- function k({ initialLanguage: e, configuredLanguages: t, configuredFallbackLanguage: s, children: l }) {
87
- let u = h(e), d = g(t, s), f = u ?? C(t, d), p = r(u), [m] = i(() => {
88
- if (typeof window > "u") return T(f, d);
89
- let e = O(f, d);
90
- return h(e.language) !== f && e.changeLanguage(f), e;
83
+ function A({ initialLanguage: e, configuredLanguages: n, configuredFallbackLanguage: r, children: l }) {
84
+ let d = t(e), f = _(n, r), p = d ?? w(n, f), m = a(d), [h] = o(() => {
85
+ if (typeof window > "u") return E(p, f);
86
+ let e = k(p, f);
87
+ return t(e.language) !== p && e.changeLanguage(p), e;
91
88
  });
92
- return n(() => {
93
- !u || p.current === u || (p.current = u, h(m.language) !== u && m.changeLanguage(u));
94
- }, [m, u]), /* @__PURE__ */ a(o, {
95
- i18n: m,
96
- defaultNS: c,
89
+ return i(() => {
90
+ !d || m.current === d || (m.current = d, t(h.language) !== d && h.changeLanguage(d));
91
+ }, [h, d]), /* @__PURE__ */ s(c, {
92
+ i18n: h,
93
+ defaultNS: u,
97
94
  children: l
98
95
  });
99
96
  }
100
97
  //#endregion
101
- export { k as I18nProvider, C as detectStorefrontI18nLanguage, h as normalizeStorefrontI18nLanguage, y as resolveStorefrontI18nRequestLanguage };
98
+ export { A as I18nProvider, w as detectStorefrontI18nLanguage, t as normalizeStorefrontI18nLanguage, b as resolveStorefrontI18nRequestLanguage };
package/dist/i18n/en.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare const storefront: {
9
9
  nav_products: string;
10
10
  nav_itineraries: string;
11
11
  nav_contact: string;
12
- language_toggle: string;
12
+ language_selector_label: string;
13
13
  cta_book_now: string;
14
14
  cta_book_short: string;
15
15
  mobile_menu_open: string;
@@ -185,7 +185,7 @@ export declare const storefront: {
185
185
  cart_empty_description: string;
186
186
  cart_line_meta: string;
187
187
  remove_from_cart: string;
188
- cart_total_per_unit: string;
188
+ cart_total: string;
189
189
  cart_clear: string;
190
190
  booking_select_variant_cancel: string;
191
191
  close_modal: string;
package/dist/i18n/en.js CHANGED
@@ -10,7 +10,7 @@ var e = {
10
10
  nav_products: "Bikes",
11
11
  nav_itineraries: "Routes",
12
12
  nav_contact: "Contact",
13
- language_toggle: "FR/EN",
13
+ language_selector_label: "Change language",
14
14
  cta_book_now: "Book now",
15
15
  cta_book_short: "Book",
16
16
  mobile_menu_open: "Open navigation menu",
@@ -186,7 +186,7 @@ var e = {
186
186
  cart_empty_description: "Add a bike (and accessories) to continue.",
187
187
  cart_line_meta: "Qty {{quantity}} · {{price}} / {{unit}}",
188
188
  remove_from_cart: "Remove from cart",
189
- cart_total_per_unit: "Total / {{unit}}",
189
+ cart_total: "Total",
190
190
  cart_clear: "Clear cart",
191
191
  booking_select_variant_cancel: "Cancel",
192
192
  close_modal: "Close",
package/dist/i18n/fr.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare const storefront: {
9
9
  nav_products: string;
10
10
  nav_itineraries: string;
11
11
  nav_contact: string;
12
- language_toggle: string;
12
+ language_selector_label: string;
13
13
  cta_book_now: string;
14
14
  cta_book_short: string;
15
15
  mobile_menu_open: string;
@@ -186,7 +186,7 @@ export declare const storefront: {
186
186
  cart_empty_description: string;
187
187
  cart_line_meta: string;
188
188
  remove_from_cart: string;
189
- cart_total_per_unit: string;
189
+ cart_total: string;
190
190
  cart_clear: string;
191
191
  booking_select_variant_cancel: string;
192
192
  close_modal: string;
package/dist/i18n/fr.js CHANGED
@@ -10,7 +10,7 @@ var e = {
10
10
  nav_products: "Vélos",
11
11
  nav_itineraries: "Itinéraires",
12
12
  nav_contact: "Contact",
13
- language_toggle: "FR/EN",
13
+ language_selector_label: "Changer de langue",
14
14
  cta_book_now: "Réserver",
15
15
  cta_book_short: "Réserver",
16
16
  mobile_menu_open: "Ouvrir le menu de navigation",
@@ -187,7 +187,7 @@ var e = {
187
187
  cart_empty_description: "Ajoutez un vélo (et des accessoires) pour continuer.",
188
188
  cart_line_meta: "Qté {{quantity}} · {{price}} / {{unit}}",
189
189
  remove_from_cart: "Retirer du panier",
190
- cart_total_per_unit: "Total / {{unit}}",
190
+ cart_total: "Total",
191
191
  cart_clear: "Vider le panier",
192
192
  booking_select_variant_cancel: "Annuler",
193
193
  close_modal: "Fermer",
@@ -0,0 +1,15 @@
1
+ export declare const STOREFRONT_I18N_LANGUAGES: readonly [{
2
+ readonly code: "fr";
3
+ readonly name: "Français";
4
+ readonly flag: "🇫🇷";
5
+ }, {
6
+ readonly code: "en";
7
+ readonly name: "English";
8
+ readonly flag: "🇬🇧";
9
+ }];
10
+ export type StorefrontI18nLanguage = (typeof STOREFRONT_I18N_LANGUAGES)[number]["code"];
11
+ export type StorefrontI18nLanguageOption = (typeof STOREFRONT_I18N_LANGUAGES)[number];
12
+ export declare const STOREFRONT_I18N_LANGUAGE_CODES: readonly StorefrontI18nLanguage[];
13
+ export declare const normalizeStorefrontI18nLanguage: (language: unknown) => StorefrontI18nLanguage | null;
14
+ export declare const resolveStorefrontI18nLanguageOptions: (configuredLanguages?: readonly string[] | null) => StorefrontI18nLanguageOption[];
15
+ //# sourceMappingURL=languages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../src/i18n/languages.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB;;;;;;;;EAG5B,CAAA;AAEV,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AACvF,MAAM,MAAM,4BAA4B,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAA;AAErF,eAAO,MAAM,8BAA8B,EAAE,SAAS,sBAAsB,EACzB,CAAA;AAEnD,eAAO,MAAM,+BAA+B,GAAI,UAAU,OAAO,KAAG,sBAAsB,GAAG,IAM5F,CAAA;AAED,eAAO,MAAM,oCAAoC,GAC/C,sBAAsB,SAAS,MAAM,EAAE,GAAG,IAAI,KAC7C,4BAA4B,EAkB9B,CAAA"}
@@ -0,0 +1,26 @@
1
+ //#region src/i18n/languages.ts
2
+ var e = [{
3
+ code: "fr",
4
+ name: "Français",
5
+ flag: "🇫🇷"
6
+ }, {
7
+ code: "en",
8
+ name: "English",
9
+ flag: "🇬🇧"
10
+ }], t = e.map(({ code: e }) => e), n = (e) => {
11
+ if (typeof e != "string") return null;
12
+ let [n] = e.trim().toLowerCase().split(/[-_]/);
13
+ return t.includes(n) ? n : null;
14
+ }, r = (t) => {
15
+ if (!t?.length) return [...e];
16
+ let r = [], i = /* @__PURE__ */ new Set();
17
+ for (let a of t) {
18
+ let t = n(a);
19
+ if (!t || i.has(t)) continue;
20
+ let o = e.find((e) => e.code === t);
21
+ o && (r.push(o), i.add(t));
22
+ }
23
+ return r.length > 0 ? r : [...e];
24
+ };
25
+ //#endregion
26
+ export { e as STOREFRONT_I18N_LANGUAGES, t as STOREFRONT_I18N_LANGUAGE_CODES, n as normalizeStorefrontI18nLanguage, r as resolveStorefrontI18nLanguageOptions };