@seij/common-ui 0.1.2 → 0.1.4
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 +87 -86
- package/dist/init/SeijUIProvider.d.ts.map +1 -1
- package/dist/init/SeijUIProvider.js +8 -8
- package/dist/init/SeijUIProvider.js.map +1 -1
- package/dist/lib/i18n/i18n.react.d.ts +2 -11
- package/dist/lib/i18n/i18n.react.d.ts.map +1 -1
- package/dist/lib/i18n/i18n.react.js +29 -23
- package/dist/lib/i18n/i18n.react.js.map +1 -1
- package/dist/lib/i18n/i18n.service.d.ts +28 -0
- package/dist/lib/i18n/i18n.service.d.ts.map +1 -0
- package/dist/lib/i18n/i18n.service.js +69 -0
- package/dist/lib/i18n/i18n.service.js.map +1 -0
- package/dist/lib/i18n/i18n.types.d.ts +4 -3
- package/dist/lib/i18n/i18n.types.d.ts.map +1 -1
- package/dist/lib/i18n/index.d.ts +1 -1
- package/dist/lib/i18n/index.d.ts.map +1 -1
- package/dist/lib/localdate/InputLocalDate.js +1 -1
- package/dist/lib/localdate/InputLocalDate.js.map +1 -1
- package/dist/lib/month/InputMonth.js +1 -1
- package/dist/lib/month/InputMonth.js.map +1 -1
- package/package.json +8 -8
- package/dist/lib/i18n/i18n.factory.d.ts +0 -3
- package/dist/lib/i18n/i18n.factory.d.ts.map +0 -1
- package/dist/lib/i18n/i18n.factory.js +0 -70
- package/dist/lib/i18n/i18n.factory.js.map +0 -1
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
|
|
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
|
|
9
|
-
import { DataTableDynamic as
|
|
10
|
-
import { ErrorManager as P, useErrorNotifier as
|
|
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
|
|
13
|
-
import {
|
|
14
|
-
import { I18nProvider as
|
|
15
|
-
import { InfoBox as
|
|
16
|
-
import { InlineEdit as
|
|
17
|
-
import { ListView as
|
|
18
|
-
import { Loader as
|
|
19
|
-
import { InputLocalDate as
|
|
20
|
-
import { LabelLocalDate as
|
|
21
|
-
import { InputMoneyDec as
|
|
22
|
-
import { InputMoneyInt as
|
|
23
|
-
import { LabelMoneyDec as
|
|
24
|
-
import { LabelMoneyInt as
|
|
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
|
|
27
|
-
import { Navigation as
|
|
28
|
-
import { INPUT_AMOUNT_ALLOWED_DECIMAL_SEPARATORS as
|
|
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
|
|
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
|
|
33
|
-
import { LabelPercentInt as
|
|
34
|
-
import { InputCombobox as
|
|
35
|
-
import { InputSelect as
|
|
36
|
-
import { SwitchButton as
|
|
37
|
-
import { Tabs as
|
|
38
|
-
import { InputText as
|
|
39
|
-
import { Description as
|
|
40
|
-
import { LabelAndDescription as
|
|
41
|
-
import { Todo as
|
|
42
|
-
import { SectionTitle as
|
|
43
|
-
import { ViewBody as
|
|
44
|
-
import { ViewFooter as
|
|
45
|
-
import { ViewHeader as
|
|
46
|
-
import { ViewLayout as
|
|
47
|
-
import { ViewTitle as
|
|
48
|
-
import { InputDurationYears as
|
|
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
|
-
|
|
54
|
+
n as ButtonBar,
|
|
55
55
|
b as CommonUi,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
64
|
-
|
|
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
|
-
|
|
69
|
+
v as FormLayoutTable,
|
|
70
70
|
h as FormSectionTitle,
|
|
71
71
|
R as FormText,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
87
|
+
yo as InputNumberInt,
|
|
86
88
|
Bo as InputPercent,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
Vo as InputSelect,
|
|
90
|
+
Yo as InputText,
|
|
89
91
|
fr as InputYear,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
qo as LabelAndDescription,
|
|
93
|
+
$ as LabelLocalDate,
|
|
94
|
+
ao as LabelMoneyDec,
|
|
95
|
+
xo as LabelMoneyInt,
|
|
94
96
|
wo as LabelPercent,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
116
|
-
|
|
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,
|
|
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
|
|
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
|
|
5
|
-
const
|
|
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
|
|
12
|
-
return /* @__PURE__ */
|
|
13
|
-
|
|
14
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
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
|
|
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 {
|
|
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
|
|
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,
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { normalize as
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
}, [
|
|
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
|
|
21
|
-
const
|
|
22
|
-
if (!
|
|
23
|
-
return
|
|
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
|
-
|
|
27
|
-
|
|
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
|
|
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,28 @@
|
|
|
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
|
+
registerNamespace: (key: string, resources: Record<string, any>) => void;
|
|
26
|
+
}
|
|
27
|
+
export declare const I18nServiceInstance: I18nService;
|
|
28
|
+
//# 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;cAWqC,MAAM;eAAS,MAAM;QATlE;IAED,iBAAiB,GAAI,KAAK,MAAM,EAAE,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,IAAI,CAItE;CACF;AAQD,eAAO,MAAM,mBAAmB,aAAoB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
registerNamespace = (t, e) => {
|
|
56
|
+
for (const a of Object.keys(e))
|
|
57
|
+
n.addResources(a, t, e[a]);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function M(o) {
|
|
61
|
+
const t = new Intl.DateTimeFormat(o, { month: "long" });
|
|
62
|
+
return Array.from({ length: 12 }, (a, r) => t.format(new Date(2e3, r, 1))).map((a, r) => ({ code: r + 1, label: a }));
|
|
63
|
+
}
|
|
64
|
+
const S = new D();
|
|
65
|
+
export {
|
|
66
|
+
D as I18nService,
|
|
67
|
+
S as I18nServiceInstance
|
|
68
|
+
};
|
|
69
|
+
//# 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 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,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,MACDR,EAAgB,aAAa,OAAOI,EAAG,UAAUC,EAAG;AAAA,EAG7D,WAAW,MACFL,EAAgB;AAAA,EAGzB,MAAM,CAACS,MACE,IAAI,KAAK,eAAe,KAAK,SAAA,GAAaA,KAAS,KAAK,QAAA,EAAU,KAAKA,CAAK,KAAM,MAAS;AAAA,EAGpG,KAAK,CAACA,MACG,IAAI,KAAK,aAAa,KA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G,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,MAAA9B,EAAgB,aAAa+B,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;"}
|
|
@@ -15,14 +15,15 @@ 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
|
}[];
|
|
26
26
|
getLocale(): string;
|
|
27
|
+
registerNamespace(key: string, resources: Record<string, any>): void;
|
|
27
28
|
}
|
|
28
29
|
//# sourceMappingURL=i18n.types.d.ts.map
|
|
@@ -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,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AM,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;IACpB,iBAAiB,CAAC,GAAG,EAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAA;CACpE"}
|
package/dist/lib/i18n/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/i18n/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,
|
|
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 +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,CAACD,MACHD,EAAYC,CAAM,EACZ,MAAM,EAAE,EAChB,OAAO,CAACE,GAAGC,GAAGC,MAAWA,MAAU,KAAKA,MAAU,IAAI,GAAGF,CAAC,IAAIC,CAAC,KAAK,GAAGD,CAAC,GAAGC,CAAC,IAAK,EAAE,EAAE,OAAO,GAAG,EAAE,GAG1GE,IAAuB,CAACL,MAA2B;AACvD,QAAMM,IAAML,EAAWD,CAAM;AAE7B,MAAIA,EAAO,SAAS,GAAG,GAAG;AACxB,QAAIM,EAAI,WAAW;AACjB,aAAO,GAAGA,CAAG;AAGf,QAAIA,EAAI,WAAW;AACjB,aAAO,GAAGA,CAAG;AAAA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GO;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;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,CAACD,MACHD,EAAYC,CAAM,EACZ,MAAM,EAAE,EAChB,OAAO,CAACE,GAAGC,GAAGC,MAAWA,MAAU,KAAKA,MAAU,IAAI,GAAGF,CAAC,IAAIC,CAAC,KAAK,GAAGD,CAAC,GAAGC,CAAC,IAAK,EAAE,EAAE,OAAO,GAAG,EAAE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UM;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,
|
|
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.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
"url": "https://github.com/seij-net/seij-commons-js.git"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@fluentui/react-components": "9.72.9",
|
|
12
11
|
"@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",
|
|
17
13
|
"date-fns": "4.1.0",
|
|
18
|
-
"
|
|
14
|
+
"@fluentui/react-components": "9.72.9",
|
|
15
|
+
"i18next-icu": "2.4.1",
|
|
16
|
+
"lodash-es": "4.17.22",
|
|
17
|
+
"rifm": "0.12.1",
|
|
18
|
+
"i18next": "25.7.3"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/lodash-es": "4.17.12"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"react
|
|
25
|
-
"react": "19.2.3"
|
|
24
|
+
"react": "19.2.3",
|
|
25
|
+
"react-dom": "19.2.3"
|
|
26
26
|
},
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
@@ -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,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