@seij/common-ui 0.1.2 → 0.1.3

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,118 +1,119 @@
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 f } from "./lib/button_bar/ButtonBar.js";
4
+ import { ButtonBar as n } from "./lib/button_bar/ButtonBar.js";
5
5
  import { Button as i } from "./lib/button/Button.js";
6
6
  import { CommonUi as b } from "./lib/common-ui.js";
7
7
  import { obfuscateLabel as I } from "./lib/commons/obfuscatelabel.js";
8
- import { DataTable as D, DataTableBody as L, DataTableCaption as c, DataTableCell as d, DataTableHead as s, DataTableHeaderCell as y, DataTableRow as B } from "./lib/data_table/DataTable.js";
9
- import { DataTableDynamic as w } from "./lib/datatabledynamic/DataTableDynamic.js";
10
- import { ErrorManager as P, useErrorNotifier as S } from "./lib/error_notifier/ErrorNotifier.js";
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
+ import { DataTableDynamic as M } from "./lib/datatabledynamic/DataTableDynamic.js";
10
+ import { ErrorManager as P, useErrorNotifier as A } from "./lib/error_notifier/ErrorNotifier.js";
11
11
  import { ErrorBox as F } from "./lib/errorbox/ErrorBox.js";
12
- import { FormField as C, FormLayout as V, FormLayoutTable as g, FormSectionTitle as h, FormText as R } from "./lib/form_layout/FormLayout.js";
13
- import { createI18nEngine as _ } from "./lib/i18n/i18n.factory.js";
14
- import { I18nProvider as H, useI18n as O } from "./lib/i18n/i18n.react.js";
15
- import { InfoBox as j } from "./lib/info_box/InfoBox.js";
16
- import { InlineEdit as k } from "./lib/inlineedit/InlineEdit.js";
17
- import { ListView as z } from "./lib/listview/ListView.js";
18
- import { Loader as J } from "./lib/loader/Loader.js";
19
- import { InputLocalDate as Q } from "./lib/localdate/InputLocalDate.js";
20
- import { LabelLocalDate as Z } from "./lib/localdate/LabelLocalDate.js";
21
- import { InputMoneyDec as oo } from "./lib/money/InputMoneyDec.js";
22
- import { InputMoneyInt as eo } from "./lib/money/InputMoneyInt.js";
23
- import { LabelMoneyDec as po } from "./lib/money/LabelMoneyDec.js";
24
- import { LabelMoneyInt as mo } from "./lib/money/LabelMoneyInt.js";
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";
24
+ import { LabelMoneyInt as xo } from "./lib/money/LabelMoneyInt.js";
25
25
  import { InputDurationMonths as fo } from "./lib/month/InputDurationMonths.js";
26
- import { InputMonth as io } from "./lib/month/InputMonth.js";
27
- import { Navigation as bo } from "./lib/navigation/Navigation.js";
28
- import { INPUT_AMOUNT_ALLOWED_DECIMAL_SEPARATORS as Io, InputNumber as To } from "./lib/number/InputNumber.js";
26
+ import { InputMonth as lo } from "./lib/month/InputMonth.js";
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
29
  import { InputNumberDec as Lo } from "./lib/number/InputNumberDec.js";
30
- import { InputNumberInt as so } from "./lib/number/InputNumberInt.js";
30
+ import { InputNumberInt as yo } from "./lib/number/InputNumberInt.js";
31
31
  import { InputPercent as Bo } from "./lib/percent/InputPercent.js";
32
- import { LabelPercent as wo, LabelRate as Eo } from "./lib/percent/LabelPercent.js";
33
- import { LabelPercentInt as So } from "./lib/percent/LabelPercentInt.js";
34
- import { InputCombobox as Fo } from "./lib/select/InputCombobox.js";
35
- import { InputSelect as Co } from "./lib/select/InputSelect.js";
36
- import { SwitchButton as go } from "./lib/switchbutton/SwitchButton.js";
37
- import { Tabs as Ro, TabsList as Uo, TabsPanel as _o, TabsTab as vo } from "./lib/tabs/Tabs.js";
38
- import { InputText as Oo } from "./lib/text/InputText.js";
39
- import { Description as jo } from "./lib/typography/description/Description.js";
40
- import { LabelAndDescription as ko } from "./lib/typography/label_and_description/LabelAndDescription.js";
41
- import { Todo as zo } from "./lib/typography/todo/Todo.js";
42
- import { SectionTitle as Jo } from "./lib/typography/sectiontitle/SectionTitle.js";
43
- import { ViewBody as Qo } from "./lib/view_layout/ViewBody.js";
44
- import { ViewFooter as Zo } from "./lib/view_layout/ViewFooter.js";
45
- import { ViewHeader as or } from "./lib/view_layout/ViewHeader.js";
46
- import { ViewLayout as er } from "./lib/view_layout/ViewLayout.js";
47
- import { ViewTitle as pr } from "./lib/view_layout/ViewTitle.js";
48
- import { InputDurationYears as mr } from "./lib/year/InputDurationYears.js";
32
+ import { LabelPercent as wo, LabelRate as Po } from "./lib/percent/LabelPercent.js";
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";
48
+ import { InputDurationYears as xr } from "./lib/year/InputDurationYears.js";
49
49
  import { InputYear as fr } from "./lib/year/InputYear.js";
