@seij/common-ui 0.1.4 → 0.1.6

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 CHANGED
@@ -1,58 +1,58 @@
1
1
  import { SeijUIProvider as e } from "./init/SeijUIProvider.js";
2
2
  import { ApplicationShell as p } from "./lib/applicationshell/ApplicationShell.js";
3
3
  import { Badge as m } from "./lib/badge/Badge.js";
4
- import { ButtonBar as n } from "./lib/button_bar/ButtonBar.js";
4
+ import { ButtonBar as x } from "./lib/button_bar/ButtonBar.js";
5
5
  import { Button as i } from "./lib/button/Button.js";
6
- import { CommonUi as b } from "./lib/common-ui.js";
7
- import { obfuscateLabel as I } from "./lib/commons/obfuscatelabel.js";
6
+ import { CommonUi as I } from "./lib/common-ui.js";
7
+ import { obfuscateLabel as u } from "./lib/commons/obfuscatelabel.js";
8
8
  import { DataTable as c, DataTableBody as D, DataTableCaption as L, DataTableCell as s, DataTableHead as d, DataTableHeaderCell as y, DataTableRow as S } from "./lib/data_table/DataTable.js";
9
9
  import { DataTableDynamic as M } from "./lib/datatabledynamic/DataTableDynamic.js";
10
- import { ErrorManager as P, useErrorNotifier as A } from "./lib/error_notifier/ErrorNotifier.js";
11
- import { ErrorBox as F } from "./lib/errorbox/ErrorBox.js";
10
+ import { ErrorManager as N, useErrorNotifier as P } from "./lib/error_notifier/ErrorNotifier.js";
11
+ import { ErrorBox as E } from "./lib/errorbox/ErrorBox.js";
12
12
  import { FormField as C, FormLayout as V, FormLayoutTable as v, FormSectionTitle as h, FormText as R } from "./lib/form_layout/FormLayout.js";
13
- import { I18nService as _, I18nServiceInstance as g } from "./lib/i18n/i18n.service.js";
14
- import { I18nProvider as O, useI18n as Y } from "./lib/i18n/i18n.react.js";
15
- import { InfoBox as W } from "./lib/info_box/InfoBox.js";
16
- import { InlineEdit as q } from "./lib/inlineedit/InlineEdit.js";
17
- import { ListView as G } from "./lib/listview/ListView.js";
18
- import { Loader as K } from "./lib/loader/Loader.js";
19
- import { InputLocalDate as X } from "./lib/localdate/InputLocalDate.js";
20
- import { LabelLocalDate as $ } from "./lib/localdate/LabelLocalDate.js";
21
- import { InputMoneyDec as ro } from "./lib/money/InputMoneyDec.js";
22
- import { InputMoneyInt as to } from "./lib/money/InputMoneyInt.js";
23
- import { LabelMoneyDec as ao } from "./lib/money/LabelMoneyDec.js";
13
+ import { I18nService as _, I18nServiceInstance as g, i18NextInstance as H } from "./lib/i18n/i18n.service.js";
14
+ import { I18nProvider as Y, useI18n as j } from "./lib/i18n/i18n.react.js";
15
+ import { InfoBox as k } from "./lib/info_box/InfoBox.js";
16
+ import { InlineEdit as z } from "./lib/inlineedit/InlineEdit.js";
17
+ import { ListView as J } from "./lib/listview/ListView.js";
18
+ import { Loader as Q } from "./lib/loader/Loader.js";
19
+ import { InputLocalDate as Z } from "./lib/localdate/InputLocalDate.js";
20
+ import { LabelLocalDate as oo } from "./lib/localdate/LabelLocalDate.js";
21
+ import { InputMoneyDec as eo } from "./lib/money/InputMoneyDec.js";
22
+ import { InputMoneyInt as po } from "./lib/money/InputMoneyInt.js";
23
+ import { LabelMoneyDec as mo } from "./lib/money/LabelMoneyDec.js";
24
24
  import { LabelMoneyInt as xo } from "./lib/money/LabelMoneyInt.js";
25
- import { InputDurationMonths as fo } from "./lib/month/InputDurationMonths.js";
26
- import { InputMonth as lo } from "./lib/month/InputMonth.js";
25
+ import { InputDurationMonths as io } from "./lib/month/InputDurationMonths.js";
26
+ import { InputMonth as Io } from "./lib/month/InputMonth.js";
27
27
  import { Navigation as uo } from "./lib/navigation/Navigation.js";
28
- import { INPUT_AMOUNT_ALLOWED_DECIMAL_SEPARATORS as To, InputNumber as co } from "./lib/number/InputNumber.js";
29
- import { InputNumberDec as Lo } from "./lib/number/InputNumberDec.js";
30
- import { InputNumberInt as yo } from "./lib/number/InputNumberInt.js";
31
- import { InputPercent as Bo } from "./lib/percent/InputPercent.js";
32
- import { LabelPercent as wo, LabelRate as Po } from "./lib/percent/LabelPercent.js";
28
+ import { INPUT_AMOUNT_ALLOWED_DECIMAL_SEPARATORS as co, InputNumber as Do } from "./lib/number/InputNumber.js";
29
+ import { InputNumberDec as so } from "./lib/number/InputNumberDec.js";
30
+ import { InputNumberInt as So } from "./lib/number/InputNumberInt.js";
31
+ import { InputPercent as Mo } from "./lib/percent/InputPercent.js";
32
+ import { LabelPercent as No, LabelRate as Po } from "./lib/percent/LabelPercent.js";
33
33
  import { LabelPercentInt as Eo } from "./lib/percent/LabelPercentInt.js";
34
- import { InputCombobox as No } from "./lib/select/InputCombobox.js";
35
- import { InputSelect as Vo } from "./lib/select/InputSelect.js";
36
- import { SwitchButton as ho } from "./lib/switchbutton/SwitchButton.js";
37
- import { Tabs as Uo, TabsList as _o, TabsPanel as go, TabsTab as Ho } from "./lib/tabs/Tabs.js";
38
- import { InputText as Yo } from "./lib/text/InputText.js";
39
- import { Description as Wo } from "./lib/typography/description/Description.js";
40
- import { LabelAndDescription as qo } from "./lib/typography/label_and_description/LabelAndDescription.js";
41
- import { Todo as Go } from "./lib/typography/todo/Todo.js";
42
- import { SectionTitle as Ko } from "./lib/typography/sectiontitle/SectionTitle.js";
43
- import { ViewBody as Xo } from "./lib/view_layout/ViewBody.js";
44
- import { ViewFooter as $o } from "./lib/view_layout/ViewFooter.js";
45
- import { ViewHeader as rr } from "./lib/view_layout/ViewHeader.js";
46
- import { ViewLayout as tr } from "./lib/view_layout/ViewLayout.js";
47
- import { ViewTitle as ar } from "./lib/view_layout/ViewTitle.js";
34
+ import { InputCombobox as Co } from "./lib/select/InputCombobox.js";
35
+ import { InputSelect as vo } from "./lib/select/InputSelect.js";
36
+ import { SwitchButton as Ro } from "./lib/switchbutton/SwitchButton.js";
37
+ import { Tabs as _o, TabsList as go, TabsPanel as Ho, TabsTab as Oo } from "./lib/tabs/Tabs.js";
38
+ import { InputText as jo } from "./lib/text/InputText.js";
39
+ import { Description as ko } from "./lib/typography/description/Description.js";
40
+ import { LabelAndDescription as zo } from "./lib/typography/label_and_description/LabelAndDescription.js";
41
+ import { Todo as Jo } from "./lib/typography/todo/Todo.js";
42
+ import { SectionTitle as Qo } from "./lib/typography/sectiontitle/SectionTitle.js";
43
+ import { ViewBody as Zo } from "./lib/view_layout/ViewBody.js";
44
+ import { ViewFooter as or } from "./lib/view_layout/ViewFooter.js";
45
+ import { ViewHeader as er } from "./lib/view_layout/ViewHeader.js";
46
+ import { ViewLayout as pr } from "./lib/view_layout/ViewLayout.js";
47
+ import { ViewTitle as mr } from "./lib/view_layout/ViewTitle.js";
48
48
  import { InputDurationYears as xr } from "./lib/year/InputDurationYears.js";
