@seij/common-ui 0.0.1
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/LICENSE +201 -0
- package/README.md +7 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +113 -0
- package/dist/index.js.map +1 -0
- package/dist/init/SeijUIProvider.d.ts +15 -0
- package/dist/init/SeijUIProvider.d.ts.map +1 -0
- package/dist/init/SeijUIProvider.js +20 -0
- package/dist/init/SeijUIProvider.js.map +1 -0
- package/dist/lib/applicationshell/ApplicationShell.d.ts +13 -0
- package/dist/lib/applicationshell/ApplicationShell.d.ts.map +1 -0
- package/dist/lib/applicationshell/ApplicationShell.js +110 -0
- package/dist/lib/applicationshell/ApplicationShell.js.map +1 -0
- package/dist/lib/applicationshell/ApplicationShell.types.d.ts +9 -0
- package/dist/lib/applicationshell/ApplicationShell.types.d.ts.map +1 -0
- package/dist/lib/applicationshell/TitleBar.d.ts +9 -0
- package/dist/lib/applicationshell/TitleBar.d.ts.map +1 -0
- package/dist/lib/applicationshell/TitleBar.js +100 -0
- package/dist/lib/applicationshell/TitleBar.js.map +1 -0
- package/dist/lib/badge/Badge.d.ts +5 -0
- package/dist/lib/badge/Badge.d.ts.map +1 -0
- package/dist/lib/badge/Badge.js +9 -0
- package/dist/lib/badge/Badge.js.map +1 -0
- package/dist/lib/button/Button.d.ts +16 -0
- package/dist/lib/button/Button.d.ts.map +1 -0
- package/dist/lib/button/Button.js +15 -0
- package/dist/lib/button/Button.js.map +1 -0
- package/dist/lib/button_bar/ButtonBar.d.ts +5 -0
- package/dist/lib/button_bar/ButtonBar.d.ts.map +1 -0
- package/dist/lib/button_bar/ButtonBar.js +26 -0
- package/dist/lib/button_bar/ButtonBar.js.map +1 -0
- package/dist/lib/common-ui.d.ts +5 -0
- package/dist/lib/common-ui.d.ts.map +1 -0
- package/dist/lib/common-ui.js +9 -0
- package/dist/lib/common-ui.js.map +1 -0
- package/dist/lib/commons/currencysymbol.d.ts +2 -0
- package/dist/lib/commons/currencysymbol.d.ts.map +1 -0
- package/dist/lib/commons/currencysymbol.js +15 -0
- package/dist/lib/commons/currencysymbol.js.map +1 -0
- package/dist/lib/commons/obfuscatelabel.d.ts +17 -0
- package/dist/lib/commons/obfuscatelabel.d.ts.map +1 -0
- package/dist/lib/commons/obfuscatelabel.js +23 -0
- package/dist/lib/commons/obfuscatelabel.js.map +1 -0
- package/dist/lib/data_table/DataTable.d.ts +32 -0
- package/dist/lib/data_table/DataTable.d.ts.map +1 -0
- package/dist/lib/data_table/DataTable.js +40 -0
- package/dist/lib/data_table/DataTable.js.map +1 -0
- package/dist/lib/datatabledynamic/DataTableDynamic.d.ts +14 -0
- package/dist/lib/datatabledynamic/DataTableDynamic.d.ts.map +1 -0
- package/dist/lib/datatabledynamic/DataTableDynamic.js +18 -0
- package/dist/lib/datatabledynamic/DataTableDynamic.js.map +1 -0
- package/dist/lib/devise/DeviseContext.d.ts +2 -0
- package/dist/lib/devise/DeviseContext.d.ts.map +1 -0
- package/dist/lib/devise/DeviseContext.js +6 -0
- package/dist/lib/devise/DeviseContext.js.map +1 -0
- package/dist/lib/error_notifier/ErrorNotifier.d.ts +6 -0
- package/dist/lib/error_notifier/ErrorNotifier.d.ts.map +1 -0
- package/dist/lib/error_notifier/ErrorNotifier.js +29 -0
- package/dist/lib/error_notifier/ErrorNotifier.js.map +1 -0
- package/dist/lib/errorbox/ErrorBox.d.ts +6 -0
- package/dist/lib/errorbox/ErrorBox.d.ts.map +1 -0
- package/dist/lib/errorbox/ErrorBox.js +26 -0
- package/dist/lib/errorbox/ErrorBox.js.map +1 -0
- package/dist/lib/form_layout/FormLayout.d.ts +23 -0
- package/dist/lib/form_layout/FormLayout.d.ts.map +1 -0
- package/dist/lib/form_layout/FormLayout.js +102 -0
- package/dist/lib/form_layout/FormLayout.js.map +1 -0
- package/dist/lib/i18n/i18n.detect.d.ts +10 -0
- package/dist/lib/i18n/i18n.detect.d.ts.map +1 -0
- package/dist/lib/i18n/i18n.detect.js +30 -0
- package/dist/lib/i18n/i18n.detect.js.map +1 -0
- package/dist/lib/i18n/i18n.factory.d.ts +3 -0
- package/dist/lib/i18n/i18n.factory.d.ts.map +1 -0
- package/dist/lib/i18n/i18n.factory.js +70 -0
- package/dist/lib/i18n/i18n.factory.js.map +1 -0
- package/dist/lib/i18n/i18n.react.d.ts +19 -0
- package/dist/lib/i18n/i18n.react.d.ts.map +1 -0
- package/dist/lib/i18n/i18n.react.js +29 -0
- package/dist/lib/i18n/i18n.react.js.map +1 -0
- package/dist/lib/i18n/i18n.types.d.ts +28 -0
- package/dist/lib/i18n/i18n.types.d.ts.map +1 -0
- package/dist/lib/i18n/index.d.ts +3 -0
- package/dist/lib/i18n/index.d.ts.map +1 -0
- package/dist/lib/info_box/InfoBox.d.ts +7 -0
- package/dist/lib/info_box/InfoBox.d.ts.map +1 -0
- package/dist/lib/info_box/InfoBox.js +13 -0
- package/dist/lib/info_box/InfoBox.js.map +1 -0
- package/dist/lib/inlineedit/InlineEdit.d.ts +9 -0
- package/dist/lib/inlineedit/InlineEdit.d.ts.map +1 -0
- package/dist/lib/inlineedit/InlineEdit.js +47 -0
- package/dist/lib/inlineedit/InlineEdit.js.map +1 -0
- package/dist/lib/listview/ListView.d.ts +16 -0
- package/dist/lib/listview/ListView.d.ts.map +1 -0
- package/dist/lib/listview/ListView.js +100 -0
- package/dist/lib/listview/ListView.js.map +1 -0
- package/dist/lib/loader/Loader.d.ts +4 -0
- package/dist/lib/loader/Loader.d.ts.map +1 -0
- package/dist/lib/loader/Loader.js +9 -0
- package/dist/lib/loader/Loader.js.map +1 -0
- package/dist/lib/localdate/InputLocalDate.d.ts +17 -0
- package/dist/lib/localdate/InputLocalDate.d.ts.map +1 -0
- package/dist/lib/localdate/InputLocalDate.js +61 -0
- package/dist/lib/localdate/InputLocalDate.js.map +1 -0
- package/dist/lib/localdate/LabelLocalDate.d.ts +6 -0
- package/dist/lib/localdate/LabelLocalDate.d.ts.map +1 -0
- package/dist/lib/localdate/LabelLocalDate.js +9 -0
- package/dist/lib/localdate/LabelLocalDate.js.map +1 -0
- package/dist/lib/money/InputMoneyDec.d.ts +20 -0
- package/dist/lib/money/InputMoneyDec.d.ts.map +1 -0
- package/dist/lib/money/InputMoneyDec.js +24 -0
- package/dist/lib/money/InputMoneyDec.js.map +1 -0
- package/dist/lib/money/InputMoneyInt.d.ts +24 -0
- package/dist/lib/money/InputMoneyInt.d.ts.map +1 -0
- package/dist/lib/money/InputMoneyInt.js +24 -0
- package/dist/lib/money/InputMoneyInt.js.map +1 -0
- package/dist/lib/money/LabelMoneyDec.d.ts +33 -0
- package/dist/lib/money/LabelMoneyDec.d.ts.map +1 -0
- package/dist/lib/money/LabelMoneyDec.js +22 -0
- package/dist/lib/money/LabelMoneyDec.js.map +1 -0
- package/dist/lib/money/LabelMoneyInt.d.ts +33 -0
- package/dist/lib/money/LabelMoneyInt.d.ts.map +1 -0
- package/dist/lib/money/LabelMoneyInt.js +22 -0
- package/dist/lib/money/LabelMoneyInt.js.map +1 -0
- package/dist/lib/month/InputDurationMonths.d.ts +9 -0
- package/dist/lib/month/InputDurationMonths.d.ts.map +1 -0
- package/dist/lib/month/InputDurationMonths.js +22 -0
- package/dist/lib/month/InputDurationMonths.js.map +1 -0
- package/dist/lib/month/InputMonth.d.ts +13 -0
- package/dist/lib/month/InputMonth.d.ts.map +1 -0
- package/dist/lib/month/InputMonth.js +15 -0
- package/dist/lib/month/InputMonth.js.map +1 -0
- package/dist/lib/navigation/Navigation.d.ts +9 -0
- package/dist/lib/navigation/Navigation.d.ts.map +1 -0
- package/dist/lib/navigation/Navigation.js +38 -0
- package/dist/lib/navigation/Navigation.js.map +1 -0
- package/dist/lib/navigation/Navigation.types.d.ts +48 -0
- package/dist/lib/navigation/Navigation.types.d.ts.map +1 -0
- package/dist/lib/navigation/NavigationService.d.ts +8 -0
- package/dist/lib/navigation/NavigationService.d.ts.map +1 -0
- package/dist/lib/navigation/NavigationService.js +13 -0
- package/dist/lib/navigation/NavigationService.js.map +1 -0
- package/dist/lib/number/InputNumber.d.ts +22 -0
- package/dist/lib/number/InputNumber.d.ts.map +1 -0
- package/dist/lib/number/InputNumber.js +82 -0
- package/dist/lib/number/InputNumber.js.map +1 -0
- package/dist/lib/number/InputNumberDec.d.ts +16 -0
- package/dist/lib/number/InputNumberDec.d.ts.map +1 -0
- package/dist/lib/number/InputNumberDec.js +21 -0
- package/dist/lib/number/InputNumberDec.js.map +1 -0
- package/dist/lib/number/InputNumberInt.d.ts +19 -0
- package/dist/lib/number/InputNumberInt.d.ts.map +1 -0
- package/dist/lib/number/InputNumberInt.js +21 -0
- package/dist/lib/number/InputNumberInt.js.map +1 -0
- package/dist/lib/number/index.d.ts +4 -0
- package/dist/lib/number/index.d.ts.map +1 -0
- package/dist/lib/percent/InputPercent.d.ts +9 -0
- package/dist/lib/percent/InputPercent.d.ts.map +1 -0
- package/dist/lib/percent/InputPercent.js +29 -0
- package/dist/lib/percent/InputPercent.js.map +1 -0
- package/dist/lib/percent/LabelPercent.d.ts +8 -0
- package/dist/lib/percent/LabelPercent.d.ts.map +1 -0
- package/dist/lib/percent/LabelPercent.js +9 -0
- package/dist/lib/percent/LabelPercent.js.map +1 -0
- package/dist/lib/percent/LabelPercentInt.d.ts +4 -0
- package/dist/lib/percent/LabelPercentInt.d.ts.map +1 -0
- package/dist/lib/percent/LabelPercentInt.js +10 -0
- package/dist/lib/percent/LabelPercentInt.js.map +1 -0
- package/dist/lib/select/InputCombobox.d.ts +49 -0
- package/dist/lib/select/InputCombobox.d.ts.map +1 -0
- package/dist/lib/select/InputCombobox.js +42 -0
- package/dist/lib/select/InputCombobox.js.map +1 -0
- package/dist/lib/select/InputSelect.d.ts +22 -0
- package/dist/lib/select/InputSelect.d.ts.map +1 -0
- package/dist/lib/select/InputSelect.js +31 -0
- package/dist/lib/select/InputSelect.js.map +1 -0
- package/dist/lib/switchbutton/SwitchButton.d.ts +9 -0
- package/dist/lib/switchbutton/SwitchButton.d.ts.map +1 -0
- package/dist/lib/switchbutton/SwitchButton.js +18 -0
- package/dist/lib/switchbutton/SwitchButton.js.map +1 -0
- package/dist/lib/tabs/Tabs.d.ts +18 -0
- package/dist/lib/tabs/Tabs.d.ts.map +1 -0
- package/dist/lib/tabs/Tabs.js +30 -0
- package/dist/lib/tabs/Tabs.js.map +1 -0
- package/dist/lib/tabs/index.d.ts +2 -0
- package/dist/lib/tabs/index.d.ts.map +1 -0
- package/dist/lib/text/InputText.d.ts +12 -0
- package/dist/lib/text/InputText.d.ts.map +1 -0
- package/dist/lib/text/InputText.js +32 -0
- package/dist/lib/text/InputText.js.map +1 -0
- package/dist/lib/typography/description/Description.d.ts +4 -0
- package/dist/lib/typography/description/Description.d.ts.map +1 -0
- package/dist/lib/typography/description/Description.js +9 -0
- package/dist/lib/typography/description/Description.js.map +1 -0
- package/dist/lib/typography/description/index.d.ts +2 -0
- package/dist/lib/typography/description/index.d.ts.map +1 -0
- package/dist/lib/typography/index.d.ts +5 -0
- package/dist/lib/typography/index.d.ts.map +1 -0
- package/dist/lib/typography/label_and_description/LabelAndDescription.d.ts +5 -0
- package/dist/lib/typography/label_and_description/LabelAndDescription.d.ts.map +1 -0
- package/dist/lib/typography/label_and_description/LabelAndDescription.js +16 -0
- package/dist/lib/typography/label_and_description/LabelAndDescription.js.map +1 -0
- package/dist/lib/typography/label_and_description/index.d.ts +2 -0
- package/dist/lib/typography/label_and_description/index.d.ts.map +1 -0
- package/dist/lib/typography/sectiontitle/SectionTitle.d.ts +5 -0
- package/dist/lib/typography/sectiontitle/SectionTitle.d.ts.map +1 -0
- package/dist/lib/typography/sectiontitle/SectionTitle.js +8 -0
- package/dist/lib/typography/sectiontitle/SectionTitle.js.map +1 -0
- package/dist/lib/typography/todo/Todo.d.ts +5 -0
- package/dist/lib/typography/todo/Todo.d.ts.map +1 -0
- package/dist/lib/typography/todo/Todo.js +7 -0
- package/dist/lib/typography/todo/Todo.js.map +1 -0
- package/dist/lib/view_layout/ViewBody.d.ts +8 -0
- package/dist/lib/view_layout/ViewBody.d.ts.map +1 -0
- package/dist/lib/view_layout/ViewBody.js +8 -0
- package/dist/lib/view_layout/ViewBody.js.map +1 -0
- package/dist/lib/view_layout/ViewFooter.d.ts +10 -0
- package/dist/lib/view_layout/ViewFooter.d.ts.map +1 -0
- package/dist/lib/view_layout/ViewFooter.js +8 -0
- package/dist/lib/view_layout/ViewFooter.js.map +1 -0
- package/dist/lib/view_layout/ViewHeader.d.ts +5 -0
- package/dist/lib/view_layout/ViewHeader.d.ts.map +1 -0
- package/dist/lib/view_layout/ViewHeader.js +8 -0
- package/dist/lib/view_layout/ViewHeader.js.map +1 -0
- package/dist/lib/view_layout/ViewLayout.d.ts +16 -0
- package/dist/lib/view_layout/ViewLayout.d.ts.map +1 -0
- package/dist/lib/view_layout/ViewLayout.js +127 -0
- package/dist/lib/view_layout/ViewLayout.js.map +1 -0
- package/dist/lib/view_layout/ViewTitle.d.ts +21 -0
- package/dist/lib/view_layout/ViewTitle.d.ts.map +1 -0
- package/dist/lib/view_layout/ViewTitle.js +71 -0
- package/dist/lib/view_layout/ViewTitle.js.map +1 -0
- package/dist/lib/year/InputDurationYears.d.ts +9 -0
- package/dist/lib/year/InputDurationYears.d.ts.map +1 -0
- package/dist/lib/year/InputDurationYears.js +22 -0
- package/dist/lib/year/InputDurationYears.js.map +1 -0
- package/dist/lib/year/InputYear.d.ts +9 -0
- package/dist/lib/year/InputYear.d.ts.map +1 -0
- package/dist/lib/year/InputYear.js +21 -0
- package/dist/lib/year/InputYear.js.map +1 -0
- package/dist/locales/en.d.ts +8 -0
- package/dist/locales/en.d.ts.map +1 -0
- package/dist/locales/en.js +41 -0
- package/dist/locales/en.js.map +1 -0
- package/dist/locales/fr.d.ts +8 -0
- package/dist/locales/fr.d.ts.map +1 -0
- package/dist/locales/fr.js +41 -0
- package/dist/locales/fr.js.map +1 -0
- package/dist/locales/interfaces.d.ts +11 -0
- package/dist/locales/interfaces.d.ts.map +1 -0
- package/dist/stories/utils/SeijUIProviderDecorator.d.ts +2 -0
- package/dist/stories/utils/SeijUIProviderDecorator.d.ts.map +1 -0
- package/dist/stories/utils/StoryComponentFrame.d.ts +11 -0
- package/dist/stories/utils/StoryComponentFrame.d.ts.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
export type FormLayoutType = "fluid" | "table";
|
|
3
|
+
export declare function FormLayout({ children, variant }: {
|
|
4
|
+
variant?: FormLayoutType;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function FormLayoutTable({ children }: {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export type FormFieldHintPosition = "inline" | "infobutton";
|
|
11
|
+
export declare function FormField({ label, hint, children, hintPosition, }: {
|
|
12
|
+
label: string | ReactNode;
|
|
13
|
+
hint?: ReactNode;
|
|
14
|
+
children: ReactElement;
|
|
15
|
+
hintPosition?: FormFieldHintPosition;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function FormSectionTitle({ children }: {
|
|
18
|
+
children: ReactNode | ReactNode[];
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function FormText({ children }: {
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
//# sourceMappingURL=FormLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormLayout.d.ts","sourceRoot":"","sources":["../../../src/lib/form_layout/FormLayout.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,YAAY,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAoB3E,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,CAAC;AAM/C,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,OAAiB,EAAE,EAAE;IAAE,OAAO,CAAC,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAS5G;AAED,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAEpE;AAMD,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,YAAY,CAAC;AAU5D,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,YAA2B,GAC5B,EAAE;IACD,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,YAAY,CAAC;IACvB,YAAY,CAAC,EAAE,qBAAqB,CAAC;CACtC,2CA+CA;AAqDD,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,GAAG,SAAS,EAAE,CAAA;CAAE,2CAMnF;AAKD,wBAAgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAM7D"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { jsx as o, jsxs as l, Fragment as y } from "react/jsx-runtime";
|
|
2
|
+
import { makeStyles as p, tokens as i, typographyStyles as m, makeResetStyles as F, InfoLabel as S } from "@fluentui/react-components";
|
|
3
|
+
import { isString as h, isEmpty as v } from "lodash-es";
|
|
4
|
+
import { createContext as x, useContext as b } from "react";
|
|
5
|
+
import { obfuscateLabel as z } from "../commons/obfuscatelabel.js";
|
|
6
|
+
import { SectionTitle as T } from "../typography/sectiontitle/SectionTitle.js";
|
|
7
|
+
import { SwitchButton as B } from "../switchbutton/SwitchButton.js";
|
|
8
|
+
const L = p({
|
|
9
|
+
fluid: {
|
|
10
|
+
display: "flex",
|
|
11
|
+
flexDirection: "column",
|
|
12
|
+
columnGap: i.spacingHorizontalM,
|
|
13
|
+
rowGap: i.spacingVerticalM
|
|
14
|
+
},
|
|
15
|
+
table: {
|
|
16
|
+
display: "grid",
|
|
17
|
+
gridTemplateColumns: "max-content auto",
|
|
18
|
+
columnGap: i.spacingHorizontalM,
|
|
19
|
+
rowGap: i.spacingVerticalM
|
|
20
|
+
}
|
|
21
|
+
}), f = x({ type: "fluid" });
|
|
22
|
+
function V({ children: t, variant: n = "fluid" }) {
|
|
23
|
+
const e = L(), r = n === "fluid" ? e.fluid : e.table;
|
|
24
|
+
return /* @__PURE__ */ o(f.Provider, { value: { type: n }, children: /* @__PURE__ */ o("div", { className: r, children: t }) });
|
|
25
|
+
}
|
|
26
|
+
function R({ children: t }) {
|
|
27
|
+
return /* @__PURE__ */ o(V, { variant: "table", children: t });
|
|
28
|
+
}
|
|
29
|
+
const X = p({
|
|
30
|
+
childrenFluidArea: {
|
|
31
|
+
"> *": {
|
|
32
|
+
width: "100%"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
function D({
|
|
37
|
+
label: t,
|
|
38
|
+
hint: n,
|
|
39
|
+
children: e,
|
|
40
|
+
hintPosition: r = "infobutton"
|
|
41
|
+
}) {
|
|
42
|
+
const c = b(f), g = X(), s = n && t && r === "infobutton" ? n : null, u = n && (!t || r === "inline") ? /* @__PURE__ */ o(H, { children: n }) : null, d = h(t) && !v(t) ? z(t) : t;
|
|
43
|
+
return c.type === "table" ? /* @__PURE__ */ l(y, { children: [
|
|
44
|
+
/* @__PURE__ */ o(a, { horizontal: !0, infoButton: s, children: d }),
|
|
45
|
+
/* @__PURE__ */ l("div", { children: [
|
|
46
|
+
e,
|
|
47
|
+
u
|
|
48
|
+
] })
|
|
49
|
+
] }) : e && e.type === B ? /* @__PURE__ */ l("div", { style: { display: "grid", gridTemplateColumns: "auto 1fr" }, children: [
|
|
50
|
+
/* @__PURE__ */ o("div", { children: e }),
|
|
51
|
+
/* @__PURE__ */ l("div", { children: [
|
|
52
|
+
/* @__PURE__ */ o(a, { horizontal: !0, infoButton: s, children: d }),
|
|
53
|
+
u
|
|
54
|
+
] })
|
|
55
|
+
] }) : /* @__PURE__ */ l("div", { children: [
|
|
56
|
+
/* @__PURE__ */ o("div", { children: /* @__PURE__ */ o(a, { horizontal: !0, infoButton: s, children: d }) }),
|
|
57
|
+
/* @__PURE__ */ o("div", { className: g.childrenFluidArea, children: e }),
|
|
58
|
+
u
|
|
59
|
+
] });
|
|
60
|
+
}
|
|
61
|
+
const C = p({
|
|
62
|
+
vertical: {
|
|
63
|
+
paddingTop: i.spacingVerticalXXS,
|
|
64
|
+
paddingBottom: i.spacingVerticalXXS,
|
|
65
|
+
marginBottom: i.spacingVerticalXXS,
|
|
66
|
+
...m.body1
|
|
67
|
+
},
|
|
68
|
+
horizontal: {
|
|
69
|
+
paddingTop: i.spacingVerticalSNudge,
|
|
70
|
+
paddingBottom: i.spacingVerticalSNudge,
|
|
71
|
+
marginRight: i.spacingHorizontalM,
|
|
72
|
+
...m.body1
|
|
73
|
+
}
|
|
74
|
+
}), a = ({
|
|
75
|
+
horizontal: t = !1,
|
|
76
|
+
infoButton: n,
|
|
77
|
+
children: e
|
|
78
|
+
}) => {
|
|
79
|
+
const r = C(), c = t ? r.horizontal : r.vertical;
|
|
80
|
+
return n ? /* @__PURE__ */ o(S, { info: n, children: e }) : /* @__PURE__ */ o("div", { className: c, children: e });
|
|
81
|
+
}, N = F({
|
|
82
|
+
marginTop: i.spacingVerticalXXS,
|
|
83
|
+
color: i.colorNeutralForeground3,
|
|
84
|
+
...m.caption1
|
|
85
|
+
}), H = ({ children: t }) => {
|
|
86
|
+
const n = N();
|
|
87
|
+
return /* @__PURE__ */ o("div", { className: n, children: t });
|
|
88
|
+
};
|
|
89
|
+
function E({ children: t }) {
|
|
90
|
+
return /* @__PURE__ */ o("div", { style: { gridColumn: "span 2" }, children: /* @__PURE__ */ o(T, { children: t }) });
|
|
91
|
+
}
|
|
92
|
+
function q({ children: t }) {
|
|
93
|
+
return /* @__PURE__ */ o(a, { infoButton: null, horizontal: !0, children: t });
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
D as FormField,
|
|
97
|
+
V as FormLayout,
|
|
98
|
+
R as FormLayoutTable,
|
|
99
|
+
E as FormSectionTitle,
|
|
100
|
+
q as FormText
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=FormLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormLayout.js","sources":["../../../src/lib/form_layout/FormLayout.tsx"],"sourcesContent":["import { InfoLabel, makeResetStyles, makeStyles, tokens, typographyStyles } from \"@fluentui/react-components\";\nimport { isEmpty, isString } from \"lodash-es\";\nimport { createContext, ReactElement, ReactNode, useContext } from \"react\";\nimport { obfuscateLabel } from \"../commons/obfuscatelabel\";\nimport { SectionTitle } from \"../typography/sectiontitle/SectionTitle\";\nimport { SwitchButton } from \"../switchbutton/SwitchButton\";\n\nconst useStylesFormLayout = makeStyles({\n fluid: {\n display: \"flex\",\n flexDirection: \"column\",\n columnGap: tokens.spacingHorizontalM,\n rowGap: tokens.spacingVerticalM,\n },\n table: {\n display: \"grid\",\n gridTemplateColumns: \"max-content auto\",\n columnGap: tokens.spacingHorizontalM,\n rowGap: tokens.spacingVerticalM,\n },\n});\n\nexport type FormLayoutType = \"fluid\" | \"table\";\ntype FormLayoutCtxProps = {\n type: FormLayoutType;\n};\nconst FormLayoutCtx = createContext<FormLayoutCtxProps>({ type: \"fluid\" });\n\nexport function FormLayout({ children, variant = \"fluid\" }: { variant?: FormLayoutType; children: ReactNode }) {\n const style = useStylesFormLayout();\n\n const styles = variant === \"fluid\" ? style.fluid : style.table;\n return (\n <FormLayoutCtx.Provider value={{ type: variant }}>\n <div className={styles}>{children}</div>\n </FormLayoutCtx.Provider>\n );\n}\n\nexport function FormLayoutTable({ children }: { children: ReactNode }) {\n return <FormLayout variant=\"table\">{children}</FormLayout>;\n}\n\n// -----------------------------------------------------------------------------\n// Champ de formulaire\n// -----------------------------------------------------------------------------\n\nexport type FormFieldHintPosition = \"inline\" | \"infobutton\";\n\nconst useFormFieldStyles = makeStyles({\n childrenFluidArea: {\n \"> *\": {\n width: \"100%\",\n },\n },\n});\n\nexport function FormField({\n label,\n hint,\n children,\n hintPosition = \"infobutton\",\n}: {\n label: string | ReactNode;\n hint?: ReactNode;\n children: ReactElement;\n hintPosition?: FormFieldHintPosition;\n}) {\n const ctx = useContext(FormLayoutCtx);\n const styles = useFormFieldStyles();\n const infoButtonContent = hint && label && hintPosition === \"infobutton\" ? hint : null;\n const infoInline = hint && (!label || hintPosition === \"inline\") ? <Hint>{hint}</Hint> : null;\n\n const labelSafe = isString(label) && !isEmpty(label) ? obfuscateLabel(label) : label;\n\n if (ctx.type === \"table\") {\n return (\n <>\n <FormFieldLabel horizontal infoButton={infoButtonContent}>\n {labelSafe}\n </FormFieldLabel>\n <div>\n {children}\n {infoInline}\n </div>\n </>\n );\n }\n\n if (children && children.type === SwitchButton) {\n return (\n <div style={{ display: \"grid\", gridTemplateColumns: \"auto 1fr\" }}>\n <div>{children}</div>\n <div>\n <FormFieldLabel horizontal infoButton={infoButtonContent}>\n {labelSafe}\n </FormFieldLabel>\n {infoInline}\n </div>\n </div>\n );\n }\n\n return (\n <div>\n <div>\n <FormFieldLabel horizontal infoButton={infoButtonContent}>\n {labelSafe}\n </FormFieldLabel>\n </div>\n <div className={styles.childrenFluidArea}>{children}</div>\n {infoInline}\n </div>\n );\n}\n\n// Label d'un champ de formulaire\n// -----------------------------------------------------------------------------\n\nconst useFormFieldLabelStyles = makeStyles({\n vertical: {\n paddingTop: tokens.spacingVerticalXXS,\n paddingBottom: tokens.spacingVerticalXXS,\n marginBottom: tokens.spacingVerticalXXS,\n ...typographyStyles.body1,\n },\n horizontal: {\n paddingTop: tokens.spacingVerticalSNudge,\n paddingBottom: tokens.spacingVerticalSNudge,\n marginRight: tokens.spacingHorizontalM,\n ...typographyStyles.body1,\n },\n});\n\nconst FormFieldLabel = ({\n horizontal = false,\n infoButton,\n children,\n}: {\n horizontal?: boolean;\n infoButton: ReactNode;\n children: ReactNode;\n}) => {\n const styles = useFormFieldLabelStyles();\n const className = horizontal ? styles.horizontal : styles.vertical;\n // return <div className={className}>{children}</div>;\n return infoButton ? <InfoLabel info={infoButton}>{children}</InfoLabel> : <div className={className}>{children}</div>;\n // return <InfoLabel>{children}</InfoLabel>\n};\n\n// Hint d'un champ de formulaire\n// -----------------------------------------------------------------------------\nconst useHintStyle = makeResetStyles({\n marginTop: tokens.spacingVerticalXXS,\n color: tokens.colorNeutralForeground3,\n ...typographyStyles.caption1,\n});\n\nconst Hint = ({ children }: { children: ReactNode }) => {\n const className = useHintStyle();\n return <div className={className}>{children}</div>;\n};\n\n// -----------------------------------------------------------------------------\n// Séparation des formulaires\n// -----------------------------------------------------------------------------\n\nexport function FormSectionTitle({ children }: { children: ReactNode | ReactNode[] }) {\n return (\n <div style={{ gridColumn: \"span 2\" }}>\n <SectionTitle>{children}</SectionTitle>\n </div>\n );\n}\n\n// -----------------------------------------------------------------------------\n// Texte read-ony a la place d'un champ de saisie\n// -----------------------------------------------------------------------------\nexport function FormText({ children }: { children: ReactNode }) {\n return (\n <FormFieldLabel infoButton={null} horizontal>\n {children}\n </FormFieldLabel>\n );\n}\n"],"names":["useStylesFormLayout","makeStyles","tokens","FormLayoutCtx","createContext","FormLayout","children","variant","style","styles","jsx","FormLayoutTable","useFormFieldStyles","FormField","label","hint","hintPosition","ctx","useContext","infoButtonContent","infoInline","Hint","labelSafe","isString","isEmpty","obfuscateLabel","jsxs","Fragment","FormFieldLabel","SwitchButton","useFormFieldLabelStyles","typographyStyles","horizontal","infoButton","className","InfoLabel","useHintStyle","makeResetStyles","FormSectionTitle","SectionTitle","FormText"],"mappings":";;;;;;;AAOA,MAAMA,IAAsBC,EAAW;AAAA,EACrC,OAAO;AAAA,IACL,SAAS;AAAA,IACT,eAAe;AAAA,IACf,WAAWC,EAAO;AAAA,IAClB,QAAQA,EAAO;AAAA,EAAA;AAAA,EAEjB,OAAO;AAAA,IACL,SAAS;AAAA,IACT,qBAAqB;AAAA,IACrB,WAAWA,EAAO;AAAA,IAClB,QAAQA,EAAO;AAAA,EAAA;AAEnB,CAAC,GAMKC,IAAgBC,EAAkC,EAAE,MAAM,SAAS;AAElE,SAASC,EAAW,EAAE,UAAAC,GAAU,SAAAC,IAAU,WAA8D;AAC7G,QAAMC,IAAQR,EAAA,GAERS,IAASF,MAAY,UAAUC,EAAM,QAAQA,EAAM;AACzD,SACE,gBAAAE,EAACP,EAAc,UAAd,EAAuB,OAAO,EAAE,MAAMI,EAAA,GACrC,UAAA,gBAAAG,EAAC,OAAA,EAAI,WAAWD,GAAS,UAAAH,GAAS,GACpC;AAEJ;AAEO,SAASK,EAAgB,EAAE,UAAAL,KAAqC;AACrE,SAAO,gBAAAI,EAACL,GAAA,EAAW,SAAQ,SAAS,UAAAC,EAAA,CAAS;AAC/C;AAQA,MAAMM,IAAqBX,EAAW;AAAA,EACpC,mBAAmB;AAAA,IACjB,OAAO;AAAA,MACL,OAAO;AAAA,IAAA;AAAA,EACT;AAEJ,CAAC;AAEM,SAASY,EAAU;AAAA,EACxB,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAT;AAAA,EACA,cAAAU,IAAe;AACjB,GAKG;AACD,QAAMC,IAAMC,EAAWf,CAAa,GAC9BM,IAASG,EAAA,GACTO,IAAoBJ,KAAQD,KAASE,MAAiB,eAAeD,IAAO,MAC5EK,IAAaL,MAAS,CAACD,KAASE,MAAiB,YAAY,gBAAAN,EAACW,GAAA,EAAM,UAAAN,EAAA,CAAK,IAAU,MAEnFO,IAAYC,EAAST,CAAK,KAAK,CAACU,EAAQV,CAAK,IAAIW,EAAeX,CAAK,IAAIA;AAE/E,SAAIG,EAAI,SAAS,UAEb,gBAAAS,EAAAC,GAAA,EACE,UAAA;AAAA,IAAA,gBAAAjB,EAACkB,GAAA,EAAe,YAAU,IAAC,YAAYT,GACpC,UAAAG,GACH;AAAA,sBACC,OAAA,EACE,UAAA;AAAA,MAAAhB;AAAA,MACAc;AAAA,IAAA,EAAA,CACH;AAAA,EAAA,GACF,IAIAd,KAAYA,EAAS,SAASuB,IAE9B,gBAAAH,EAAC,SAAI,OAAO,EAAE,SAAS,QAAQ,qBAAqB,cAClD,UAAA;AAAA,IAAA,gBAAAhB,EAAC,SAAK,UAAAJ,GAAS;AAAA,sBACd,OAAA,EACC,UAAA;AAAA,MAAA,gBAAAI,EAACkB,GAAA,EAAe,YAAU,IAAC,YAAYT,GACpC,UAAAG,GACH;AAAA,MACCF;AAAA,IAAA,EAAA,CACH;AAAA,EAAA,GACF,sBAKD,OAAA,EACC,UAAA;AAAA,IAAA,gBAAAV,EAAC,OAAA,EACC,4BAACkB,GAAA,EAAe,YAAU,IAAC,YAAYT,GACpC,aACH,EAAA,CACF;AAAA,IACA,gBAAAT,EAAC,OAAA,EAAI,WAAWD,EAAO,mBAAoB,UAAAH,GAAS;AAAA,IACnDc;AAAA,EAAA,GACH;AAEJ;AAKA,MAAMU,IAA0B7B,EAAW;AAAA,EACzC,UAAU;AAAA,IACR,YAAYC,EAAO;AAAA,IACnB,eAAeA,EAAO;AAAA,IACtB,cAAcA,EAAO;AAAA,IACrB,GAAG6B,EAAiB;AAAA,EAAA;AAAA,EAEtB,YAAY;AAAA,IACV,YAAY7B,EAAO;AAAA,IACnB,eAAeA,EAAO;AAAA,IACtB,aAAaA,EAAO;AAAA,IACpB,GAAG6B,EAAiB;AAAA,EAAA;AAExB,CAAC,GAEKH,IAAiB,CAAC;AAAA,EACtB,YAAAI,IAAa;AAAA,EACb,YAAAC;AAAA,EACA,UAAA3B;AACF,MAIM;AACJ,QAAMG,IAASqB,EAAA,GACTI,IAAYF,IAAavB,EAAO,aAAaA,EAAO;AAE1D,SAAOwB,IAAa,gBAAAvB,EAACyB,GAAA,EAAU,MAAMF,GAAa,UAAA3B,GAAS,IAAe,gBAAAI,EAAC,OAAA,EAAI,WAAAwB,GAAuB,UAAA5B,EAAA,CAAS;AAEjH,GAIM8B,IAAeC,EAAgB;AAAA,EACnC,WAAWnC,EAAO;AAAA,EAClB,OAAOA,EAAO;AAAA,EACd,GAAG6B,EAAiB;AACtB,CAAC,GAEKV,IAAO,CAAC,EAAE,UAAAf,QAAwC;AACtD,QAAM4B,IAAYE,EAAA;AAClB,SAAO,gBAAA1B,EAAC,OAAA,EAAI,WAAAwB,GAAuB,UAAA5B,EAAA,CAAS;AAC9C;AAMO,SAASgC,EAAiB,EAAE,UAAAhC,KAAmD;AACpF,SACE,gBAAAI,EAAC,OAAA,EAAI,OAAO,EAAE,YAAY,YACxB,UAAA,gBAAAA,EAAC6B,GAAA,EAAc,UAAAjC,EAAA,CAAS,EAAA,CAC1B;AAEJ;AAKO,SAASkC,EAAS,EAAE,UAAAlC,KAAqC;AAC9D,2BACGsB,GAAA,EAAe,YAAY,MAAM,YAAU,IACzC,UAAAtB,GACH;AAEJ;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Locale = string;
|
|
2
|
+
export declare function normalize(loc?: string): Locale;
|
|
3
|
+
export declare function detectClientLocale(): Locale;
|
|
4
|
+
export declare function detectServerLocale(opts: {
|
|
5
|
+
queryLang?: string | null;
|
|
6
|
+
cookieLang?: string | null;
|
|
7
|
+
acceptLanguage?: string | null;
|
|
8
|
+
}): Locale;
|
|
9
|
+
export declare function setUserLocale(loc: string): string;
|
|
10
|
+
//# sourceMappingURL=i18n.detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.detect.d.ts","sourceRoot":"","sources":["../../../src/lib/i18n/i18n.detect.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAK5B,wBAAgB,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAM9C;AAmBD,wBAAgB,kBAAkB,IAAI,MAAM,CAO3C;AAGD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,GAAG,MAAM,CAGT;AAGD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,UAKxC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const t = ["fr", "en"];
|
|
2
|
+
function r(n) {
|
|
3
|
+
if (!n) return "en";
|
|
4
|
+
const e = n.toLowerCase(), o = e.split("-")[0];
|
|
5
|
+
return t.includes(e) ? e : t.includes(o) ? o : "en";
|
|
6
|
+
}
|
|
7
|
+
function i() {
|
|
8
|
+
var n;
|
|
9
|
+
if (!(typeof navigator > "u"))
|
|
10
|
+
return ((n = navigator.languages) == null ? void 0 : n[0]) || navigator.language;
|
|
11
|
+
}
|
|
12
|
+
function a() {
|
|
13
|
+
if (!(typeof window > "u"))
|
|
14
|
+
return localStorage.getItem("locale") || void 0;
|
|
15
|
+
}
|
|
16
|
+
function u() {
|
|
17
|
+
if (!(typeof window > "u"))
|
|
18
|
+
return new URLSearchParams(window.location.search).get("lang") || void 0;
|
|
19
|
+
}
|
|
20
|
+
function f() {
|
|
21
|
+
return r(
|
|
22
|
+
u() || a() || // fromHtmlLang() ||
|
|
23
|
+
i()
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
f as detectClientLocale,
|
|
28
|
+
r as normalize
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=i18n.detect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.detect.js","sources":["../../../src/lib/i18n/i18n.detect.ts"],"sourcesContent":["// i18n/locale.ts\nexport type Locale = string;\n\nconst SUPPORTED = [\"fr\", \"en\"] as const;\nconst FALLBACK: Locale = \"en\";\n\nexport function normalize(loc?: string): Locale {\n if (!loc) return FALLBACK;\n // garde \"fr-CA\" mais tombe sur \"fr\" si non supporté\n const lc = loc.toLowerCase();\n const base = lc.split(\"-\")[0];\n return SUPPORTED.includes(lc as any) ? (lc as Locale) : SUPPORTED.includes(base as any) ? (base as Locale) : FALLBACK;\n}\n\n// Client-only helpers\nfunction fromHtmlLang(): string | undefined {\n return typeof document !== \"undefined\" ? document.documentElement.lang : undefined;\n}\nfunction fromNavigator(): string | undefined {\n if (typeof navigator === \"undefined\") return undefined;\n return navigator.languages?.[0] || navigator.language;\n}\nfunction fromStorage(): string | undefined {\n if (typeof window === \"undefined\") return undefined;\n return localStorage.getItem(\"locale\") || undefined;\n}\nfunction fromQuery(): string | undefined {\n if (typeof window === \"undefined\") return undefined;\n return new URLSearchParams(window.location.search).get(\"lang\") || undefined;\n}\n\nexport function detectClientLocale(): Locale {\n return normalize(\n fromQuery() ||\n fromStorage() ||\n // fromHtmlLang() ||\n fromNavigator(),\n );\n}\n\n// SSR-side (ex: Next.js route handler / Node middleware)\nexport function detectServerLocale(opts: {\n queryLang?: string | null;\n cookieLang?: string | null;\n acceptLanguage?: string | null;\n}): Locale {\n const fromAL = opts.acceptLanguage?.split(\",\")?.[0]; // ex: \"fr-CA,fr;q=0.9,en;q=0.8\"\n return normalize(opts.queryLang || opts.cookieLang || fromAL);\n}\n\n// Persister le choix utilisateur (client)\nexport function setUserLocale(loc: string) {\n const n = normalize(loc);\n if (typeof document !== \"undefined\") document.documentElement.lang = n;\n if (typeof window !== \"undefined\") localStorage.setItem(\"locale\", n);\n return n;\n}\n"],"names":["SUPPORTED","normalize","loc","lc","base","fromNavigator","_a","fromStorage","fromQuery","detectClientLocale"],"mappings":"AAGA,MAAMA,IAAY,CAAC,MAAM,IAAI;AAGtB,SAASC,EAAUC,GAAsB;AAC9C,MAAI,CAACA,EAAK,QAAO;AAEjB,QAAMC,IAAKD,EAAI,YAAA,GACTE,IAAOD,EAAG,MAAM,GAAG,EAAE,CAAC;AAC5B,SAAOH,EAAU,SAASG,CAAS,IAAKA,IAAgBH,EAAU,SAASI,CAAW,IAAKA,IAAkB;AAC/G;AAMA,SAASC,IAAoC;AAf7C,MAAAC;AAgBE,MAAI,SAAO,YAAc;AACzB,aAAOA,IAAA,UAAU,cAAV,gBAAAA,EAAsB,OAAM,UAAU;AAC/C;AACA,SAASC,IAAkC;AACzC,MAAI,SAAO,SAAW;AACtB,WAAO,aAAa,QAAQ,QAAQ,KAAK;AAC3C;AACA,SAASC,IAAgC;AACvC,MAAI,SAAO,SAAW;AACtB,WAAO,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAAE,IAAI,MAAM,KAAK;AACpE;AAEO,SAASC,IAA6B;AAC3C,SAAOR;AAAA,IACLO,EAAA,KACED,EAAA;AAAA,IAEAF,EAAA;AAAA,EAAc;AAEpB;"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":"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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
}>;
|
|
7
|
+
export interface I18nProviderProps {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
/** SSR hydrate */
|
|
10
|
+
initialLocale?: string;
|
|
11
|
+
/** for tests, storybook, preview */
|
|
12
|
+
forcedLocale?: string;
|
|
13
|
+
/** Lazy loading by locale of messages and formats (promise) */
|
|
14
|
+
load: Loader;
|
|
15
|
+
}
|
|
16
|
+
export declare function I18nProvider({ children, initialLocale, forcedLocale, load }: I18nProviderProps): string | import("react/jsx-runtime").JSX.Element | null;
|
|
17
|
+
export declare function useI18n(): I18n;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=i18n.react.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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));
|
|
17
|
+
});
|
|
18
|
+
}, [e, s]), a ? "Could not load locale " + e : u ? /* @__PURE__ */ f(m.Provider, { value: u, children: t }) : null;
|
|
19
|
+
}
|
|
20
|
+
function M() {
|
|
21
|
+
const t = v(m);
|
|
22
|
+
if (!t) throw new Error("useI18n must be used within I18nProvider");
|
|
23
|
+
return t;
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
z as I18nProvider,
|
|
27
|
+
M as useI18n
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=i18n.react.js.map
|
|
@@ -0,0 +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;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type Messages = Record<string, string>;
|
|
2
|
+
export type Formats = {
|
|
3
|
+
localdate: {
|
|
4
|
+
placeholder: string;
|
|
5
|
+
inputmask: string;
|
|
6
|
+
};
|
|
7
|
+
date: Record<string, Intl.DateTimeFormatOptions>;
|
|
8
|
+
number: Record<string, Intl.NumberFormatOptions>;
|
|
9
|
+
list: Record<string, Intl.ListFormatOptions>;
|
|
10
|
+
};
|
|
11
|
+
export interface I18n {
|
|
12
|
+
t(id: string, values?: Record<string, unknown>): string;
|
|
13
|
+
rich(id: string, values?: Record<string, unknown | ((chunks: string) => React.ReactNode)>): React.ReactNode;
|
|
14
|
+
formatDate(d: Date | number, style?: string): string;
|
|
15
|
+
formatNumber(n: number, style?: string): string;
|
|
16
|
+
formatList(items: string[], style?: string): string;
|
|
17
|
+
formatRelative(d: Date | number): string;
|
|
18
|
+
localDatePlaceholder: string;
|
|
19
|
+
localDateInputMask: string;
|
|
20
|
+
localDateFormattedToISO: (str: string) => string;
|
|
21
|
+
localDateISOToFormattedInput: (str: string) => string;
|
|
22
|
+
monthList: {
|
|
23
|
+
code: number;
|
|
24
|
+
label: string;
|
|
25
|
+
}[];
|
|
26
|
+
getLocale(): string;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=i18n.types.d.ts.map
|
|
@@ -0,0 +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,GAAG,MAAM,CAAC;IACpD,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IACzC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,uBAAuB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACjD,4BAA4B,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACtD,SAAS,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC7C,SAAS,IAAI,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export declare function InfoBox({ children, intent, className, }: {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
intent: "info" | "warning" | "error" | "success";
|
|
5
|
+
className?: string;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=InfoBox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfoBox.d.ts","sourceRoot":"","sources":["../../../src/lib/info_box/InfoBox.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,wBAAgB,OAAO,CAAC,EACtB,QAAQ,EACR,MAAM,EACN,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAMA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { MessageBar as s, MessageBarBody as t } from "@fluentui/react-components";
|
|
3
|
+
function i({
|
|
4
|
+
children: o,
|
|
5
|
+
intent: e,
|
|
6
|
+
className: n
|
|
7
|
+
}) {
|
|
8
|
+
return /* @__PURE__ */ r(s, { intent: e, className: n, children: /* @__PURE__ */ r(t, { children: o }) });
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
i as InfoBox
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=InfoBox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfoBox.js","sources":["../../../src/lib/info_box/InfoBox.tsx"],"sourcesContent":["import { MessageBar, MessageBarBody } from \"@fluentui/react-components\";\nimport { ReactNode } from \"react\";\n\nexport function InfoBox({\n children,\n intent,\n className,\n}: {\n children: ReactNode;\n intent: \"info\" | \"warning\" | \"error\" | \"success\";\n className?: string;\n}) {\n return (\n <MessageBar intent={intent} className={className}>\n <MessageBarBody>{children}</MessageBarBody>\n </MessageBar>\n );\n}\n"],"names":["InfoBox","children","intent","className","MessageBar","jsx","MessageBarBody"],"mappings":";;AAGO,SAASA,EAAQ;AAAA,EACtB,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AACF,GAIG;AACD,2BACGC,GAAA,EAAW,QAAAF,GAAgB,WAAAC,GAC1B,UAAA,gBAAAE,EAACC,GAAA,EAAgB,UAAAL,GAAS,EAAA,CAC5B;AAEJ;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export declare function InlineEdit({ children, editor, onEditStart, onEditOK, onEditCancel, }: {
|
|
3
|
+
children?: ReactNode | ReactNode[] | null;
|
|
4
|
+
editor: ReactNode;
|
|
5
|
+
onEditStart: () => Promise<any>;
|
|
6
|
+
onEditOK: () => Promise<any>;
|
|
7
|
+
onEditCancel: () => Promise<any>;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=InlineEdit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InlineEdit.d.ts","sourceRoot":"","sources":["../../../src/lib/inlineedit/InlineEdit.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAK5C,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,MAAM,EACN,WAAW,EACX,QAAQ,EACR,YAAY,GACb,EAAE;IACD,QAAQ,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,GAAG,IAAI,CAAC;IAC1C,MAAM,EAAE,SAAS,CAAC;IAClB,WAAW,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;IAChC,QAAQ,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7B,YAAY,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;CAClC,2CAsEA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsxs as r, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useState as d } from "react";
|
|
3
|
+
import { Tooltip as E, Button as a } from "@fluentui/react-components";
|
|
4
|
+
import { toProblem as s } from "@seij/common-types";
|
|
5
|
+
import { EditRegular as g } from "@fluentui/react-icons";
|
|
6
|
+
function O({
|
|
7
|
+
children: f,
|
|
8
|
+
editor: h,
|
|
9
|
+
onEditStart: u,
|
|
10
|
+
onEditOK: y,
|
|
11
|
+
onEditCancel: m
|
|
12
|
+
}) {
|
|
13
|
+
const [p, n] = d(!1), [c, t] = d(null), [o, i] = d(!1), v = async () => {
|
|
14
|
+
try {
|
|
15
|
+
t(null), await u(), n(!0);
|
|
16
|
+
} catch (l) {
|
|
17
|
+
t(s(l));
|
|
18
|
+
}
|
|
19
|
+
}, x = async () => {
|
|
20
|
+
try {
|
|
21
|
+
t(null), i(!0), await y(), n(!1), i(!1);
|
|
22
|
+
} catch (l) {
|
|
23
|
+
t(s(l)), i(!1);
|
|
24
|
+
}
|
|
25
|
+
}, C = async () => {
|
|
26
|
+
try {
|
|
27
|
+
t(null), i(!0), await m(), n(!1), i(!1);
|
|
28
|
+
} catch (l) {
|
|
29
|
+
t(s(l)), i(!1);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return p ? /* @__PURE__ */ r("div", { children: [
|
|
33
|
+
/* @__PURE__ */ r("div", { style: { display: "flex", justifyContent: "flex-start" }, children: [
|
|
34
|
+
/* @__PURE__ */ e("div", { children: h }),
|
|
35
|
+
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(a, { disabled: o, onClick: x, children: "OK" }) }),
|
|
36
|
+
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(a, { disabled: o, onClick: C, children: "Cancel" }) })
|
|
37
|
+
] }),
|
|
38
|
+
c && /* @__PURE__ */ e("div", { style: { color: "red" }, children: c.title })
|
|
39
|
+
] }) : /* @__PURE__ */ r("div", { style: { display: "flex", justifyContent: "flex-start" }, children: [
|
|
40
|
+
/* @__PURE__ */ e("div", { children: f }),
|
|
41
|
+
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(E, { content: "Large with calendar icon only", relationship: "label", children: /* @__PURE__ */ e(a, { size: "small", icon: /* @__PURE__ */ e(g, {}), onClick: v }) }) })
|
|
42
|
+
] });
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
O as InlineEdit
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=InlineEdit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InlineEdit.js","sources":["../../../src/lib/inlineedit/InlineEdit.tsx"],"sourcesContent":["import { ReactNode, useState } from \"react\";\nimport { Button, Tooltip } from \"@fluentui/react-components\";\nimport { Problem, toProblem } from \"@seij/common-types\";\nimport { EditRegular } from \"@fluentui/react-icons\";\n\nexport function InlineEdit({\n children,\n editor,\n onEditStart,\n onEditOK,\n onEditCancel,\n}: {\n children?: ReactNode | ReactNode[] | null;\n editor: ReactNode;\n onEditStart: () => Promise<any>;\n onEditOK: () => Promise<any>;\n onEditCancel: () => Promise<any>;\n}) {\n const [editing, setEditing] = useState<boolean>(false);\n const [error, setError] = useState<Problem | null>(null);\n const [pending, setPending] = useState<boolean>(false);\n\n const handleEdit = async () => {\n try {\n setError(null);\n await onEditStart();\n setEditing(true);\n } catch (err) {\n setError(toProblem(err));\n }\n };\n\n const handleEditOK = async () => {\n try {\n setError(null);\n setPending(true);\n await onEditOK();\n setEditing(false);\n setPending(false);\n } catch (err) {\n setError(toProblem(err));\n setPending(false);\n }\n };\n const handleEditCancel = async () => {\n try {\n setError(null);\n setPending(true);\n await onEditCancel();\n setEditing(false);\n setPending(false);\n } catch (err: any) {\n setError(toProblem(err));\n setPending(false);\n }\n };\n\n if (!editing)\n return (\n <div style={{ display: \"flex\", justifyContent: \"flex-start\" }}>\n <div>{children}</div>\n <div>\n <Tooltip content=\"Large with calendar icon only\" relationship=\"label\">\n <Button size=\"small\" icon={<EditRegular />} onClick={handleEdit} />\n </Tooltip>\n </div>\n </div>\n );\n\n return (\n <div>\n <div style={{ display: \"flex\", justifyContent: \"flex-start\" }}>\n <div>{editor}</div>\n <div>\n <Button disabled={pending} onClick={handleEditOK}>\n OK\n </Button>\n </div>\n <div>\n <Button disabled={pending} onClick={handleEditCancel}>\n Cancel\n </Button>\n </div>\n </div>\n {error && <div style={{ color: \"red\" }}>{error.title}</div>}\n </div>\n );\n}\n"],"names":["InlineEdit","children","editor","onEditStart","onEditOK","onEditCancel","editing","setEditing","useState","error","setError","pending","setPending","handleEdit","err","toProblem","handleEditOK","handleEditCancel","jsxs","jsx","Button","Tooltip","EditRegular"],"mappings":";;;;;AAKO,SAASA,EAAW;AAAA,EACzB,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC;AACF,GAMG;AACD,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAkB,EAAK,GAC/C,CAACC,GAAOC,CAAQ,IAAIF,EAAyB,IAAI,GACjD,CAACG,GAASC,CAAU,IAAIJ,EAAkB,EAAK,GAE/CK,IAAa,YAAY;AAC7B,QAAI;AACF,MAAAH,EAAS,IAAI,GACb,MAAMP,EAAA,GACNI,EAAW,EAAI;AAAA,IACjB,SAASO,GAAK;AACZ,MAAAJ,EAASK,EAAUD,CAAG,CAAC;AAAA,IACzB;AAAA,EACF,GAEME,IAAe,YAAY;AAC/B,QAAI;AACF,MAAAN,EAAS,IAAI,GACbE,EAAW,EAAI,GACf,MAAMR,EAAA,GACNG,EAAW,EAAK,GAChBK,EAAW,EAAK;AAAA,IAClB,SAASE,GAAK;AACZ,MAAAJ,EAASK,EAAUD,CAAG,CAAC,GACvBF,EAAW,EAAK;AAAA,IAClB;AAAA,EACF,GACMK,IAAmB,YAAY;AACnC,QAAI;AACF,MAAAP,EAAS,IAAI,GACbE,EAAW,EAAI,GACf,MAAMP,EAAA,GACNE,EAAW,EAAK,GAChBK,EAAW,EAAK;AAAA,IAClB,SAASE,GAAU;AACjB,MAAAJ,EAASK,EAAUD,CAAG,CAAC,GACvBF,EAAW,EAAK;AAAA,IAClB;AAAA,EACF;AAEA,SAAKN,sBAaF,OAAA,EACC,UAAA;AAAA,IAAA,gBAAAY,EAAC,SAAI,OAAO,EAAE,SAAS,QAAQ,gBAAgB,gBAC7C,UAAA;AAAA,MAAA,gBAAAC,EAAC,SAAK,UAAAjB,EAAA,CAAO;AAAA,MACb,gBAAAiB,EAAC,SACC,UAAA,gBAAAA,EAACC,GAAA,EAAO,UAAUT,GAAS,SAASK,GAAc,UAAA,KAAA,CAElD,EAAA,CACF;AAAA,MACA,gBAAAG,EAAC,SACC,UAAA,gBAAAA,EAACC,GAAA,EAAO,UAAUT,GAAS,SAASM,GAAkB,UAAA,SAAA,CAEtD,EAAA,CACF;AAAA,IAAA,GACF;AAAA,IACCR,uBAAU,OAAA,EAAI,OAAO,EAAE,OAAO,SAAU,UAAAA,EAAM,MAAA,CAAM;AAAA,EAAA,GACvD,IA1BE,gBAAAS,EAAC,SAAI,OAAO,EAAE,SAAS,QAAQ,gBAAgB,gBAC7C,UAAA;AAAA,IAAA,gBAAAC,EAAC,SAAK,UAAAlB,GAAS;AAAA,sBACd,OAAA,EACC,UAAA,gBAAAkB,EAACE,KAAQ,SAAQ,iCAAgC,cAAa,SAC5D,UAAA,gBAAAF,EAACC,KAAO,MAAK,SAAQ,MAAM,gBAAAD,EAACG,GAAA,CAAA,CAAY,GAAI,SAAST,EAAA,CAAY,GACnE,EAAA,CACF;AAAA,EAAA,GACF;AAqBN;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface ListItemData {
|
|
3
|
+
id: string;
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
description: ReactNode | null;
|
|
6
|
+
}
|
|
7
|
+
export interface ListViewProps<T extends ListItemData = ListItemData> {
|
|
8
|
+
data: T[];
|
|
9
|
+
activeId: string;
|
|
10
|
+
searchText?: string;
|
|
11
|
+
search?: (input: string) => void;
|
|
12
|
+
pathFactory: (item: T) => string;
|
|
13
|
+
navigate: (url: string) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function ListView<T extends ListItemData>({ data, activeId, searchText, search, pathFactory, navigate, }: ListViewProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=ListView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../src/lib/listview/ListView.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,EAAE,SAAS,GAAG,IAAI,CAAC;CAC/B;AAQD,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY;IAClE,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IACjC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AACD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,YAAY,EAAE,EAC/C,IAAI,EACJ,QAAQ,EACR,UAAe,EACf,MAAM,EACN,WAAW,EACX,QAAQ,GACT,EAAE,aAAa,CAAC,CAAC,CAAC,2CA8BlB"}
|