50
50
  export {
51
51
  p as ApplicationShell,
52
52
  m as Badge,
53
53
  i as Button,
54
- f as ButtonBar,
54
+ n as ButtonBar,
55
55
  b as CommonUi,
56
- D as DataTable,
57
- L as DataTableBody,
58
- c as DataTableCaption,
59
- d as DataTableCell,
60
- w as DataTableDynamic,
61
- s as DataTableHead,
56
+ c as DataTable,
57
+ D as DataTableBody,
58
+ L as DataTableCaption,
59
+ s as DataTableCell,
60
+ M as DataTableDynamic,
61
+ d as DataTableHead,
62
62
  y as DataTableHeaderCell,
63
- B as DataTableRow,
64
- jo as Description,
63
+ S as DataTableRow,
64
+ Wo as Description,
65
65
  F as ErrorBox,
66
66
  P as ErrorManager,
67
67
  C as FormField,
68
68
  V as FormLayout,
69
- g as FormLayoutTable,
69
+ v as FormLayoutTable,
70
70
  h as FormSectionTitle,
71
71
  R as FormText,
72
- H as I18nProvider,
73
- Io as INPUT_AMOUNT_ALLOWED_DECIMAL_SEPARATORS,
74
- j as InfoBox,
75
- k as InlineEdit,
76
- Fo as InputCombobox,
72
+ O as I18nProvider,
73
+ _ as I18nService,
74
+ g as I18nServiceInstance,
75
+ To as INPUT_AMOUNT_ALLOWED_DECIMAL_SEPARATORS,
76
+ W as InfoBox,
77
+ q as InlineEdit,
78
+ No as InputCombobox,
77
79
  fo as InputDurationMonths,
78
- mr as InputDurationYears,
79
- Q as InputLocalDate,
80
- oo as InputMoneyDec,
81
- eo as InputMoneyInt,
82
- io as InputMonth,
83
- To as InputNumber,
80
+ xr as InputDurationYears,
81
+ X as InputLocalDate,
82
+ ro as InputMoneyDec,
83
+ to as InputMoneyInt,
84
+ lo as InputMonth,
85
+ co as InputNumber,
84
86
  Lo as InputNumberDec,
85
- so as InputNumberInt,
87
+ yo as InputNumberInt,
86
88
  Bo as InputPercent,
87
- Co as InputSelect,
88
- Oo as InputText,
89
+ Vo as InputSelect,
90
+ Yo as InputText,
89
91
  fr as InputYear,
90
- ko as LabelAndDescription,
91
- Z as LabelLocalDate,
92
- po as LabelMoneyDec,
93
- mo as LabelMoneyInt,
92
+ qo as LabelAndDescription,
93
+ $ as LabelLocalDate,
94
+ ao as LabelMoneyDec,
95
+ xo as LabelMoneyInt,
94
96
  wo as LabelPercent,
95
- So as LabelPercentInt,
96
- Eo as LabelRate,
97
- z as ListView,
98
- J as Loader,
99
- bo as Navigation,
100
- Jo as SectionTitle,
97
+ Eo as LabelPercentInt,
98
+ Po as LabelRate,
99
+ G as ListView,
100
+ K as Loader,
101
+ uo as Navigation,
102
+ Ko as SectionTitle,
101
103
  e as SeijUIProvider,
102
- go as SwitchButton,
103
- Ro as Tabs,
104
- Uo as TabsList,
105
- _o as TabsPanel,
106
- vo as TabsTab,
107
- zo as Todo,
108
- Qo as ViewBody,
109
- Zo as ViewFooter,
110
- or as ViewHeader,
111
- er as ViewLayout,
112
- pr as ViewTitle,
113
- _ as createI18nEngine,
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,
114
115
  I as obfuscateLabel,
115
- S as useErrorNotifier,
116
- O as useI18n
116
+ A as useErrorNotifier,
117
+ Y as useI18n
117
118
  };
118
119
  //# sourceMappingURL=index.js.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,2CAc9E"}
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,20 +1,20 @@
1
- import { jsx as o, jsxs as a } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
2
  import { webLightTheme as i, FluentProvider as n } from "@fluentui/react-components";
3
3
  import { ErrorManager as s } from "../lib/error_notifier/ErrorNotifier.js";