49
- import { InputYear as fr } from "./lib/year/InputYear.js";
49
+ import { InputYear as ir } from "./lib/year/InputYear.js";
50
50
  export {
51
51
  p as ApplicationShell,
52
52
  m as Badge,
53
53
  i as Button,
54
- n as ButtonBar,
55
- b as CommonUi,
54
+ x as ButtonBar,
55
+ I as CommonUi,
56
56
  c as DataTable,
57
57
  D as DataTableBody,
58
58
  L as DataTableCaption,
@@ -61,59 +61,60 @@ export {
61
61
  d as DataTableHead,
62
62
  y as DataTableHeaderCell,
63
63
  S as DataTableRow,
64
- Wo as Description,
65
- F as ErrorBox,
66
- P as ErrorManager,
64
+ ko as Description,
65
+ E as ErrorBox,
66
+ N as ErrorManager,
67
67
  C as FormField,
68
68
  V as FormLayout,
69
69
  v as FormLayoutTable,
70
70
  h as FormSectionTitle,
71
71
  R as FormText,
72
- O as I18nProvider,
72
+ Y as I18nProvider,
73
73
  _ as I18nService,
74
74
  g as I18nServiceInstance,
75
- To as INPUT_AMOUNT_ALLOWED_DECIMAL_SEPARATORS,
76
- W as InfoBox,
77
- q as InlineEdit,
78
- No as InputCombobox,
79
- fo as InputDurationMonths,
75
+ co as INPUT_AMOUNT_ALLOWED_DECIMAL_SEPARATORS,
76
+ k as InfoBox,
77
+ z as InlineEdit,
78
+ Co as InputCombobox,
79
+ io as InputDurationMonths,
80
80
  xr as InputDurationYears,
81
- X as InputLocalDate,
82
- ro as InputMoneyDec,
83
- to as InputMoneyInt,
84
- lo as InputMonth,
85
- co as InputNumber,
86
- Lo as InputNumberDec,
87
- yo as InputNumberInt,
88
- Bo as InputPercent,
89
- Vo as InputSelect,
90
- Yo as InputText,
91
- fr as InputYear,
92
- qo as LabelAndDescription,
93
- $ as LabelLocalDate,
94
- ao as LabelMoneyDec,
81
+ Z as InputLocalDate,
82
+ eo as InputMoneyDec,
83
+ po as InputMoneyInt,
84
+ Io as InputMonth,
85
+ Do as InputNumber,
86
+ so as InputNumberDec,
87
+ So as InputNumberInt,
88
+ Mo as InputPercent,
89
+ vo as InputSelect,
90
+ jo as InputText,
91
+ ir as InputYear,
92
+ zo as LabelAndDescription,
93
+ oo as LabelLocalDate,
94
+ mo as LabelMoneyDec,
95
95
  xo as LabelMoneyInt,
96
- wo as LabelPercent,
96
+ No as LabelPercent,
97
97
  Eo as LabelPercentInt,
98
98
  Po as LabelRate,
99
- G as ListView,
100
- K as Loader,
99
+ J as ListView,
100
+ Q as Loader,
101
101
  uo as Navigation,
102
- Ko as SectionTitle,
102
+ Qo as SectionTitle,
103
103
  e as SeijUIProvider,
104
- ho as SwitchButton,
105
- Uo as Tabs,
106
- _o as TabsList,
107
- go as TabsPanel,
108
- Ho as TabsTab,
109
- Go as Todo,
110
- Xo as ViewBody,
111
- $o as ViewFooter,
112
- rr as ViewHeader,
113
- tr as ViewLayout,
114
- ar as ViewTitle,
115
- I as obfuscateLabel,
116
- A as useErrorNotifier,
117
- Y as useI18n
104
+ Ro as SwitchButton,
105
+ _o as Tabs,
106
+ go as TabsList,
107
+ Ho as TabsPanel,
108
+ Oo as TabsTab,
109
+ Jo as Todo,
110
+ Zo as ViewBody,
111
+ or as ViewFooter,
112
+ er as ViewHeader,
113
+ pr as ViewLayout,
114
+ mr as ViewTitle,
115
+ H as i18NextInstance,
116
+ u as obfuscateLabel,
117
+ P as useErrorNotifier,
118
+ j as useI18n
118
119
  };
119
120
  //# sourceMappingURL=index.js.map
@@ -1,15 +1,6 @@
1
1
  import { PropsWithChildren } from 'react';
2
- import { Formats, Messages } from '../lib/i18n';
3
2
  interface SeijUIProviderProps extends PropsWithChildren {
4
- /** SSR hydrate */
5
- initialLocale?: string;
6
- /** SSR hydrate */
7
- initialMessages?: Messages;
8
- /** SSR hydrate */
9
- initialFormats?: Formats;
10
- /** for tests, storybook, preview */
11
- forcedLocale?: string;
12
3
  }
13
- export declare function SeijUIProvider({ children, initialLocale }: SeijUIProviderProps): import("react/jsx-runtime").JSX.Element;
4
+ export declare function SeijUIProvider({ children }: SeijUIProviderProps): import("react/jsx-runtime").JSX.Element;
14
5
  export {};
15
6
  //# sourceMappingURL=SeijUIProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SeijUIProvider.d.ts","sourceRoot":"","sources":["../../src/init/SeijUIProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAahD,UAAU,mBAAoB,SAAQ,iBAAiB;IACrD,kBAAkB;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB;IAClB,eAAe,CAAC,EAAE,QAAQ,CAAC;IAC3B,kBAAkB;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,mBAAmB,2CAS9E"}
1
+ {"version":3,"file":"SeijUIProvider.d.ts","sourceRoot":"","sources":["../../src/init/SeijUIProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAc1C,UAAU,mBAAoB,SAAQ,iBAAiB;CAEtD;AAED,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,mBAAmB,2CAS/D"}
@@ -1,20 +1,20 @@
1
- import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
- import { webLightTheme as i, FluentProvider as n } from "@fluentui/react-components";
3
- import { ErrorManager as s } from "../lib/error_notifier/ErrorNotifier.js";
4
- import { I18nProvider as a } from "../lib/i18n/i18n.react.js";
5
- const m = {
6
- ...i,
1
+ import { jsx as e, jsxs as r } from "react/jsx-runtime";
2
+ import { webLightTheme as t, FluentProvider as i } from "@fluentui/react-components";
3
+ import { ErrorManager as n } from "../lib/error_notifier/ErrorNotifier.js";
4
+ import { I18nProvider as s } from "../lib/i18n/i18n.react.js";
5
+ const a = {
6
+ ...t,
7
7
  fontFamilyBase: "'Noto Sans', 'Segoe UI', 'Segoe UI Web (West European)', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif",
8
8
  fontFamilyMonospace: "Fira Mono, Consolas, 'Courier New', Courier, monospace",
9
9
  fontFamilyNumeric: "Bahnschrift, 'Segoe UI', 'Segoe UI Web (West European)', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif"
10
10
  };
11
- function u({ children: o, initialLocale: r }) {
12
- return /* @__PURE__ */ e(a, { initialLocale: r, children: /* @__PURE__ */ t(n, { theme: m, children: [
11
+ function f({ children: o }) {
12
+ return /* @__PURE__ */ e(s, { children: /* @__PURE__ */ r(i, { theme: a, children: [
13
13
  o,
14
- /* @__PURE__ */ e(s, {})
14
+ /* @__PURE__ */ e(n, {})
15
15
  ] }) });
16
16
  }
17
17
  export {
18
- u as SeijUIProvider
18
+ f as SeijUIProvider
19
19
  };
20
20
  //# sourceMappingURL=SeijUIProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SeijUIProvider.js","sources":["../../src/init/SeijUIProvider.tsx"],"sourcesContent":["import { FluentProvider, Theme, webLightTheme } from \"@fluentui/react-components\";\n\nimport { PropsWithChildren } from \"react\";\nimport { ErrorManager } from \"../lib/error_notifier/ErrorNotifier\";\nimport { Formats, Messages } from \"../lib/i18n\";\nimport { I18nProvider } from \"../lib/i18n/i18n.react\";\n\n// noinspection SpellCheckingInspection\nconst theme: Theme = {\n ...webLightTheme,\n fontFamilyBase:\n \"'Noto Sans', 'Segoe UI', 'Segoe UI Web (West European)', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif\",\n fontFamilyMonospace: \"Fira Mono, Consolas, 'Courier New', Courier, monospace\",\n fontFamilyNumeric:\n \"Bahnschrift, 'Segoe UI', 'Segoe UI Web (West European)', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif\",\n};\n\ninterface SeijUIProviderProps extends PropsWithChildren {\n /** SSR hydrate */\n initialLocale?: string;\n /** SSR hydrate */\n initialMessages?: Messages;\n /** SSR hydrate */\n initialFormats?: Formats;\n /** for tests, storybook, preview */\n forcedLocale?: string;\n}\n\nexport function SeijUIProvider({ children, initialLocale }: SeijUIProviderProps) {\n return (\n <I18nProvider initialLocale={initialLocale}>\n <FluentProvider theme={theme}>\n {children}\n <ErrorManager />\n </FluentProvider>\n </I18nProvider>\n );\n}\n"],"names":["theme","webLightTheme","SeijUIProvider","children","initialLocale","jsx","I18nProvider","jsxs","FluentProvider","ErrorManager"],"mappings":";;;;AAQA,MAAMA,IAAe;AAAA,EACnB,GAAGC;AAAA,EACH,gBACE;AAAA,EACF,qBAAqB;AAAA,EACrB,mBACE;AACJ;AAaO,SAASC,EAAe,EAAE,UAAAC,GAAU,eAAAC,KAAsC;AAC/E,SACE,gBAAAC,EAACC,GAAA,EAAa,eAAAF,GACZ,UAAA,gBAAAG,EAACC,KAAe,OAAAR,GACb,UAAA;AAAA,IAAAG;AAAA,sBACAM,GAAA,CAAA,CAAa;AAAA,EAAA,EAAA,CAChB,EAAA,CACF;AAEJ;"}
1
+ {"version":3,"file":"SeijUIProvider.js","sources":["../../src/init/SeijUIProvider.tsx"],"sourcesContent":["import { FluentProvider, Theme, webLightTheme } from \"@fluentui/react-components\";\n\nimport { PropsWithChildren } from \"react\";\nimport { ErrorManager } from \"../lib/error_notifier/ErrorNotifier\";\nimport { I18nProvider } from \"../lib/i18n/i18n.react\";\n\n// noinspection SpellCheckingInspection\nconst theme: Theme = {\n ...webLightTheme,\n fontFamilyBase:\n \"'Noto Sans', 'Segoe UI', 'Segoe UI Web (West European)', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif\",\n fontFamilyMonospace: \"Fira Mono, Consolas, 'Courier New', Courier, monospace\",\n fontFamilyNumeric:\n \"Bahnschrift, 'Segoe UI', 'Segoe UI Web (West European)', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif\",\n};\n\ninterface SeijUIProviderProps extends PropsWithChildren {\n\n}\n\nexport function SeijUIProvider({ children }: SeijUIProviderProps) {\n return (\n <I18nProvider>\n <FluentProvider theme={theme}>\n {children}\n <ErrorManager />\n </FluentProvider>\n </I18nProvider>\n );\n}\n"],"names":["theme","webLightTheme","SeijUIProvider","children","jsx","I18nProvider","jsxs","FluentProvider","ErrorManager"],"mappings":";;;;AAOA,MAAMA,IAAe;AAAA,EACnB,GAAGC;AAAA,EACH,gBACE;AAAA,EACF,qBAAqB;AAAA,EACrB,mBACE;AACJ;AAMO,SAASC,EAAe,EAAE,UAAAC,KAAiC;AAChE,SACE,gBAAAC,EAACC,GAAA,EACC,UAAA,gBAAAC,EAACC,GAAA,EAAe,OAAAP,GACb,UAAA;AAAA,IAAAG;AAAA,sBACAK,GAAA,CAAA,CAAa;AAAA,EAAA,EAAA,CAChB,EAAA,CACF;AAEJ;"}
@@ -2,9 +2,7 @@ import { default as React } from 'react';
2
2
  import { I18n } from './i18n.types';
3
3
  export interface I18nProviderProps {
4
4
  children: React.ReactNode;
5
- /** SSR hydrate */
6
- initialLocale?: string;
7
5
  }
8
- export declare function I18nProvider({ children, initialLocale }: I18nProviderProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function I18nProvider({ children }: I18nProviderProps): import("react/jsx-runtime").JSX.Element | null;
9
7
  export declare function useI18n(): I18n;
10
8
  //# sourceMappingURL=i18n.react.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.react.d.ts","sourceRoot":"","sources":["../../../src/lib/i18n/i18n.react.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAG5E,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAQpC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,kBAAkB;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,iBAAiB,2CAwB1E;AAED,wBAAgB,OAAO,IAAI,IAAI,CAI9B"}
1
+ {"version":3,"file":"i18n.react.d.ts","sourceRoot":"","sources":["../../../src/lib/i18n/i18n.react.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkE,MAAM,OAAO,CAAC;AAEvF,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAQpC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,kDAsB3D;AAED,wBAAgB,OAAO,IAAI,IAAI,CAI9B"}
@@ -1,35 +1,28 @@
1
1
  import { jsx as u } from "react/jsx-runtime";
2
- import i from "i18next";
3
- import { createContext as g, useContext as f, useState as v, useMemo as s } from "react";
4
- import { normalize as I, detectClientLocale as d } from "./i18n.detect.js";
2
+ import { createContext as a, useContext as f, useState as r, useMemo as m, useEffect as v } from "react";
5
3
  import { I18nServiceInstance as n } from "./i18n.service.js";
6
- const a = g({ i18nService: n, lastChange: 0 });
7
- function S({ children: e, initialLocale: t }) {
8
- const [r, c] = v(0);
9
- s(() => {
10
- const o = I(t || d());
11
- o !== i.language && n.readyPromise.then(() => {
12
- i.changeLanguage(o, () => {
13
- c((/* @__PURE__ */ new Date()).getTime());
14
- });
15
- });
16
- }, [t]);
17
- const m = s(
4
+ const s = a({ i18nService: n, lastChange: 0 });
5
+ function x({ children: e }) {
6
+ const [t, I] = r(0), [o, i] = r(!1), c = m(
18
7
  () => ({
19
8
  i18nService: n,
20
- lastChange: r
9
+ lastChange: t
21
10
  }),
22
- [r]
11
+ [t]
23
12
  );
24
- return /* @__PURE__ */ u(a.Provider, { value: m, children: e });
13
+ return v(() => {
14
+ n.readyPromise.then(() => {
15
+ i(!0);
16
+ });
17
+ }, []), o ? /* @__PURE__ */ u(s.Provider, { value: c, children: e }) : null;
25
18
  }
26
- function w() {
27
- const e = f(a);
19
+ function C() {
20
+ const e = f(s);
28
21
  if (!e) throw new Error("useI18n must be used within I18nProvider");
29
22
  return e.i18nService;
30
23
  }
31
24
  export {
32
- S as I18nProvider,
33
- w as useI18n
25
+ x as I18nProvider,
26
+ C as useI18n
34
27
  };
35
28
  //# sourceMappingURL=i18n.react.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.react.js","sources":["../../../src/lib/i18n/i18n.react.tsx"],"sourcesContent":["// i18n/I18nProvider.tsx\nimport i18next from \"i18next\";\nimport React, { createContext, useContext, useMemo, useState } from \"react\";\nimport { detectClientLocale, normalize } from \"./i18n.detect\";\nimport { I18nService, I18nServiceInstance } from \"./i18n.service\";\nimport { I18n } from \"./i18n.types\";\n\ntype I18nCtxType = {\n i18nService: I18nService;\n lastChange: number;\n};\nconst I18nCtx = createContext<I18nCtxType>({ i18nService: I18nServiceInstance, lastChange: 0 });\n\nexport interface I18nProviderProps {\n children: React.ReactNode;\n /** SSR hydrate */\n initialLocale?: string;\n}\n\nexport function I18nProvider({ children, initialLocale }: I18nProviderProps) {\n // Detects the locale: first used the forced one, then initial, then use autodetection\n\n const [instanceTs, setInstanceTs] = useState(0);\n useMemo(() => {\n const language = normalize(initialLocale || detectClientLocale());\n if (language !== i18next.language) {\n I18nServiceInstance.readyPromise.then(() => {\n i18next.changeLanguage(language, () => {\n setInstanceTs(new Date().getTime());\n });\n });\n }\n }, [initialLocale]);\n\n const value: I18nCtxType = useMemo(\n () => ({\n i18nService: I18nServiceInstance,\n lastChange: instanceTs,\n }),\n [instanceTs],\n );\n\n return <I18nCtx.Provider value={value}>{children}</I18nCtx.Provider>;\n}\n\nexport function useI18n(): I18n {\n const v = useContext(I18nCtx);\n if (!v) throw new Error(\"useI18n must be used within I18nProvider\");\n return v.i18nService;\n}\n"],"names":["I18nCtx","createContext","I18nServiceInstance","I18nProvider","children","initialLocale","instanceTs","setInstanceTs","useState","useMemo","language","normalize","detectClientLocale","i18next","value","jsx","useI18n","v","useContext"],"mappings":";;;;;AAWA,MAAMA,IAAUC,EAA2B,EAAE,aAAaC,GAAqB,YAAY,GAAG;AAQvF,SAASC,EAAa,EAAE,UAAAC,GAAU,eAAAC,KAAoC;AAG3E,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAS,CAAC;AAC9C,EAAAC,EAAQ,MAAM;AACZ,UAAMC,IAAWC,EAAUN,KAAiBO,EAAA,CAAoB;AAChE,IAAIF,MAAaG,EAAQ,YACvBX,EAAoB,aAAa,KAAK,MAAM;AAC1C,MAAAW,EAAQ,eAAeH,GAAU,MAAM;AACrC,QAAAH,GAAc,oBAAI,KAAA,GAAO,QAAA,CAAS;AAAA,MACpC,CAAC;AAAA,IACH,CAAC;AAAA,EAEL,GAAG,CAACF,CAAa,CAAC;AAElB,QAAMS,IAAqBL;AAAA,IACzB,OAAO;AAAA,MACL,aAAaP;AAAA,MACb,YAAYI;AAAA,IAAA;AAAA,IAEd,CAACA,CAAU;AAAA,EAAA;AAGb,SAAO,gBAAAS,EAACf,EAAQ,UAAR,EAAiB,OAAAc,GAAe,UAAAV,EAAA,CAAS;AACnD;AAEO,SAASY,IAAgB;AAC9B,QAAMC,IAAIC,EAAWlB,CAAO;AAC5B,MAAI,CAACiB,EAAG,OAAM,IAAI,MAAM,0CAA0C;AAClE,SAAOA,EAAE;AACX;"}
1
+ {"version":3,"file":"i18n.react.js","sources":["../../../src/lib/i18n/i18n.react.tsx"],"sourcesContent":["// i18n/I18nProvider.tsx\nimport React, { createContext, useContext, useEffect, useMemo, useState } from \"react\";\nimport { i18NextInstance, I18nService, I18nServiceInstance } from \"./i18n.service\";\nimport { I18n } from \"./i18n.types\";\n\ntype I18nCtxType = {\n i18nService: I18nService;\n lastChange: number;\n};\nconst I18nCtx = createContext<I18nCtxType>({ i18nService: I18nServiceInstance, lastChange: 0 });\n\nexport interface I18nProviderProps {\n children: React.ReactNode;\n}\n\nexport function I18nProvider({ children }: I18nProviderProps) {\n // Detects the locale: first used the forced one, then initial, then use autodetection\n\n const [instanceTs, setInstanceTs] = useState(0);\n const [ready, setReady] = useState<boolean>(false)\n const value: I18nCtxType = useMemo(\n () => ({\n i18nService: I18nServiceInstance,\n lastChange: instanceTs,\n }),\n [instanceTs],\n );\n\n useEffect(() => {\n I18nServiceInstance.readyPromise.then(()=>{\n setReady(true)\n })\n }, [])\n\n if (!ready) return null\n\n return <I18nCtx.Provider value={value}>{children}</I18nCtx.Provider>;\n}\n\nexport function useI18n(): I18n {\n const v = useContext(I18nCtx);\n if (!v) throw new Error(\"useI18n must be used within I18nProvider\");\n return v.i18nService;\n}\n"],"names":["I18nCtx","createContext","I18nServiceInstance","I18nProvider","children","instanceTs","setInstanceTs","useState","ready","setReady","value","useMemo","useEffect","jsx","useI18n","v","useContext"],"mappings":";;;AASA,MAAMA,IAAUC,EAA2B,EAAE,aAAaC,GAAqB,YAAY,GAAG;AAMvF,SAASC,EAAa,EAAE,UAAAC,KAA+B;AAG5D,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAS,CAAC,GACxC,CAACC,GAAOC,CAAQ,IAAIF,EAAkB,EAAK,GAC3CG,IAAqBC;AAAA,IACzB,OAAO;AAAA,MACL,aAAaT;AAAA,MACb,YAAYG;AAAA,IAAA;AAAA,IAEd,CAACA,CAAU;AAAA,EAAA;AASb,SANAO,EAAU,MAAM;AACd,IAAAV,EAAoB,aAAa,KAAK,MAAI;AACxC,MAAAO,EAAS,EAAI;AAAA,IACf,CAAC;AAAA,EACH,GAAG,CAAA,CAAE,GAEAD,IAEE,gBAAAK,EAACb,EAAQ,UAAR,EAAiB,OAAAU,GAAe,UAAAN,EAAA,CAAS,IAF9B;AAGrB;AAEO,SAASU,IAAgB;AAC9B,QAAMC,IAAIC,EAAWhB,CAAO;AAC5B,MAAI,CAACe,EAAG,OAAM,IAAI,MAAM,0CAA0C;AAClE,SAAOA,EAAE;AACX;"}
@@ -1,4 +1,6 @@
1
+ import { i18n } from 'i18next';
1
2
  import { I18n } from './i18n.types';
3
+ export declare const i18NextInstance: i18n;
2
4
  export declare class I18nService implements I18n {
3
5
  readyPromise: Promise<import('i18next').TFunction<"translation", undefined>>;
4
6
  getLocale: () => string;
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.service.d.ts","sourceRoot":"","sources":["../../../src/lib/i18n/i18n.service.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAUpC,qBAAa,WAAY,YAAW,IAAI;IACtC,YAAY,iEAA8B;IAE1C,SAAS,QAAO,MAAM,CAEpB;IAEF,IAAI,GAAI,IAAI,MAAM,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC,KAAG,KAAK,CAAC,SAAS,CAE5G;IAEF,CAAC,GAAI,IAAI,MAAM,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,MAAM,CAExD;IAEF,OAAO,uCAEL;IAEF,QAAQ,eAEN;IAEF,GAAG,GAAI,QAAQ,MAAM,yBAEnB;IAEF,EAAE,GAAI,QAAQ,MAAM,uBAEnB;IAED,EAAE,GAAI,QAAQ,MAAM,qBAKnB;IAED,GAAG,gCAEF;IAED,UAAU,GAAI,GAAG,IAAI,GAAG,MAAM,EAAE,QAA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AAQ,MAAM,yBAEnB;IAEF,EAAE,GAAI,QAAQ,MAAM,uBAElB;IAEF,EAAE,GAAI,QAAQ,MAAM,qBAKlB;IAEF,GAAG,gCAED;IAEF,UAAU,GAAI,GAAG,IAAI,GAAG,MAAM,EAAE,QAAQ,MAAM,KAAG,MAAM,CAErD;IAEF,YAAY,GAAI,GAAG,MAAM,EAAE,QAAQ,MAAM,KAAG,MAAM,CAEhD;IAEF,UAAU,GAAI,OAAO,MAAM,EAAE,EAAE,QAAQ,MAAM,KAAG,MAAM,CAEpD;IAEF,cAAc,GAAI,GAAG,IAAI,GAAG,MAAM,KAAG,MAAM,CA4BzC;IAEF,oBAAoB,QAAO,MAAM,CAE/B;IAEF,kBAAkB,QAAO,MAAM,CAE7B;IAEF,uBAAuB,GAAI,KAAK,MAAM,KAAG,MAAM,CAU7C;IAEF,4BAA4B,GAAI,KAAK,MAAM,KAAG,MAAM,CAclD;IAEF,SAAS;cAWqC,MAAM;eAAS,MAAM;QATjE;IAEF,iBAAiB,GAAI,KAAK,MAAM,EAAE,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,IAAI,CAIrE;CACH;AAQD,eAAO,MAAM,mBAAmB,aAAoB,CAAC"}
@@ -1,20 +1,28 @@
1
- import { parse as f, isDate as s, isValid as i, formatISO as c, format as h } from "date-fns";
2
- import d from "i18next";
3
- import g from "i18next-icu";
4
- import m from "../../locales/fr.js";
5
- import u from "../../locales/en.js";
1
+ import { parse as c, isDate as s, isValid as i, formatISO as f, format as g } from "date-fns";
2
+ import h from "i18next";
3
+ import d from "i18next-icu";
6
4
  import { isString as p } from "lodash-es";
7
- const n = d.createInstance(), I = n.use(g).init({
5
+ import l from "../../locales/en.js";
6
+ import m from "../../locales/fr.js";
7
+ import I from "i18next-browser-languagedetector";
8
+ const n = h.createInstance(), D = n.use(d).use(I).init({
8
9
  debug: !0,
9
- resources: { fr: { translation: m.messages }, en: { translation: u.messages } },
10
- interpolation: { escapeValue: !1 }
10
+ fallbackLng: "en",
11
+ resources: { fr: { translation: m.messages }, en: { translation: l.messages } },
12
+ interpolation: { escapeValue: !1 },
13
+ detection: {
14
+ order: ["querystring", "localStorage", "navigator"],
15
+ lookupQuerystring: "lng",
16
+ lookupLocalStorage: "lng",
17
+ caches: ["localStorage"]
18
+ }
11
19
  });
12
- class D {
13
- readyPromise = I;
20
+ class M {
21
+ readyPromise = D;
14
22
  getLocale = () => n.language;
15
23
  rich = (t, e) => n.t(t, e);
16
24
  t = (t, e) => n.t(t, e);
17
- formats = () => n.language === "fr" ? m.formats : u.formats;
25
+ formats = () => n.language === "fr" ? m.formats : l.formats;
18
26
  language = () => n.language;
19
27
  dtf = (t) => new Intl.DateTimeFormat(this.language(), t && this.formats().date[t] || void 0);
20
28
  nf = (t) => new Intl.NumberFormat(this.language(), t && this.formats().number[t] || void 0);
@@ -27,43 +35,44 @@ class D {
27
35
  formatNumber = (t, e) => this.nf(e).format(t);
28
36
  formatList = (t, e) => this.lf(e).format(t);
29
37
  formatRelative = (t) => {
30
- const e = (Number(t) - Date.now()) / 1e3, a = Math.abs(e), r = a < 60 ? "second" : a < 3600 ? "minute" : a < 86400 ? "hour" : a < 2592e3 ? "day" : a < 31536e3 ? "month" : "year", l = Math.round(r === "second" ? e : r === "minute" ? e / 60 : r === "hour" ? e / 3600 : r === "day" ? e / 86400 : r === "month" ? e / 2592e3 : e / 31536e3);
31
- return this.rtf().format(l, r);
38
+ const e = (Number(t) - Date.now()) / 1e3, a = Math.abs(e), r = a < 60 ? "second" : a < 3600 ? "minute" : a < 86400 ? "hour" : a < 2592e3 ? "day" : a < 31536e3 ? "month" : "year", u = Math.round(r === "second" ? e : r === "minute" ? e / 60 : r === "hour" ? e / 3600 : r === "day" ? e / 86400 : r === "month" ? e / 2592e3 : e / 31536e3);
39
+ return this.rtf().format(u, r);
32
40
  };
33
41
  localDatePlaceholder = () => this.formats().localdate.placeholder;
34
42
  localDateInputMask = () => this.formats().localdate.inputmask;
35
43
  localDateFormattedToISO = (t) => {
36
- const e = this.formats().localdate.inputmask, a = f(
44
+ const e = this.formats().localdate.inputmask, a = c(
37
45
  t,
38
46
  e,
39
47
  /* @__PURE__ */ new Date()
40
48
  // { locale: fr }
41
49
  );
42
- return !s(a) || !i(a) ? "" : c(a, { representation: "date" });
50
+ return !s(a) || !i(a) ? "" : f(a, { representation: "date" });
43
51
  };
44
52
  localDateISOToFormattedInput = (t) => {
45
53
  const e = this.formats().localdate.inputmask;
46
54
  let a;
47
55
  if (p(t)) {
48
56
  const r = new Date(t);
49
- s(r) && i(r) ? a = h(r, e) : a = "";
57
+ s(r) && i(r) ? a = g(r, e) : a = "";
50
58
  } else
51
59
  a = "";
52
60
  return a;
53
61
  };
54
- monthList = () => M(this.language());
62
+ monthList = () => b(this.language());
55
63
  registerNamespace = (t, e) => {
56
64
  for (const a of Object.keys(e))
57
65
  n.addResources(a, t, e[a]);
58
66
  };
59
67
  }
60
- function M(o) {
68
+ function b(o) {
61
69
  const t = new Intl.DateTimeFormat(o, { month: "long" });
62
70
  return Array.from({ length: 12 }, (a, r) => t.format(new Date(2e3, r, 1))).map((a, r) => ({ code: r + 1, label: a }));
63
71
  }
64
- const S = new D();
72
+ const N = new M();
65
73
  export {
66
- D as I18nService,
67
- S as I18nServiceInstance
74
+ M as I18nService,
75
+ N as I18nServiceInstance,
76
+ n as i18NextInstance
68
77
  };
69
78
  //# sourceMappingURL=i18n.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.service.js","sources":["../../../src/lib/i18n/i18n.service.ts"],"sourcesContent":["import { format, formatISO, isDate, isValid, parse } from \"date-fns\";\nimport i18next from \"i18next\";\nimport ICU from \"i18next-icu\";\n\nimport fr from \"../../locales/fr\";\nimport en from \"../../locales/en\";\nimport { I18n } from \"./i18n.types\";\nimport { isString } from \"lodash-es\";\n\nconst i18NextInstance = i18next.createInstance();\nconst i18NextinstanceInitPromise = i18NextInstance.use(ICU).init({\n debug: true,\n resources: { fr: { translation: fr.messages }, en: { translation: en.messages } },\n interpolation: { escapeValue: false },\n});\n\nexport class I18nService implements I18n {\n readyPromise = i18NextinstanceInitPromise;\n\n getLocale = (): string => {\n return i18NextInstance.language;\n };\n\n rich = (id: string, values?: Record<string, unknown | ((chunks: string) => React.ReactNode)>): React.ReactNode => {\n return i18NextInstance.t(id, values);\n };\n\n t = (id: string, values?: Record<string, unknown>): string => {\n return i18NextInstance.t(id, values);\n };\n\n formats = () => {\n return i18NextInstance.language === \"fr\" ? fr.formats : en.formats;\n };\n\n language = () => {\n return i18NextInstance.language;\n };\n\n dtf = (style?: string) => {\n return new Intl.DateTimeFormat(this.language(), (style && this.formats().date[style]) || undefined);\n };\n\n nf = (style?: string) => {\n return new Intl.NumberFormat(this.language(), (style && this.formats().number[style]) || undefined);\n }\n\n lf = (style?: string) => {\n return new Intl.ListFormat(\n this.language(),\n (style && this.formats().list[style]) || { type: \"conjunction\", style: \"long\" },\n );\n }\n\n rtf = () => {\n return new Intl.RelativeTimeFormat(this.language(), { numeric: \"auto\" });\n }\n\n formatDate = (d: Date | number, style?: string): string => {\n return this.dtf(style).format(d);\n }\n\n formatNumber =(n: number, style?: string): string => {\n return this.nf(style).format(n);\n }\n\n formatList = (items: string[], style?: string): string => {\n return this.lf(style).format(items);\n }\n\n formatRelative = (d: Date | number): string => {\n const diff = (Number(d) - Date.now()) / 1000;\n const abs = Math.abs(diff);\n const unit =\n abs < 60\n ? \"second\"\n : abs < 3600\n ? \"minute\"\n : abs < 86400\n ? \"hour\"\n : abs < 2592000\n ? \"day\"\n : abs < 31536000\n ? \"month\"\n : \"year\";\n const value =\n unit === \"second\"\n ? Math.round(diff)\n : unit === \"minute\"\n ? Math.round(diff / 60)\n : unit === \"hour\"\n ? Math.round(diff / 3600)\n : unit === \"day\"\n ? Math.round(diff / 86400)\n : unit === \"month\"\n ? Math.round(diff / 2592000)\n : Math.round(diff / 31536000);\n return this.rtf().format(value, unit as Intl.RelativeTimeFormatUnit);\n }\n\n localDatePlaceholder = (): string => {\n return this.formats().localdate.placeholder;\n }\n\n localDateInputMask = (): string => {\n return this.formats().localdate.inputmask;\n }\n\n localDateFormattedToISO = (str: string): string => {\n const inputMask = this.formats().localdate.inputmask;\n const parsed = parse(\n str,\n inputMask,\n new Date(),\n // { locale: fr }\n );\n if (!isDate(parsed) || !isValid(parsed)) return \"\";\n return formatISO(parsed, { representation: \"date\" });\n }\n\n localDateISOToFormattedInput = (str: string): string => {\n const inputMask = this.formats().localdate.inputmask;\n let result;\n if (isString(str)) {\n const date = new Date(str);\n if (isDate(date) && isValid(date)) {\n result = format(date, inputMask);\n } else {\n result = \"\";\n }\n } else {\n result = \"\";\n }\n return result;\n }\n\n monthList = () => {\n return getMonthNames(this.language());\n }\n\n registerNamespace = (key: string, resources: Record<string, any>): void => {\n for (const lang of Object.keys(resources)) {\n i18NextInstance.addResources(lang, key, resources[lang])\n }\n }\n}\n\nfunction getMonthNames(locale: string): { code: number; label: string }[] {\n const formatter = new Intl.DateTimeFormat(locale, { month: \"long\" });\n const months = Array.from({ length: 12 }, (_, i) => formatter.format(new Date(2000, i, 1)));\n return months.map((i, index) => ({ code: index + 1, label: i }));\n}\n\nexport const I18nServiceInstance = new I18nService();\n"],"names":["i18NextInstance","i18next","i18NextinstanceInitPromise","ICU","fr","en","I18nService","id","values","style","d","n","items","diff","abs","unit","value","str","inputMask","parsed","parse","isDate","isValid","formatISO","result","isString","date","format","getMonthNames","key","resources","lang","locale","formatter","_","i","index","I18nServiceInstance"],"mappings":";;;;;;AASA,MAAMA,IAAkBC,EAAQ,eAAA,GAC1BC,IAA6BF,EAAgB,IAAIG,CAAG,EAAE,KAAK;AAAA,EAC/D,OAAO;AAAA,EACP,WAAW,EAAE,IAAI,EAAE,aAAaC,EAAG,YAAY,IAAI,EAAE,aAAaC,EAAG,WAAS;AAAA,EAC9E,eAAe,EAAE,aAAa,GAAA;AAChC,CAAC;AAEM,MAAMC,EAA4B;AAAA,EACvC,eAAeJ;AAAA,EAEf,YAAY,MACH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AAC,CAAC,EAC5E,IAAI,CAACA,GAAGC,OAAW,EAAE,MAAMA,IAAQ,GAAG,OAAOD,EAAA,EAAI;AACjE;AAEO,MAAME,IAAsB,IAAI/B,EAAA;"}
1
+ {"version":3,"file":"i18n.service.js","sources":["../../../src/lib/i18n/i18n.service.ts"],"sourcesContent":["import { format, formatISO, isDate, isValid, parse } from \"date-fns\";\nimport i18next from \"i18next\";\nimport type { i18n } from \"i18next\";\nimport ICU from \"i18next-icu\";\nimport { isString } from \"lodash-es\";\nimport en from \"../../locales/en\";\nimport fr from \"../../locales/fr\";\nimport { I18n } from \"./i18n.types\";\nimport LanguageDetector from \"i18next-browser-languagedetector\";\n\nexport const i18NextInstance: i18n = i18next.createInstance();\nconst i18NextinstanceInitPromise = i18NextInstance\n .use(ICU)\n .use(LanguageDetector)\n .init({\n debug: true,\n fallbackLng: \"en\",\n resources: { fr: { translation: fr.messages }, en: { translation: en.messages } },\n interpolation: { escapeValue: false },\n detection: {\n order: [\"querystring\", \"localStorage\", \"navigator\"],\n lookupQuerystring: \"lng\",\n lookupLocalStorage: \"lng\",\n caches: [\"localStorage\"],\n },\n });\n\nexport class I18nService implements I18n {\n readyPromise = i18NextinstanceInitPromise;\n\n getLocale = (): string => {\n return i18NextInstance.language;\n };\n\n rich = (id: string, values?: Record<string, unknown | ((chunks: string) => React.ReactNode)>): React.ReactNode => {\n return i18NextInstance.t(id, values);\n };\n\n t = (id: string, values?: Record<string, unknown>): string => {\n return i18NextInstance.t(id, values);\n };\n\n formats = () => {\n return i18NextInstance.language === \"fr\" ? fr.formats : en.formats;\n };\n\n language = () => {\n return i18NextInstance.language;\n };\n\n dtf = (style?: string) => {\n return new Intl.DateTimeFormat(this.language(), (style && this.formats().date[style]) || undefined);\n };\n\n nf = (style?: string) => {\n return new Intl.NumberFormat(this.language(), (style && this.formats().number[style]) || undefined);\n };\n\n lf = (style?: string) => {\n return new Intl.ListFormat(\n this.language(),\n (style && this.formats().list[style]) || { type: \"conjunction\", style: \"long\" },\n );\n };\n\n rtf = () => {\n return new Intl.RelativeTimeFormat(this.language(), { numeric: \"auto\" });\n };\n\n formatDate = (d: Date | number, style?: string): string => {\n return this.dtf(style).format(d);\n };\n\n formatNumber = (n: number, style?: string): string => {\n return this.nf(style).format(n);\n };\n\n formatList = (items: string[], style?: string): string => {\n return this.lf(style).format(items);\n };\n\n formatRelative = (d: Date | number): string => {\n const diff = (Number(d) - Date.now()) / 1000;\n const abs = Math.abs(diff);\n const unit =\n abs < 60\n ? \"second\"\n : abs < 3600\n ? \"minute\"\n : abs < 86400\n ? \"hour\"\n : abs < 2592000\n ? \"day\"\n : abs < 31536000\n ? \"month\"\n : \"year\";\n const value =\n unit === \"second\"\n ? Math.round(diff)\n : unit === \"minute\"\n ? Math.round(diff / 60)\n : unit === \"hour\"\n ? Math.round(diff / 3600)\n : unit === \"day\"\n ? Math.round(diff / 86400)\n : unit === \"month\"\n ? Math.round(diff / 2592000)\n : Math.round(diff / 31536000);\n return this.rtf().format(value, unit as Intl.RelativeTimeFormatUnit);\n };\n\n localDatePlaceholder = (): string => {\n return this.formats().localdate.placeholder;\n };\n\n localDateInputMask = (): string => {\n return this.formats().localdate.inputmask;\n };\n\n localDateFormattedToISO = (str: string): string => {\n const inputMask = this.formats().localdate.inputmask;\n const parsed = parse(\n str,\n inputMask,\n new Date(),\n // { locale: fr }\n );\n if (!isDate(parsed) || !isValid(parsed)) return \"\";\n return formatISO(parsed, { representation: \"date\" });\n };\n\n localDateISOToFormattedInput = (str: string): string => {\n const inputMask = this.formats().localdate.inputmask;\n let result;\n if (isString(str)) {\n const date = new Date(str);\n if (isDate(date) && isValid(date)) {\n result = format(date, inputMask);\n } else {\n result = \"\";\n }\n } else {\n result = \"\";\n }\n return result;\n };\n\n monthList = () => {\n return getMonthNames(this.language());\n };\n\n registerNamespace = (key: string, resources: Record<string, any>): void => {\n for (const lang of Object.keys(resources)) {\n i18NextInstance.addResources(lang, key, resources[lang]);\n }\n };\n}\n\nfunction getMonthNames(locale: string): { code: number; label: string }[] {\n const formatter = new Intl.DateTimeFormat(locale, { month: \"long\" });\n const months = Array.from({ length: 12 }, (_, i) => formatter.format(new Date(2000, i, 1)));\n return months.map((i, index) => ({ code: index + 1, label: i }));\n}\n\nexport const I18nServiceInstance = new I18nService();\n"],"names":["i18NextInstance","i18next","i18NextinstanceInitPromise","ICU","LanguageDetector","fr","en","I18nService","id","values","style","d","n","items","diff","abs","unit","value","str","inputMask","parsed","parse","isDate","isValid","formatISO","result","isString","date","format","getMonthNames","key","resources","lang","locale","formatter","_","i","index","I18nServiceInstance"],"mappings":";;;;;;;AAUO,MAAMA,IAAwBC,EAAQ,eAAA,GACvCC,IAA6BF,EAChC,IAAIG,CAAG,EACP,IAAIC,CAAgB,EACpB,KAAK;AAAA,EACJ,OAAO;AAAA,EACP,aAAa;AAAA,EACb,WAAW,EAAE,IAAI,EAAE,aAAaC,EAAG,YAAY,IAAI,EAAE,aAAaC,EAAG,WAAS;AAAA,EAC9E,eAAe,EAAE,aAAa,GAAA;AAAA,EAC9B,WAAW;AAAA,IACT,OAAO,CAAC,eAAe,gBAAgB,WAAW;AAAA,IAClD,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,IACpB,QAAQ,CAAC,cAAc;AAAA,EAAA;AAE3B,CAAC;AAEI,MAAMC,EAA4B;AAAA,EACvC,eAAeL;AAAA,EAEf,YAAY,MACHF,EAAgB;AAAA,EAGzB,OAAO,CAACQ,GAAYC,MACXT,EAAgB,EAAEQ,GAAIC,CAAM;AAAA,EAGrC,IAAI,CAACD,GAAYC,MACRT,EAAgB,EAAEQ,GAAIC,CAAM;AAAA,EAGrC,UAAU,MACDT,EAAgB,aAAa,OAAOK,EAAG,UAAUC,EAAG;AAAA,EAG7D,WAAW,MACFN,EAAgB;AAAA,EAGzB,MAAM,CAACU,MACE,IAAI,KAAK,eAAe,KAAK,SAAA,GAAaA,KAAS,KAAK,QAAA,EAAU,KAAKA,CAAK,KAAM,MAAS;AAAA,EAGpG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AAA;AAAA;AAAA,IAAK;AAGX,WAAI,CAACG,EAAOF,CAAM,KAAK,CAACG,EAAQH,CAAM,IAAU,KACzCI,EAAUJ,GAAQ,EAAE,gBAAgB,QAAQ;AAAA,EACrD;AAAA,EAEA,+BAA+B,CAACF,MAAwB;AACtD,UAAMC,IAAY,KAAK,QAAA,EAAU,UAAU;AAC3C,QAAIM;AACJ,QAAIC,EAASR,CAAG,GAAG;AACjB,YAAMS,IAAO,IAAI,KAAKT,CAAG;AACzB,MAAII,EAAOK,CAAI,KAAKJ,EAAQI,CAAI,IAC9BF,IAASG,EAAOD,GAAMR,CAAS,IAE/BM,IAAS;AAAA,IAEb;AACE,MAAAA,IAAS;AAEX,WAAOA;AAAA,EACT;AAAA,EAEA,YAAY,MACHI,EAAc,KAAK,UAAU;AAAA,EAGtC,oBAAoB,CAACC,GAAaC,MAAyC;AACzE,eAAWC,KAAQ,OAAO,KAAKD,CAAS;AACtC,MAAA/B,EAAgB,aAAagC,GAAMF,GAAKC,EAAUC,CAAI,CAAC;AAAA,EAE3D;AACF;AAEA,SAASH,EAAcI,GAAmD;AACxE,QAAMC,IAAY,IAAI,KAAK,eAAeD,GAAQ,EAAE,OAAO,QAAQ;AAEnE,SADe,MAAM,KAAK,EAAE,QAAQ,GAAA,GAAM,CAACE,GAAGC,MAAMF,EAAU,OAAO,IAAI,KAAK,KAAME,GAAG,CAAC,CAAC,CAAC,EAC5E,IAAI,CAACA,GAAGC,OAAW,EAAE,MAAMA,IAAQ,GAAG,OAAOD,EAAA,EAAI;AACjE;AAEO,MAAME,IAAsB,IAAI/B,EAAA;"}
@@ -1,4 +1,4 @@
1
1
  export * from './i18n.types';
2
- export { I18nService, I18nServiceInstance } from './i18n.service';
2
+ export { I18nService, I18nServiceInstance, i18NextInstance } from './i18n.service';
3
3
  export { useI18n, I18nProvider, type I18nProviderProps } from './i18n.react';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/i18n/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,EAAC,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAC,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/i18n/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAClF,OAAO,EAAC,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAC,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seij/common-ui",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,14 +8,15 @@
8
8
  "url": "https://github.com/seij-net/seij-commons-js.git"
9
9
  },
10
10
  "dependencies": {
11
+ "@fluentui/react-components": "9.72.9",
11
12
  "@fluentui/react-icons": "2.0.316",
13
+ "i18next-browser-languagedetector": "8.2.0",
12
14
  "@seij/common-types": "0.1.3",
13
- "date-fns": "4.1.0",
14
- "@fluentui/react-components": "9.72.9",
15
+ "i18next": "25.7.3",
15
16
  "i18next-icu": "2.4.1",
16
17
  "lodash-es": "4.17.22",
17
- "rifm": "0.12.1",
18
- "i18next": "25.7.3"
18
+ "date-fns": "4.1.0",
19
+ "rifm": "0.12.1"
19
20
  },
20
21
  "devDependencies": {
21
22
  "@types/lodash-es": "4.17.12"
@@ -1,29 +0,0 @@
1
- const t = ["fr", "en"];
2
- function r(e) {
3
- if (!e) return "en";
4
- const n = e.toLowerCase(), o = n.split("-")[0];
5
- return t.includes(n) ? n : t.includes(o) ? o : "en";
6
- }
7
- function i() {
8
- if (!(typeof navigator > "u"))
9
- return navigator.languages?.[0] || navigator.language;
10
- }
11
- function a() {
12
- if (!(typeof window > "u"))
13
- return localStorage.getItem("locale") || void 0;
14
- }
15
- function u() {
16
- if (!(typeof window > "u"))
17
- return new URLSearchParams(window.location.search).get("lang") || void 0;
18
- }
19
- function f() {
20
- return r(
21
- u() || a() || // fromHtmlLang() ||
22
- i()
23
- );
24
- }
25
- export {
26
- f as detectClientLocale,
27
- r as normalize
28
- };
29
- //# sourceMappingURL=i18n.detect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"i18n.detect.js","sources":["../../../src/lib/i18n/i18n.detect.ts"],"sourcesContent":["// i18n/locale.ts\nexport type Locale = string;\n\nconst SUPPORTED = [\"fr\", \"en\"] as const;\nconst FALLBACK: Locale = \"en\";\n\nexport function normalize(loc?: string): Locale {\n if (!loc) return FALLBACK;\n // garde \"fr-CA\" mais tombe sur \"fr\" si non supporté\n const lc = loc.toLowerCase();\n const base = lc.split(\"-\")[0];\n return SUPPORTED.includes(lc as any) ? (lc as Locale) : SUPPORTED.includes(base as any) ? (base as Locale) : FALLBACK;\n}\n\n// Client-only helpers\nfunction fromHtmlLang(): string | undefined {\n return typeof document !== \"undefined\" ? document.documentElement.lang : undefined;\n}\nfunction fromNavigator(): string | undefined {\n if (typeof navigator === \"undefined\") return undefined;\n return navigator.languages?.[0] || navigator.language;\n}\nfunction fromStorage(): string | undefined {\n if (typeof window === \"undefined\") return undefined;\n return localStorage.getItem(\"locale\") || undefined;\n}\nfunction fromQuery(): string | undefined {\n if (typeof window === \"undefined\") return undefined;\n return new URLSearchParams(window.location.search).get(\"lang\") || undefined;\n}\n\nexport function detectClientLocale(): Locale {\n return normalize(\n fromQuery() ||\n fromStorage() ||\n // fromHtmlLang() ||\n fromNavigator(),\n );\n}\n\n// SSR-side (ex: Next.js route handler / Node middleware)\nexport function detectServerLocale(opts: {\n queryLang?: string | null;\n cookieLang?: string | null;\n acceptLanguage?: string | null;\n}): Locale {\n const fromAL = opts.acceptLanguage?.split(\",\")?.[0]; // ex: \"fr-CA,fr;q=0.9,en;q=0.8\"\n return normalize(opts.queryLang || opts.cookieLang || fromAL);\n}\n\n// Persister le choix utilisateur (client)\nexport function setUserLocale(loc: string) {\n const n = normalize(loc);\n if (typeof document !== \"undefined\") document.documentElement.lang = n;\n if (typeof window !== \"undefined\") localStorage.setItem(\"locale\", n);\n return n;\n}\n"],"names":["SUPPORTED","normalize","loc","lc","base","fromNavigator","fromStorage","fromQuery","detectClientLocale"],"mappings":"AAGA,MAAMA,IAAY,CAAC,MAAM,IAAI;AAGtB,SAASC,EAAUC,GAAsB;AAC9C,MAAI,CAACA,EAAK,QAAO;AAEjB,QAAMC,IAAKD,EAAI,YAAA,GACTE,IAAOD,EAAG,MAAM,GAAG,EAAE,CAAC;AAC5B,SAAOH,EAAU,SAASG,CAAS,IAAKA,IAAgBH,EAAU,SAASI,CAAW,IAAKA,IAAkB;AAC/G;AAMA,SAASC,IAAoC;AAC3C,MAAI,SAAO,YAAc;AACzB,WAAO,UAAU,YAAY,CAAC,KAAK,UAAU;AAC/C;AACA,SAASC,IAAkC;AACzC,MAAI,SAAO,SAAW;AACtB,WAAO,aAAa,QAAQ,QAAQ,KAAK;AAC3C;AACA,SAASC,IAAgC;AACvC,MAAI,SAAO,SAAW;AACtB,WAAO,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAAE,IAAI,MAAM,KAAK;AACpE;AAEO,SAASC,IAA6B;AAC3C,SAAOP;AAAA,IACLM,EAAA,KACED,EAAA;AAAA,IAEAD,EAAA;AAAA,EAAc;AAEpB;"}