4
- import { I18nProvider as m } from "../lib/i18n/i18n.react.js";
5
- const f = {
4
+ import { I18nProvider as a } from "../lib/i18n/i18n.react.js";
5
+ const m = {
6
6
  ...i,
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 y({ children: r, initialLocale: t }) {
12
- return /* @__PURE__ */ o(m, { initialLocale: t, load: async (e) => e === "fr" ? (await import("../locales/fr.js")).default : e === "en" ? (await import("../locales/en.js")).default : (await import("../locales/en.js")).default, children: /* @__PURE__ */ a(n, { theme: f, children: [
13
- r,
14
- /* @__PURE__ */ o(s, {})
11
+ function u({ children: o, initialLocale: r }) {
12
+ return /* @__PURE__ */ e(a, { initialLocale: r, children: /* @__PURE__ */ t(n, { theme: m, children: [
13
+ o,
14
+ /* @__PURE__ */ e(s, {})
15
15
  ] }) });
16
16
  }
17
17
  export {
18
- y as SeijUIProvider
18
+ u 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 const loader = async (locale: string) => {\n if (locale === \"fr\") return (await import(\"../locales/fr\")).default;\n if (locale === \"en\") return (await import(\"../locales/en\")).default;\n return (await import(\"../locales/en\")).default;\n };\n return (\n <I18nProvider initialLocale={initialLocale} load={loader}>\n <FluentProvider theme={theme}>\n {children}\n <ErrorManager />\n </FluentProvider>\n </I18nProvider>\n );\n}\n"],"names":["theme","webLightTheme","SeijUIProvider","children","initialLocale","I18nProvider","locale","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;AAM/E,2BACGC,GAAA,EAAa,eAAAD,GAA8B,MAN/B,OAAOE,MAChBA,MAAW,QAAc,MAAM,OAAO,kBAAe,GAAG,UACxDA,MAAW,QAAc,MAAM,OAAO,kBAAe,GAAG,WACpD,MAAM,OAAO,kBAAe,GAAG,SAIrC,UAAA,gBAAAC,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 { 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,19 +1,10 @@
1
1
  import { default as React } from 'react';
2
- import { Formats, I18n, Messages } from './i18n.types';
3
- type Loader = (locale: string) => Promise<{
4
- messages: Messages;
5
- formats: Formats;
6
- }>;
2
+ import { I18n } from './i18n.types';
7
3
  export interface I18nProviderProps {
8
4
  children: React.ReactNode;
9
5
  /** SSR hydrate */
10
6
  initialLocale?: string;
11
- /** for tests, storybook, preview */
12
- forcedLocale?: string;
13
- /** Lazy loading by locale of messages and formats (promise) */
14
- load: Loader;
15
7
  }
16
- export declare function I18nProvider({ children, initialLocale, forcedLocale, load }: I18nProviderProps): string | import("react/jsx-runtime").JSX.Element | null;
8
+ export declare function I18nProvider({ children, initialLocale }: I18nProviderProps): import("react/jsx-runtime").JSX.Element;
17
9
  export declare function useI18n(): I18n;
18
- export {};
19
10
  //# 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,KAAkE,MAAM,OAAO,CAAC;AAGvF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEvD,KAAK,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAIpF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,kBAAkB;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,iBAAiB,2DAwB9F;AAED,wBAAgB,OAAO,IAAI,IAAI,CAI9B"}
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,29 +1,35 @@
1
- import { jsx as f } from "react/jsx-runtime";
2
- import { toProblem as I } from "@seij/common-types";
3
- import { createContext as d, useContext as v, useMemo as p, useState as i, useEffect as x } from "react";
4
- import { normalize as C, detectClientLocale as h } from "./i18n.detect.js";
5
- import { createI18nEngine as E } from "./i18n.factory.js";
6
- const m = d(null);
7
- function z({ children: t, initialLocale: n, forcedLocale: o, load: s }) {
8
- const e = p(
9
- () => C(o || n || h()),
10
- [o, n]
11
- ), [u, c] = i(null), [a, l] = i(null);
12
- return x(() => {
13
- s(e).then((r) => {
14
- c(E(e, r.messages, r.formats)), l(null);
15
- }).catch((r) => {
16
- l(I(r));
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";
5
+ 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
+ });
17
15
  });
18
- }, [e, s]), a ? "Could not load locale " + e : u ? /* @__PURE__ */ f(m.Provider, { value: u, children: t }) : null;
16
+ }, [t]);
17
+ const m = s(
18
+ () => ({
19
+ i18nService: n,
20
+ lastChange: r
21
+ }),
22
+ [r]
23
+ );
24
+ return /* @__PURE__ */ u(a.Provider, { value: m, children: e });
19
25
  }
20
- function M() {
21
- const t = v(m);
22
- if (!t) throw new Error("useI18n must be used within I18nProvider");
23
- return t;
26
+ function w() {
27
+ const e = f(a);
28
+ if (!e) throw new Error("useI18n must be used within I18nProvider");
29
+ return e.i18nService;
24
30
  }
25
31
  export {
26
- z as I18nProvider,
27
- M as useI18n
32
+ S as I18nProvider,
33
+ w as useI18n
28
34
  };
29
35
  //# 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 { Problem, toProblem } from \"@seij/common-types\";\nimport React, { createContext, useContext, useEffect, useMemo, useState } from \"react\";\nimport { detectClientLocale, normalize } from \"./i18n.detect\";\nimport { createI18nEngine } from \"./i18n.factory\";\nimport { Formats, I18n, Messages } from \"./i18n.types\";\n\ntype Loader = (locale: string) => Promise<{ messages: Messages; formats: Formats }>;\n\nconst I18nCtx = createContext<I18n | null>(null);\n\nexport interface I18nProviderProps {\n children: React.ReactNode;\n /** SSR hydrate */\n initialLocale?: string;\n /** for tests, storybook, preview */\n forcedLocale?: string;\n /** Lazy loading by locale of messages and formats (promise) */\n load: Loader;\n}\n\nexport function I18nProvider({ children, initialLocale, forcedLocale, load }: I18nProviderProps) {\n // Detects the locale: first used the forced one, then initial, then use autodetection\n const locale = useMemo(\n () => normalize(forcedLocale || initialLocale || detectClientLocale()),\n [forcedLocale, initialLocale],\n );\n\n const [validInstance, setValidInstance] = useState<I18n | null>(null);\n const [error, setError] = useState<Problem | null>(null);\n\n useEffect(() => {\n load(locale)\n .then((resp) => {\n setValidInstance(createI18nEngine(locale, resp.messages, resp.formats));\n setError(null);\n })\n .catch((err) => {\n setError(toProblem(err));\n });\n }, [locale, load]);\n\n if (error) return \"Could not load locale \" + locale;\n if (!validInstance) return null;\n return <I18nCtx.Provider value={validInstance}>{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;\n}\n"],"names":["I18nCtx","createContext","I18nProvider","children","initialLocale","forcedLocale","load","locale","useMemo","normalize","detectClientLocale","validInstance","setValidInstance","useState","error","setError","useEffect","resp","createI18nEngine","err","toProblem","useI18n","v","useContext"],"mappings":";;;;;AASA,MAAMA,IAAUC,EAA2B,IAAI;AAYxC,SAASC,EAAa,EAAE,UAAAC,GAAU,eAAAC,GAAe,cAAAC,GAAc,MAAAC,KAA2B;AAE/F,QAAMC,IAASC;AAAA,IACb,MAAMC,EAAUJ,KAAgBD,KAAiBM,GAAoB;AAAA,IACrE,CAACL,GAAcD,CAAa;AAAA,EAAA,GAGxB,CAACO,GAAeC,CAAgB,IAAIC,EAAsB,IAAI,GAC9D,CAACC,GAAOC,CAAQ,IAAIF,EAAyB,IAAI;AAavD,SAXAG,EAAU,MAAM;AACd,IAAAV,EAAKC,CAAM,EACR,KAAK,CAACU,MAAS;AACd,MAAAL,EAAiBM,EAAiBX,GAAQU,EAAK,UAAUA,EAAK,OAAO,CAAC,GACtEF,EAAS,IAAI;AAAA,IACf,CAAC,EACA,MAAM,CAACI,MAAQ;AACd,MAAAJ,EAASK,EAAUD,CAAG,CAAC;AAAA,IACzB,CAAC;AAAA,EACL,GAAG,CAACZ,GAAQD,CAAI,CAAC,GAEbQ,IAAc,2BAA2BP,IACxCI,sBACGX,EAAQ,UAAR,EAAiB,OAAOW,GAAgB,UAAAR,GAAS,IAD9B;AAE7B;AAEO,SAASkB,IAAgB;AAC9B,QAAMC,IAAIC,EAAWvB,CAAO;AAC5B,MAAI,CAACsB,EAAG,OAAM,IAAI,MAAM,0CAA0C;AAClE,SAAOA;AACT;"}
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;"}
@@ -0,0 +1,27 @@
1
+ import { I18n } from './i18n.types';
2
+ export declare class I18nService implements I18n {
3
+ readyPromise: Promise<import('i18next').TFunction<"translation", undefined>>;
4
+ getLocale: () => string;
5
+ rich: (id: string, values?: Record<string, unknown | ((chunks: string) => React.ReactNode)>) => React.ReactNode;
6
+ t: (id: string, values?: Record<string, unknown>) => string;
7
+ formats: () => import('./i18n.types').Formats;
8
+ language: () => string;
9
+ dtf: (style?: string) => Intl.DateTimeFormat;
10
+ nf: (style?: string) => Intl.NumberFormat;
11
+ lf: (style?: string) => Intl.ListFormat;
12
+ rtf: () => Intl.RelativeTimeFormat;
13
+ formatDate: (d: Date | number, style?: string) => string;
14
+ formatNumber: (n: number, style?: string) => string;
15
+ formatList: (items: string[], style?: string) => string;
16
+ formatRelative: (d: Date | number) => string;
17
+ localDatePlaceholder: () => string;
18
+ localDateInputMask: () => string;
19
+ localDateFormattedToISO: (str: string) => string;
20
+ localDateISOToFormattedInput: (str: string) => string;
21
+ monthList: () => {
22
+ code: number;
23
+ label: string;
24
+ }[];
25
+ }
26
+ export declare const I18nServiceInstance: I18nService;
27
+ //# sourceMappingURL=i18n.service.d.ts.map
@@ -0,0 +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,QAAQ,MAAM,KAAG,MAAM,CAEtD;IAED,YAAY,GAAG,GAAG,MAAM,EAAE,QAAQ,MAAM,KAAG,MAAM,CAEhD;IAED,UAAU,GAAI,OAAO,MAAM,EAAE,EAAE,QAAQ,MAAM,KAAG,MAAM,CAErD;IAED,cAAc,GAAI,GAAG,IAAI,GAAG,MAAM,KAAG,MAAM,CA4B1C;IAED,oBAAoB,QAAO,MAAM,CAEhC;IAED,kBAAkB,QAAO,MAAM,CAE9B;IAED,uBAAuB,GAAI,KAAK,MAAM,KAAG,MAAM,CAU9C;IAED,4BAA4B,GAAI,KAAK,MAAM,KAAG,MAAM,CAcnD;IAED,SAAS;cAKqC,MAAM;eAAS,MAAM;QAHlE;CACF;AAQD,eAAO,MAAM,mBAAmB,aAAoB,CAAC"}
@@ -0,0 +1,65 @@
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";
6
+ import { isString as p } from "lodash-es";
7
+ const n = d.createInstance(), I = n.use(g).init({
8
+ debug: !0,
9
+ resources: { fr: { translation: m.messages }, en: { translation: u.messages } },
10
+ interpolation: { escapeValue: !1 }
11
+ });
12
+ class D {
13
+ readyPromise = I;
14
+ getLocale = () => n.language;
15
+ rich = (t, e) => n.t(t, e);
16
+ t = (t, e) => n.t(t, e);
17
+ formats = () => n.language === "fr" ? m.formats : u.formats;
18
+ language = () => n.language;
19
+ dtf = (t) => new Intl.DateTimeFormat(this.language(), t && this.formats().date[t] || void 0);
20
+ nf = (t) => new Intl.NumberFormat(this.language(), t && this.formats().number[t] || void 0);
21
+ lf = (t) => new Intl.ListFormat(
22
+ this.language(),
23
+ t && this.formats().list[t] || { type: "conjunction", style: "long" }
24
+ );
25
+ rtf = () => new Intl.RelativeTimeFormat(this.language(), { numeric: "auto" });
26
+ formatDate = (t, e) => this.dtf(e).format(t);
27
+ formatNumber = (t, e) => this.nf(e).format(t);
28
+ formatList = (t, e) => this.lf(e).format(t);
29
+ 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);
32
+ };
33
+ localDatePlaceholder = () => this.formats().localdate.placeholder;
34
+ localDateInputMask = () => this.formats().localdate.inputmask;
35
+ localDateFormattedToISO = (t) => {
36
+ const e = this.formats().localdate.inputmask, a = f(
37
+ t,
38
+ e,
39
+ /* @__PURE__ */ new Date()
40
+ // { locale: fr }
41
+ );
42
+ return !s(a) || !i(a) ? "" : c(a, { representation: "date" });
43
+ };
44
+ localDateISOToFormattedInput = (t) => {
45
+ const e = this.formats().localdate.inputmask;
46
+ let a;
47
+ if (p(t)) {
48
+ const r = new Date(t);
49
+ s(r) && i(r) ? a = h(r, e) : a = "";
50
+ } else
51
+ a = "";
52
+ return a;
53
+ };
54
+ monthList = () => M(this.language());
55
+ }
56
+ function M(o) {
57
+ const t = new Intl.DateTimeFormat(o, { month: "long" });
58
+ return Array.from({ length: 12 }, (a, r) => t.format(new Date(2e3, r, 1))).map((a, r) => ({ code: r + 1, label: a }));
59
+ }
60
+ const S = new D();
61
+ export {
62
+ D as I18nService,
63
+ S as I18nServiceInstance
64
+ };
65
+ //# sourceMappingURL=i18n.service.js.map
@@ -0,0 +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\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","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,MACHF,EAAgB;AAAA,EAGzB,OAAO,CAACO,GAAYC,MACXR,EAAgB,EAAEO,GAAIC,CAAM;AAAA,EAGrC,IAAI,CAACD,GAAYC,MACRR,EAAgB,EAAEO,GAAIC,CAAM;AAAA,EAGrC,UAAU,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,uBAAuB,MACd,KAAK,UAAU,UAAU;AAAA,EAGlC,qBAAqB,MACZ,KAAK,UAAU,UAAU;AAAA,EAGlC,0BAA0B,CAACE,MAAwB;AACjD,UAAMC,IAAY,KAAK,QAAA,EAAU,UAAU,WACrCC,IAASC;AAAA,MACbH;AAAA,MACAC;AAAA,0BACI,KAAA;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;AAExC;AAEA,SAASA,EAAcC,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,IAAI5B,EAAA;"}
@@ -15,11 +15,11 @@ export interface I18n {
15
15
  formatNumber(n: number, style?: string): string;
16
16
  formatList(items: string[], style?: string): string;
17
17
  formatRelative(d: Date | number): string;
18
- localDatePlaceholder: string;
19
- localDateInputMask: string;
18
+ localDatePlaceholder(): string;
19
+ localDateInputMask(): string;
20
20
  localDateFormattedToISO: (str: string) => string;
21
21
  localDateISOToFormattedInput: (str: string) => string;
22
- monthList: {
22
+ monthList(): {
23
23
  code: number;
24
24
  label: string;
25
25
  }[];
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.types.d.ts","sourceRoot":"","sources":["../../../src/lib/i18n/i18n.types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC9C,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE;QACT,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACjD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACjD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;CAC9C,CAAC;AAEF,MAAM,WAAW,IAAI;IACnB,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;IACxD,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;IAC5G,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrD,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAChD,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,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,KAAK,CAAC,SAAS,CAAC;IAC5G,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrD,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAChD,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpD,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IACzC,oBAAoB,IAAI,MAAM,CAAC;IAC/B,kBAAkB,IAAI,MAAM,CAAC;IAC7B,uBAAuB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACjD,4BAA4B,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACtD,SAAS,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC/C,SAAS,IAAI,MAAM,CAAC;CACrB"}
@@ -1,4 +1,4 @@
1
1
  export * from './i18n.types';
2
- export * from './i18n.factory';
2
+ export { I18nService, I18nServiceInstance } 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,cAAc,gBAAgB,CAAC;AAC/B,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,MAAM,gBAAgB,CAAA;AACjE,OAAO,EAAC,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAC,MAAM,cAAc,CAAC"}
@@ -44,7 +44,7 @@ const N = S({
44
44
  children: ({ value: s, onChange: a }) => /* @__PURE__ */ f(
45
45
  y,
46
46
  {
47
- placeholder: $,
47
+ placeholder: $(),
48
48
  className: D.root,
49
49
  value: s,
50
50
  onChange: a,
@@ -1 +1 @@
1
- {"version":3,"file":"InputLocalDate.js","sources":["../../../src/lib/localdate/InputLocalDate.tsx"],"sourcesContent":["import { Input, makeStyles } from \"@fluentui/react-components\";\nimport { LocalDate } from \"@seij/common-types\";\nimport { forwardRef, InputHTMLAttributes, useCallback, useEffect, useState } from \"react\";\nimport { Rifm } from \"rifm\";\nimport { useI18n } from \"../i18n/i18n.react\";\n\nconst useStyles = makeStyles({\n root: {\n width: \"8em\",\n \"> input\": {\n textAlign: \"right\",\n },\n },\n});\n\nconst parseDigits = (string: string): string => (string.match(/\\d+/g) || []).join(\"\");\nconst formatDate = (string: string): string => {\n const digits = parseDigits(string);\n const chars = digits.split(\"\");\n return chars.reduce((r, v, index) => (index === 2 || index === 4 ? `${r}/${v}` : `${r}${v}`), \"\").substr(0, 10);\n};\n\nconst formatDateWithAppend = (string: string): string => {\n const res = formatDate(string);\n\n if (string.endsWith(\"/\")) {\n if (res.length === 2) {\n return `${res}/`;\n }\n\n if (res.length === 5) {\n return `${res}/`;\n }\n }\n return res;\n};\nconst appendHyphen = (v: string): string => (v.length === 2 || v.length === 5 ? `${v}/` : v);\n\n/**\n * Input field for local dates with automatic adding of /\n * Values are in ISO8601 date part only\n *\n * Controlled component only\n *\n * @param props same props as an input\n * @return {JSX.Element}\n */\nexport interface InputLocalDateProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"value\" | \"onChange\"> {\n value?: string;\n onValueChange?: (value: LocalDate) => void;\n}\n\nexport const InputLocalDate = forwardRef<HTMLInputElement, InputLocalDateProps>((props, ref) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { onValueChange, value = \"\", children, size, defaultValue, type, ...delegatedProps } = props;\n const classNames = useStyles();\n const { localDatePlaceholder, localDateFormattedToISO, localDateISOToFormattedInput } = useI18n();\n const [formattedA, setFormattedA] = useState(localDateISOToFormattedInput(value));\n const [normalizedValue, setNormalizedValue] = useState(value);\n\n useEffect(() => {\n if (value !== normalizedValue) {\n setNormalizedValue(value);\n setFormattedA(localDateISOToFormattedInput(value));\n }\n });\n\n const handleChange = useCallback(\n (inputValue: string) => {\n setFormattedA(inputValue);\n const parsed = localDateFormattedToISO(inputValue);\n if (parsed !== normalizedValue) {\n setNormalizedValue(parsed);\n if (onValueChange) onValueChange(parsed);\n }\n },\n [setFormattedA, normalizedValue, setNormalizedValue, onValueChange, localDateFormattedToISO],\n );\n return (\n <Rifm\n accept={/\\d+/g}\n mask={10 <= formattedA.length}\n format={formatDateWithAppend}\n append={appendHyphen}\n value={formattedA}\n onChange={handleChange}\n >\n {({ value, onChange }) => (\n <Input\n placeholder={localDatePlaceholder}\n className={classNames.root}\n value={value}\n onChange={onChange}\n ref={ref}\n {...delegatedProps}\n />\n )}\n </Rifm>\n );\n});\n"],"names":["useStyles","makeStyles","parseDigits","string","formatDate","r","v","index","formatDateWithAppend","res","appendHyphen","InputLocalDate","forwardRef","props","ref","onValueChange","value","children","size","defaultValue","type","delegatedProps","classNames","localDatePlaceholder","localDateFormattedToISO","localDateISOToFormattedInput","useI18n","formattedA","setFormattedA","useState","normalizedValue","setNormalizedValue","useEffect","handleChange","useCallback","inputValue","parsed","jsx","Rifm","onChange","Input"],"mappings":";;;;;AAMA,MAAMA,IAAYC,EAAW;AAAA,EAC3B,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,WAAW;AAAA,MACT,WAAW;AAAA,IAAA;AAAA,EACb;AAEJ,CAAC,GAEKC,IAAc,CAACC,OAA4BA,EAAO,MAAM,MAAM,KAAK,CAAA,GAAI,KAAK,EAAE,GAC9EC,IAAa,CAAC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AoBhB,GAAeS,CAAuB;AAAA,EAAA;AAE7F,SACE,gBAAAa;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,QAAQ;AAAA,MACR,MAAM,MAAMX,EAAW;AAAA,MACvB,QAAQnB;AAAA,MACR,QAAQE;AAAA,MACR,OAAOiB;AAAA,MACP,UAAUM;AAAA,MAET,UAAA,CAAC,EAAE,OAAAjB,GAAO,UAAAuB,QACT,gBAAAF;AAAA,QAACG;AAAA,QAAA;AAAA,UACC,aAAajB;AAAA,UACb,WAAWD,EAAW;AAAA,UACtB,OAAON;AAAAA,UACP,UAAAuB;AAAA,UACA,KAAAzB;AAAA,UACC,GAAGO;AAAA,QAAA;AAAA,MAAA;AAAA,IACN;AAAA,EAAA;AAIR,CAAC;"}
1
+ {"version":3,"file":"InputLocalDate.js","sources":["../../../src/lib/localdate/InputLocalDate.tsx"],"sourcesContent":["import { Input, makeStyles } from \"@fluentui/react-components\";\nimport { LocalDate } from \"@seij/common-types\";\nimport { forwardRef, InputHTMLAttributes, useCallback, useEffect, useState } from \"react\";\nimport { Rifm } from \"rifm\";\nimport { useI18n } from \"../i18n/i18n.react\";\n\nconst useStyles = makeStyles({\n root: {\n width: \"8em\",\n \"> input\": {\n textAlign: \"right\",\n },\n },\n});\n\nconst parseDigits = (string: string): string => (string.match(/\\d+/g) || []).join(\"\");\nconst formatDate = (string: string): string => {\n const digits = parseDigits(string);\n const chars = digits.split(\"\");\n return chars.reduce((r, v, index) => (index === 2 || index === 4 ? `${r}/${v}` : `${r}${v}`), \"\").substr(0, 10);\n};\n\nconst formatDateWithAppend = (string: string): string => {\n const res = formatDate(string);\n\n if (string.endsWith(\"/\")) {\n if (res.length === 2) {\n return `${res}/`;\n }\n\n if (res.length === 5) {\n return `${res}/`;\n }\n }\n return res;\n};\nconst appendHyphen = (v: string): string => (v.length === 2 || v.length === 5 ? `${v}/` : v);\n\n/**\n * Input field for local dates with automatic adding of /\n * Values are in ISO8601 date part only\n *\n * Controlled component only\n *\n * @param props same props as an input\n * @return {JSX.Element}\n */\nexport interface InputLocalDateProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"value\" | \"onChange\"> {\n value?: string;\n onValueChange?: (value: LocalDate) => void;\n}\n\nexport const InputLocalDate = forwardRef<HTMLInputElement, InputLocalDateProps>((props, ref) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { onValueChange, value = \"\", children, size, defaultValue, type, ...delegatedProps } = props;\n const classNames = useStyles();\n const { localDatePlaceholder, localDateFormattedToISO, localDateISOToFormattedInput } = useI18n();\n const [formattedA, setFormattedA] = useState(localDateISOToFormattedInput(value));\n const [normalizedValue, setNormalizedValue] = useState(value);\n\n useEffect(() => {\n if (value !== normalizedValue) {\n setNormalizedValue(value);\n setFormattedA(localDateISOToFormattedInput(value));\n }\n });\n\n const handleChange = useCallback(\n (inputValue: string) => {\n setFormattedA(inputValue);\n const parsed = localDateFormattedToISO(inputValue);\n if (parsed !== normalizedValue) {\n setNormalizedValue(parsed);\n if (onValueChange) onValueChange(parsed);\n }\n },\n [setFormattedA, normalizedValue, setNormalizedValue, onValueChange, localDateFormattedToISO],\n );\n return (\n <Rifm\n accept={/\\d+/g}\n mask={10 <= formattedA.length}\n format={formatDateWithAppend}\n append={appendHyphen}\n value={formattedA}\n onChange={handleChange}\n >\n {({ value, onChange }) => (\n <Input\n placeholder={localDatePlaceholder()}\n className={classNames.root}\n value={value}\n onChange={onChange}\n ref={ref}\n {...delegatedProps}\n />\n )}\n </Rifm>\n );\n});\n"],"names":["useStyles","makeStyles","parseDigits","string","formatDate","r","v","index","formatDateWithAppend","res","appendHyphen","InputLocalDate","forwardRef","props","ref","onValueChange","value","children","size","defaultValue","type","delegatedProps","classNames","localDatePlaceholder","localDateFormattedToISO","localDateISOToFormattedInput","useI18n","formattedA","setFormattedA","useState","normalizedValue","setNormalizedValue","useEffect","handleChange","useCallback","inputValue","parsed","jsx","Rifm","onChange","Input"],"mappings":";;;;;AAMA,MAAMA,IAAYC,EAAW;A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AAAA,IACnB,CAACC,MAAuB;AACtB,MAAAP,EAAcO,CAAU;AACxB,YAAMC,IAASZ,EAAwBW,CAAU;AACjD,MAAIC,MAAWN,MACbC,EAAmBK,CAAM,GACrBrB,OAA6BqB,CAAM;AAAA,IAE3C;AAAA,IACA,CAACR,GAAeE,GAAiBC,GAAoBhB,GAAeS,CAAuB;AAAA,EAAA;AAE7F,SACE,gBAAAa;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,QAAQ;AAAA,MACR,MAAM,MAAMX,EAAW;AAAA,MACvB,QAAQnB;AAAA,MACR,QAAQE;AAAA,MACR,OAAOiB;AAAA,MACP,UAAUM;AAAA,MAET,UAAA,CAAC,EAAE,OAAAjB,GAAO,UAAAuB,QACT,gBAAAF;AAAA,QAACG;AAAA,QAAA;AAAA,UACC,aAAajB,EAAA;AAAA,UACb,WAAWD,EAAW;AAAA,UACtB,OAAON;AAAAA,UACP,UAAAuB;AAAA,UACA,KAAAzB;AAAA,UACC,GAAGO;AAAA,QAAA;AAAA,MAAA;AAAA,IACN;AAAA,EAAA;AAIR,CAAC;"}
@@ -4,7 +4,7 @@ import { useI18n as p } from "../i18n/i18n.react.js";
4
4
  import { InputSelect as h } from "../select/InputSelect.js";
5
5
  const b = (l) => {
6
6
  const { value: r, onValueChange: c, required: i, ...m } = l, { monthList: t, t: o } = p(), s = a(() => {
7
- const e = t.map((n) => ({ code: "" + n.code, label: n.label }));
7
+ const e = t().map((n) => ({ code: "" + n.code, label: n.label }));
8
8
  return [{ code: "", label: "-- " + o("InputSelect_select") + " --" }, ...e];
9
9
  }, [t, o]);
10
10
  return /* @__PURE__ */ u(h, { options: s, value: "" + r, onValueChange: (e) => c(parseInt(e)), ...m });
@@ -1 +1 @@
1
- {"version":3,"file":"InputMonth.js","sources":["../../../src/lib/month/InputMonth.tsx"],"sourcesContent":["import { Month } from \"@seij/common-types\";\nimport React, { useMemo } from \"react\";\nimport { useI18n } from \"../i18n/i18n.react\";\nimport { InputSelect } from \"../select/InputSelect\";\n\ntype HTMLInputElementCurated = Omit<\n React.SelectHTMLAttributes<HTMLSelectElement>,\n \"value\" | \"defaultValue\" | \"onChange\" | \"children\"\n>;\n\nexport interface InputMonthProps extends HTMLInputElementCurated {\n value: Month;\n onValueChange: (value: Month) => unknown;\n}\n\n/**\n * Permet de saisir un mois.\n */\nexport const InputMonth: React.FC<InputMonthProps> = (props) => {\n const { value, onValueChange, required, ...other } = props;\n const { monthList, t } = useI18n();\n const options = useMemo(() => {\n const months = monthList.map((it) => ({ code: \"\" + it.code, label: it.label }));\n const emptyValueSelect = t(\"InputSelect_select\");\n return [{ code: \"\", label: \"-- \" + emptyValueSelect + \" --\" }, ...months];\n }, [monthList, t]);\n\n return (\n <InputSelect options={options} value={\"\" + value} onValueChange={(v) => onValueChange(parseInt(v))} {...other} />\n );\n};\n"],"names":["InputMonth","props","value","onValueChange","required","other","monthList","t","useI18n","options","useMemo","months","it","jsx","InputSelect","v"],"mappings":";;;;AAkBO,MAAMA,IAAwC,CAACC,MAAU;AAC9D,QAAM,EAAE,OAAAC,GAAO,eAAAC,GAAe,UAAAC,GAAU,GAAGC,MAAUJ,GAC/C,EAAE,WAAAK,GAAW,GAAAC,EAAA,IAAMC,EAAA,GACnBC,IAAUC,EAAQ,MAAM;AAC5B,UAAMC,IAASL,EAAU,IAAI,CAACM,OAAQ,EAAE,MAAM,KAAKA,EAAG,MAAM,OAAOA,EAAG,QAAQ;AAE9E,WAAO,CAAC,EAAE,MAAM,IAAI,OAAO,QADFL,EAAE,oBAAoB,IACO,SAAS,GAAGI,CAAM;AAAA,EAC1E,GAAG,CAACL,GAAWC,CAAC,CAAC;AAEjB,SACE,gBAAAM,EAACC,GAAA,EAAY,SAAAL,GAAkB,OAAO,KAAKP,GAAO,eAAe,CAACa,MAAMZ,EAAc,SAASY,CAAC,CAAC,GAAI,GAAGV,GAAO;AAEnH;"}
1
+ {"version":3,"file":"InputMonth.js","sources":["../../../src/lib/month/InputMonth.tsx"],"sourcesContent":["import { Month } from \"@seij/common-types\";\nimport React, { useMemo } from \"react\";\nimport { useI18n } from \"../i18n/i18n.react\";\nimport { InputSelect } from \"../select/InputSelect\";\n\ntype HTMLInputElementCurated = Omit<\n React.SelectHTMLAttributes<HTMLSelectElement>,\n \"value\" | \"defaultValue\" | \"onChange\" | \"children\"\n>;\n\nexport interface InputMonthProps extends HTMLInputElementCurated {\n value: Month;\n onValueChange: (value: Month) => unknown;\n}\n\n/**\n * Permet de saisir un mois.\n */\nexport const InputMonth: React.FC<InputMonthProps> = (props) => {\n const { value, onValueChange, required, ...other } = props;\n const { monthList, t } = useI18n();\n const options = useMemo(() => {\n const months = monthList().map((it) => ({ code: \"\" + it.code, label: it.label }));\n const emptyValueSelect = t(\"InputSelect_select\");\n return [{ code: \"\", label: \"-- \" + emptyValueSelect + \" --\" }, ...months];\n }, [monthList, t]);\n\n return (\n <InputSelect options={options} value={\"\" + value} onValueChange={(v) => onValueChange(parseInt(v))} {...other} />\n );\n};\n"],"names":["InputMonth","props","value","onValueChange","required","other","monthList","t","useI18n","options","useMemo","months","it","jsx","InputSelect","v"],"mappings":";;;;AAkBO,MAAMA,IAAwC,CAACC,MAAU;AAC9D,QAAM,EAAE,OAAAC,GAAO,eAAAC,GAAe,UAAAC,GAAU,GAAGC,MAAUJ,GAC/C,EAAE,WAAAK,GAAW,GAAAC,EAAA,IAAMC,EAAA,GACnBC,IAAUC,EAAQ,MAAM;AAC5B,UAAMC,IAASL,EAAA,EAAY,IAAI,CAACM,OAAQ,EAAE,MAAM,KAAKA,EAAG,MAAM,OAAOA,EAAG,QAAQ;AAEhF,WAAO,CAAC,EAAE,MAAM,IAAI,OAAO,QADFL,EAAE,oBAAoB,IACO,SAAS,GAAGI,CAAM;AAAA,EAC1E,GAAG,CAACL,GAAWC,CAAC,CAAC;AAEjB,SACE,gBAAAM,EAACC,GAAA,EAAY,SAAAL,GAAkB,OAAO,KAAKP,GAAO,eAAe,CAACa,MAAMZ,EAAc,SAASY,CAAC,CAAC,GAAI,GAAGV,GAAO;AAEnH;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seij/common-ui",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -9,13 +9,13 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@fluentui/react-components": "9.72.9",
12
- "@fluentui/react-icons": "2.0.316",
13
- "i18next": "25.7.3",
14
12
  "@seij/common-types": "0.1.3",
15
- "rifm": "0.12.1",
16
- "i18next-icu": "2.4.1",
13
+ "i18next": "25.7.3",
17
14
  "date-fns": "4.1.0",
18
- "lodash-es": "4.17.22"
15
+ "i18next-icu": "2.4.1",
16
+ "@fluentui/react-icons": "2.0.316",
17
+ "lodash-es": "4.17.22",
18
+ "rifm": "0.12.1"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/lodash-es": "4.17.12"
@@ -1,3 +0,0 @@
1
- import { Formats, I18n, Messages } from './i18n.types';
2
- export declare const createI18nEngine: (locale: string, messages: Messages, formats: Formats) => I18n;
3
- //# sourceMappingURL=i18n.factory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"i18n.factory.d.ts","sourceRoot":"","sources":["../../../src/lib/i18n/i18n.factory.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,UAAU,QAAQ,EAAE,SAAS,OAAO,KAAG,IAwEvF,CAAC"}
@@ -1,70 +0,0 @@
1
- import { isDate as s, isValid as c, format as I, parse as D, formatISO as g } from "date-fns";
2
- import F from "i18next";
3
- import w from "i18next-icu";
4
- import { isString as M } from "lodash-es";
5
- const L = (o, a, e) => {
6
- const r = F.createInstance();
7
- r.use(w).init({
8
- debug: !0,
9
- lng: o,
10
- resources: { [o]: { translation: a } },
11
- interpolation: { escapeValue: !1 },
12
- initAsync: !1
13
- });
14
- const i = r.getFixedT(o), l = (t) => new Intl.DateTimeFormat(o, t && e.date[t] || void 0), d = (t) => new Intl.NumberFormat(o, t && e.number[t] || void 0), f = (t) => new Intl.ListFormat(o, t && e.list[t] || { type: "conjunction", style: "long" }), h = () => new Intl.RelativeTimeFormat(o, { numeric: "auto" });
15
- return {
16
- t(t, n) {
17
- return console.log(r), i(t, n);
18
- },
19
- rich(t, n) {
20
- return i(t, n);
21
- },
22
- formatDate(t, n) {
23
- return l(n).format(t);
24
- },
25
- formatNumber(t, n) {
26
- return d(n).format(t);
27
- },
28
- formatList(t, n) {
29
- return f(n).format(t);
30
- },
31
- formatRelative(t) {
32
- const n = (Number(t) - Date.now()) / 1e3, u = Math.abs(n), m = u < 60 ? "second" : u < 3600 ? "minute" : u < 86400 ? "hour" : u < 2592e3 ? "day" : u < 31536e3 ? "month" : "year", p = Math.round(m === "second" ? n : m === "minute" ? n / 60 : m === "hour" ? n / 3600 : m === "day" ? n / 86400 : m === "month" ? n / 2592e3 : n / 31536e3);
33
- return h().format(p, m);
34
- },
35
- localDatePlaceholder: e.localdate.placeholder,
36
- localDateInputMask: e.localdate.inputmask,
37
- localDateFormattedToISO: (t) => b(t, e.localdate.inputmask),
38
- localDateISOToFormattedInput: (t) => T(t, e.localdate.inputmask),
39
- monthList: S(o),
40
- getLocale() {
41
- return o;
42
- }
43
- };
44
- };
45
- function b(o, a) {
46
- const e = D(
47
- o,
48
- a,
49
- /* @__PURE__ */ new Date()
50
- // { locale: fr }
51
- );
52
- return !s(e) || !c(e) ? "" : g(e, { representation: "date" });
53
- }
54
- const T = (o, a) => {
55
- let e;
56
- if (M(o)) {
57
- const r = new Date(o);
58
- s(r) && c(r) ? e = I(r, a) : e = "";
59
- } else
60
- e = "";
61
- return e;
62
- };
63
- function S(o) {
64
- const a = new Intl.DateTimeFormat(o, { month: "long" });
65
- return Array.from({ length: 12 }, (r, i) => a.format(new Date(2e3, i, 1))).map((r, i) => ({ code: i + 1, label: r }));
66
- }
67
- export {
68
- L as createI18nEngine
69
- };
70
- //# sourceMappingURL=i18n.factory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"i18n.factory.js","sources":["../../../src/lib/i18n/i18n.factory.ts"],"sourcesContent":["// adapter-i18next.ts (exemple d’implémentation)\nimport { format, formatISO, isDate, isValid, parse } from \"date-fns\";\nimport i18next from \"i18next\";\nimport ICU from \"i18next-icu\";\nimport { isString } from \"lodash-es\";\nimport { Formats, I18n, Messages } from \"./i18n.types\";\n\nexport const createI18nEngine = (locale: string, messages: Messages, formats: Formats): I18n => {\n const inst = i18next.createInstance();\n inst.use(ICU).init({\n debug: true,\n lng: locale,\n resources: { [locale]: { translation: messages } },\n interpolation: { escapeValue: false },\n initAsync: false,\n });\n\n const t = inst.getFixedT(locale);\n const dtf = (style?: string) => new Intl.DateTimeFormat(locale, (style && formats.date[style]) || undefined);\n const nf = (style?: string) => new Intl.NumberFormat(locale, (style && formats.number[style]) || undefined);\n const lf = (style?: string) =>\n new Intl.ListFormat(locale, (style && formats.list[style]) || { type: \"conjunction\", style: \"long\" });\n const rtf = () => new Intl.RelativeTimeFormat(locale, { numeric: \"auto\" });\n\n return {\n t(id, values) {\n console.log(inst);\n return t(id, values);\n },\n rich(id, values) {\n return t(id, values);\n },\n formatDate(d, style) {\n return dtf(style).format(d);\n },\n formatNumber(n, style) {\n return nf(style).format(n);\n },\n formatList(items, style) {\n return lf(style).format(items);\n },\n formatRelative(d) {\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 rtf().format(value, unit as Intl.RelativeTimeFormatUnit);\n },\n localDatePlaceholder: formats.localdate.placeholder,\n localDateInputMask: formats.localdate.inputmask,\n localDateFormattedToISO: (str: string) => localDateFormattedToISO(str, formats.localdate.inputmask),\n localDateISOToFormattedInput: (str: string) => localDateISOToFormattedInput(str, formats.localdate.inputmask),\n monthList: getMonthNames(locale),\n getLocale() {\n return locale;\n },\n };\n};\n\nfunction localDateFormattedToISO(str: string, inputMask: string): string {\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\nconst localDateISOToFormattedInput = (str: string, inputMask: string): string => {\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};\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"],"names":["createI18nEngine","locale","messages","formats","inst","i18next","ICU","t","dtf","style","nf","lf","rtf","id","values","d","n","items","diff","abs","unit","value","str","localDateFormattedToISO","localDateISOToFormattedInput","getMonthNames","inputMask","parsed","parse","isDate","isValid","formatISO","result","isString","date","format","formatter","_","i","index"],"mappings":";;;;AAOO,MAAMA,IAAmB,CAACC,GAAgBC,GAAoBC,MAA2B;AAC9F,QAAMC,IAAOC,EAAQ,eAAA;AACrB,EAAAD,EAAK,IAAIE,CAAG,EAAE,KAAK;AAAA,IACjB,OAAO;AAAA,IACP,KAAKL;AAAA,IACL,WAAW,EAAE,CAACA,CAAM,GAAG,EAAE,aAAaC,IAAS;AAAA,IAC/C,eAAe,EAAE,aA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