@plumile/backoffice-react 0.1.125 → 0.1.130
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/lib/esm/components/backoffice/billing/BackofficeBillingUsageChart.js +37 -26
- package/lib/esm/components/backoffice/billing/BackofficeBillingUsageChart.js.map +1 -1
- package/lib/esm/components/backoffice/detail/BackofficeDetailBadgeRow.js +2 -1
- package/lib/esm/components/backoffice/detail/BackofficeDetailBadgeRow.js.map +1 -1
- package/lib/esm/components/backoffice/filters/backofficeFilterAction.css.js +1 -0
- package/lib/esm/components/backoffice/layout/backofficeSidebarActions.css.js +0 -1
- package/lib/esm/components/backoffice/shared/BackofficeFormattedCurrency.js +2 -1
- package/lib/esm/components/backoffice/shared/BackofficeFormattedCurrency.js.map +1 -1
- package/lib/esm/i18n/useBackofficeFormats.js +28 -12
- package/lib/esm/i18n/useBackofficeFormats.js.map +1 -1
- package/lib/esm/pages/BackofficeEntityDetailPage.js +197 -196
- package/lib/esm/pages/BackofficeEntityDetailPage.js.map +1 -1
- package/lib/esm/pages/BackofficeEntityDetailPage.view-helpers.js +74 -70
- package/lib/esm/pages/BackofficeEntityDetailPage.view-helpers.js.map +1 -1
- package/lib/types/components/backoffice/billing/BackofficeBillingUsageChart.d.ts.map +1 -1
- package/lib/types/components/backoffice/detail/BackofficeDetailBadgeRow.d.ts.map +1 -1
- package/lib/types/components/backoffice/shared/BackofficeFormattedCurrency.d.ts.map +1 -1
- package/lib/types/i18n/useBackofficeFormats.d.ts +1 -0
- package/lib/types/i18n/useBackofficeFormats.d.ts.map +1 -1
- package/lib/types/pages/BackofficeEntityDetailPage.d.ts.map +1 -1
- package/lib/types/pages/BackofficeEntityDetailPage.view-helpers.d.ts +1 -0
- package/lib/types/pages/BackofficeEntityDetailPage.view-helpers.d.ts.map +1 -1
- package/package.json +11 -11
|
@@ -6,55 +6,66 @@ import { TimeSeriesLineChart as s } from "@plumile/ui/components/charts/TimeSeri
|
|
|
6
6
|
import { formatCurrencyAmount as c } from "@plumile/ui/shared/currencyAmount.js";
|
|
7
7
|
import { toUtcDailyCategorySeries as l } from "@plumile/ui/shared/timeSeries.js";
|
|
8
8
|
//#region src/components/backoffice/billing/BackofficeBillingUsageChart.tsx
|
|
9
|
-
var u = "->", d = (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
var u = "->", d = (e, t) => new Intl.NumberFormat(void 0, {
|
|
10
|
+
style: "currency",
|
|
11
|
+
currency: t,
|
|
12
|
+
minimumFractionDigits: 0,
|
|
13
|
+
maximumFractionDigits: 0
|
|
14
|
+
}).format(e), f = ({ ariaLabel: f, buckets: p, categories: m, currency: h, emptyLabel: g, from: _, rangePrefix: v, to: y, totalAmount: b }) => {
|
|
15
|
+
let x = r(() => m.map((e) => e.id), [m]), S = r(() => Object.fromEntries(m.map((e) => [e.id, e.color])), [m]), C = r(() => Object.fromEntries(m.map((e) => [e.id, e.label])), [m]), w = r(() => _ == null || y == null ? [] : l({
|
|
16
|
+
fromIsoDateTime: _,
|
|
17
|
+
toIsoDateTime: y,
|
|
18
|
+
buckets: p,
|
|
19
|
+
categories: x
|
|
15
20
|
}), [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
]),
|
|
21
|
+
p,
|
|
22
|
+
x,
|
|
23
|
+
_,
|
|
24
|
+
y
|
|
25
|
+
]), T = (e) => c({
|
|
21
26
|
amount: e,
|
|
22
|
-
currency:
|
|
27
|
+
currency: h
|
|
23
28
|
});
|
|
24
|
-
return
|
|
29
|
+
return p.length === 0 ? /* @__PURE__ */ i("p", {
|
|
25
30
|
className: e,
|
|
26
|
-
children:
|
|
31
|
+
children: g
|
|
27
32
|
}) : /* @__PURE__ */ a("div", {
|
|
28
33
|
className: t,
|
|
29
34
|
children: [
|
|
30
35
|
/* @__PURE__ */ i("p", {
|
|
31
36
|
className: n,
|
|
32
|
-
children:
|
|
37
|
+
children: T(b)
|
|
33
38
|
}),
|
|
34
|
-
|
|
39
|
+
_ != null && y != null && /* @__PURE__ */ a("p", {
|
|
35
40
|
className: "txvbqb96 txvbqb19cd txvbqbm9g",
|
|
36
41
|
children: [
|
|
37
|
-
|
|
42
|
+
v,
|
|
38
43
|
" ",
|
|
39
|
-
/* @__PURE__ */ i(o, { value:
|
|
44
|
+
/* @__PURE__ */ i(o, { value: _ }),
|
|
40
45
|
" ",
|
|
41
46
|
u,
|
|
42
47
|
" ",
|
|
43
|
-
/* @__PURE__ */ i(o, { value:
|
|
48
|
+
/* @__PURE__ */ i(o, { value: y })
|
|
44
49
|
]
|
|
45
50
|
}),
|
|
46
51
|
/* @__PURE__ */ i(s, {
|
|
47
|
-
ariaLabel:
|
|
48
|
-
categoryColorById:
|
|
49
|
-
categoryLabel: (e) =>
|
|
50
|
-
categoryOrder:
|
|
51
|
-
formatValue:
|
|
52
|
-
series:
|
|
52
|
+
ariaLabel: f,
|
|
53
|
+
categoryColorById: S,
|
|
54
|
+
categoryLabel: (e) => C[e] ?? e,
|
|
55
|
+
categoryOrder: x,
|
|
56
|
+
formatValue: T,
|
|
57
|
+
series: w,
|
|
58
|
+
yAxis: {
|
|
59
|
+
min: 0,
|
|
60
|
+
minTickStep: 1,
|
|
61
|
+
maxTickCount: 5,
|
|
62
|
+
formatValue: (e) => d(e, h)
|
|
63
|
+
}
|
|
53
64
|
})
|
|
54
65
|
]
|
|
55
66
|
});
|
|
56
67
|
};
|
|
57
68
|
//#endregion
|
|
58
|
-
export {
|
|
69
|
+
export { f as BackofficeBillingUsageChart, f as default };
|
|
59
70
|
|
|
60
71
|
//# sourceMappingURL=BackofficeBillingUsageChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackofficeBillingUsageChart.js","names":[],"sources":["../../../../../src/components/backoffice/billing/BackofficeBillingUsageChart.tsx"],"sourcesContent":["import { useMemo, type JSX } from 'react';\nimport { FormattedDate } from '@plumile/ui/atomic/atoms/formatted-date/FormattedDate.js';\nimport { TimeSeriesLineChart } from '@plumile/ui/components/charts/TimeSeriesLineChart.js';\nimport { formatCurrencyAmount } from '@plumile/ui/shared/currencyAmount.js';\nimport { toUtcDailyCategorySeries } from '@plumile/ui/shared/timeSeries.js';\n\nimport * as styles from './backofficeBillingUsageChart.css.js';\n\nexport type BackofficeBillingUsageChartBucket = {\n readonly day: string;\n readonly category: string;\n readonly value: number;\n};\n\nexport type BackofficeBillingUsageChartCategory = {\n readonly id: string;\n readonly label: string;\n readonly color: string;\n};\n\nexport type BackofficeBillingUsageChartProps = {\n readonly currency: string;\n readonly totalAmount: number;\n readonly from: string | null;\n readonly to: string | null;\n readonly buckets: readonly BackofficeBillingUsageChartBucket[];\n readonly categories: readonly BackofficeBillingUsageChartCategory[];\n readonly emptyLabel: string;\n readonly rangePrefix: string;\n readonly ariaLabel: string;\n};\n\nconst dateSeparator = '->';\n\nexport const BackofficeBillingUsageChart = ({\n ariaLabel,\n buckets,\n categories,\n currency,\n emptyLabel,\n from,\n rangePrefix,\n to,\n totalAmount,\n}: BackofficeBillingUsageChartProps): JSX.Element => {\n const categoryOrder = useMemo(() => {\n return categories.map((category) => {\n return category.id;\n });\n }, [categories]);\n\n const categoryColorById = useMemo(() => {\n return Object.fromEntries(\n categories.map((category) => {\n return [category.id, category.color];\n }),\n );\n }, [categories]);\n\n const categoryLabelById = useMemo(() => {\n return Object.fromEntries(\n categories.map((category) => {\n return [category.id, category.label];\n }),\n );\n }, [categories]);\n\n const series = useMemo(() => {\n if (from == null || to == null) {\n return [];\n }\n\n return toUtcDailyCategorySeries({\n fromIsoDateTime: from,\n toIsoDateTime: to,\n buckets,\n categories: categoryOrder,\n });\n }, [buckets, categoryOrder, from, to]);\n\n const formatChartValue = (value: number): string => {\n return formatCurrencyAmount({\n amount: value,\n currency,\n });\n };\n\n if (buckets.length === 0) {\n return <p className={styles.rangeText}>{emptyLabel}</p>;\n }\n\n return (\n <div className={styles.root}>\n <p className={styles.totalValue}>{formatChartValue(totalAmount)}</p>\n {from != null && to != null && (\n <p className={styles.rangeText}>\n {rangePrefix} <FormattedDate value={from} /> {dateSeparator}{' '}\n <FormattedDate value={to} />\n </p>\n )}\n <TimeSeriesLineChart\n ariaLabel={ariaLabel}\n categoryColorById={categoryColorById}\n categoryLabel={(category) => {\n return categoryLabelById[category] ?? category;\n }}\n categoryOrder={categoryOrder}\n formatValue={formatChartValue}\n series={series}\n />\n </div>\n );\n};\n\nexport default BackofficeBillingUsageChart;\n"],"mappings":";;;;;;;;AAgCA,IAAM,IAAgB,
|
|
1
|
+
{"version":3,"file":"BackofficeBillingUsageChart.js","names":[],"sources":["../../../../../src/components/backoffice/billing/BackofficeBillingUsageChart.tsx"],"sourcesContent":["import { useMemo, type JSX } from 'react';\nimport { FormattedDate } from '@plumile/ui/atomic/atoms/formatted-date/FormattedDate.js';\nimport { TimeSeriesLineChart } from '@plumile/ui/components/charts/TimeSeriesLineChart.js';\nimport { formatCurrencyAmount } from '@plumile/ui/shared/currencyAmount.js';\nimport { toUtcDailyCategorySeries } from '@plumile/ui/shared/timeSeries.js';\n\nimport * as styles from './backofficeBillingUsageChart.css.js';\n\nexport type BackofficeBillingUsageChartBucket = {\n readonly day: string;\n readonly category: string;\n readonly value: number;\n};\n\nexport type BackofficeBillingUsageChartCategory = {\n readonly id: string;\n readonly label: string;\n readonly color: string;\n};\n\nexport type BackofficeBillingUsageChartProps = {\n readonly currency: string;\n readonly totalAmount: number;\n readonly from: string | null;\n readonly to: string | null;\n readonly buckets: readonly BackofficeBillingUsageChartBucket[];\n readonly categories: readonly BackofficeBillingUsageChartCategory[];\n readonly emptyLabel: string;\n readonly rangePrefix: string;\n readonly ariaLabel: string;\n};\n\nconst dateSeparator = '->';\n\nconst formatBillingAxisValue = (value: number, currency: string): string => {\n return new Intl.NumberFormat(undefined, {\n style: 'currency',\n currency,\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n }).format(value);\n};\n\nexport const BackofficeBillingUsageChart = ({\n ariaLabel,\n buckets,\n categories,\n currency,\n emptyLabel,\n from,\n rangePrefix,\n to,\n totalAmount,\n}: BackofficeBillingUsageChartProps): JSX.Element => {\n const categoryOrder = useMemo(() => {\n return categories.map((category) => {\n return category.id;\n });\n }, [categories]);\n\n const categoryColorById = useMemo(() => {\n return Object.fromEntries(\n categories.map((category) => {\n return [category.id, category.color];\n }),\n );\n }, [categories]);\n\n const categoryLabelById = useMemo(() => {\n return Object.fromEntries(\n categories.map((category) => {\n return [category.id, category.label];\n }),\n );\n }, [categories]);\n\n const series = useMemo(() => {\n if (from == null || to == null) {\n return [];\n }\n\n return toUtcDailyCategorySeries({\n fromIsoDateTime: from,\n toIsoDateTime: to,\n buckets,\n categories: categoryOrder,\n });\n }, [buckets, categoryOrder, from, to]);\n\n const formatChartValue = (value: number): string => {\n return formatCurrencyAmount({\n amount: value,\n currency,\n });\n };\n\n if (buckets.length === 0) {\n return <p className={styles.rangeText}>{emptyLabel}</p>;\n }\n\n return (\n <div className={styles.root}>\n <p className={styles.totalValue}>{formatChartValue(totalAmount)}</p>\n {from != null && to != null && (\n <p className={styles.rangeText}>\n {rangePrefix} <FormattedDate value={from} /> {dateSeparator}{' '}\n <FormattedDate value={to} />\n </p>\n )}\n <TimeSeriesLineChart\n ariaLabel={ariaLabel}\n categoryColorById={categoryColorById}\n categoryLabel={(category) => {\n return categoryLabelById[category] ?? category;\n }}\n categoryOrder={categoryOrder}\n formatValue={formatChartValue}\n series={series}\n yAxis={{\n min: 0,\n minTickStep: 1,\n maxTickCount: 5,\n formatValue: (value) => {\n return formatBillingAxisValue(value, currency);\n },\n }}\n />\n </div>\n );\n};\n\nexport default BackofficeBillingUsageChart;\n"],"mappings":";;;;;;;;AAgCA,IAAM,IAAgB,MAEhB,KAA0B,GAAe,MACtC,IAAI,KAAK,aAAa,KAAA,GAAW;CACtC,OAAO;CACP;CACA,uBAAuB;CACvB,uBAAuB;CACxB,CAAC,CAAC,OAAO,EAAM,EAGL,KAA+B,EAC1C,cACA,YACA,eACA,aACA,eACA,SACA,gBACA,OACA,qBACmD;CACnD,IAAM,IAAgB,QACb,EAAW,KAAK,MACd,EAAS,GAChB,EACD,CAAC,EAAW,CAAC,EAEV,IAAoB,QACjB,OAAO,YACZ,EAAW,KAAK,MACP,CAAC,EAAS,IAAI,EAAS,MAAM,CACpC,CACH,EACA,CAAC,EAAW,CAAC,EAEV,IAAoB,QACjB,OAAO,YACZ,EAAW,KAAK,MACP,CAAC,EAAS,IAAI,EAAS,MAAM,CACpC,CACH,EACA,CAAC,EAAW,CAAC,EAEV,IAAS,QACT,KAAQ,QAAQ,KAAM,OACjB,EAAE,GAGJ,EAAyB;EAC9B,iBAAiB;EACjB,eAAe;EACf;EACA,YAAY;EACb,CAAC,EACD;EAAC;EAAS;EAAe;EAAM;EAAG,CAAC,EAEhC,KAAoB,MACjB,EAAqB;EAC1B,QAAQ;EACR;EACD,CAAC;CAOJ,OAJI,EAAQ,WAAW,IACd,kBAAC,KAAD;EAAG,WAAW;YAAmB;EAAe,CAAA,GAIvD,kBAAC,OAAD;EAAK,WAAW;YAAhB;GACE,kBAAC,KAAD;IAAG,WAAW;cAAoB,EAAiB,EAAY;IAAK,CAAA;GACnE,KAAQ,QAAQ,KAAM,QACrB,kBAAC,KAAD;IAAG,WAAW;cAAd;KACG;KAAY;KAAC,kBAAC,GAAD,EAAe,OAAO,GAAQ,CAAA;;KAAE;KAAe;KAC7D,kBAAC,GAAD,EAAe,OAAO,GAAM,CAAA;KAC1B;;GAEN,kBAAC,GAAD;IACa;IACQ;IACnB,gBAAgB,MACP,EAAkB,MAAa;IAEzB;IACf,aAAa;IACL;IACR,OAAO;KACL,KAAK;KACL,aAAa;KACb,cAAc;KACd,cAAc,MACL,EAAuB,GAAO,EAAS;KAEjD;IACD,CAAA;GACE"}
|
|
@@ -8,9 +8,10 @@ var i = ({ items: i }) => {
|
|
|
8
8
|
return /* @__PURE__ */ t("div", {
|
|
9
9
|
className: e,
|
|
10
10
|
children: i.map((e) => {
|
|
11
|
-
let n = typeof e.label == "function" ? e.label(a) : e.label;
|
|
11
|
+
let n = typeof e.label == "function" ? e.label(a) : e.label, i = typeof e.title == "function" ? e.title(a) : e.title;
|
|
12
12
|
return /* @__PURE__ */ t(r, {
|
|
13
13
|
tone: e.tone ?? "neutral",
|
|
14
|
+
title: i,
|
|
14
15
|
children: n
|
|
15
16
|
}, e.id);
|
|
16
17
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackofficeDetailBadgeRow.js","names":[],"sources":["../../../../../src/components/backoffice/detail/BackofficeDetailBadgeRow.tsx"],"sourcesContent":["/* eslint-disable no-ternary */\nimport { type JSX } from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport type { BackofficeBadgeItem } from '@plumile/backoffice-core/types.js';\nimport { Tag } from '@plumile/ui/backoffice/atoms/tag/Tag.js';\n\nimport * as styles from './backofficeDetailBadgeRow.css.js';\n\nexport type BackofficeDetailBadgeRowProps = {\n items: readonly BackofficeBadgeItem[];\n};\n\nexport const BackofficeDetailBadgeRow = ({\n items,\n}: BackofficeDetailBadgeRowProps): JSX.Element => {\n const { t } = useTranslation();\n return (\n <div className={styles.row}>\n {items.map((item) => {\n const label =\n typeof item.label === 'function' ? item.label(t) : item.label;\n return (\n <Tag key={item.id} tone={item.tone ?? 'neutral'}>\n {label}\n </Tag>\n );\n })}\n </div>\n );\n};\n\nexport default BackofficeDetailBadgeRow;\n"],"mappings":";;;;;AAaA,IAAa,KAA4B,EACvC,eACgD;CAChD,IAAM,EAAE,SAAM,GAAgB;CAC9B,OACE,kBAAC,OAAD;EAAK,WAAW;YACb,EAAM,KAAK,MAAS;GACnB,IAAM,IACJ,OAAO,EAAK,SAAU,aAAa,EAAK,MAAM,EAAE,GAAG,EAAK;GAC1D,OACE,kBAAC,GAAD;IAAmB,MAAM,EAAK,QAAQ;
|
|
1
|
+
{"version":3,"file":"BackofficeDetailBadgeRow.js","names":[],"sources":["../../../../../src/components/backoffice/detail/BackofficeDetailBadgeRow.tsx"],"sourcesContent":["/* eslint-disable no-ternary */\nimport { type JSX } from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport type { BackofficeBadgeItem } from '@plumile/backoffice-core/types.js';\nimport { Tag } from '@plumile/ui/backoffice/atoms/tag/Tag.js';\n\nimport * as styles from './backofficeDetailBadgeRow.css.js';\n\nexport type BackofficeDetailBadgeRowProps = {\n items: readonly BackofficeBadgeItem[];\n};\n\nexport const BackofficeDetailBadgeRow = ({\n items,\n}: BackofficeDetailBadgeRowProps): JSX.Element => {\n const { t } = useTranslation();\n return (\n <div className={styles.row}>\n {items.map((item) => {\n const label =\n typeof item.label === 'function' ? item.label(t) : item.label;\n const title =\n typeof item.title === 'function' ? item.title(t) : item.title;\n return (\n <Tag key={item.id} tone={item.tone ?? 'neutral'} title={title}>\n {label}\n </Tag>\n );\n })}\n </div>\n );\n};\n\nexport default BackofficeDetailBadgeRow;\n"],"mappings":";;;;;AAaA,IAAa,KAA4B,EACvC,eACgD;CAChD,IAAM,EAAE,SAAM,GAAgB;CAC9B,OACE,kBAAC,OAAD;EAAK,WAAW;YACb,EAAM,KAAK,MAAS;GACnB,IAAM,IACJ,OAAO,EAAK,SAAU,aAAa,EAAK,MAAM,EAAE,GAAG,EAAK,OACpD,IACJ,OAAO,EAAK,SAAU,aAAa,EAAK,MAAM,EAAE,GAAG,EAAK;GAC1D,OACE,kBAAC,GAAD;IAAmB,MAAM,EAAK,QAAQ;IAAkB;cACrD;IACG,EAFI,EAAK,GAET;IAER;EACE,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* empty css */
|
|
1
2
|
/* empty css */
|
|
2
3
|
//#region src/components/backoffice/filters/backofficeFilterAction.css.ts
|
|
3
4
|
var e = "hwnq700 txvbqbdsb txvbqbey txvbqbjtp txvbqb17ia txvbqbhnp txvbqbux3 txvbqb2g9 txvbqb1uy txvbqb2et txvbqb17u txvbqb196f txvbqb19d9 txvbqbv txvbqb3f txvbqb7h txvbqb75 txvbqb7t txvbqb1bs9 txvbqb1adl txvbqb1ayh qbwcue0 txvbqb1cb0 txvbqb1cws", t = "txvbqb17h7 txvbqbhmm";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* empty css */
|
|
2
1
|
/* empty css */
|
|
3
2
|
//#region src/components/backoffice/layout/backofficeSidebarActions.css.ts
|
|
4
3
|
var e = "_1xws1b00 qbwcuej qbwcueh txvbqbdsb txvbqbey txvbqbjtp txvbqb1g5 txvbqb2e3 txvbqb2g9 txvbqb1933 txvbqb19cb txvbqbv txvbqbux3 txvbqb7h txvbqb76 txvbqb7t qbwcuei txvbqb1aey txvbqb1bsa qbwcue4 txvbqb1c2w txvbqb1c9c qbwcue0 txvbqb1cb0 txvbqb1cws txvbqb17hx txvbqbhnc";
|
|
@@ -2,12 +2,13 @@ import { useBackofficeFormats as e } from "../../../i18n/useBackofficeFormats.js
|
|
|
2
2
|
import { jsx as t } from "react/jsx-runtime";
|
|
3
3
|
//#region src/components/backoffice/shared/BackofficeFormattedCurrency.tsx
|
|
4
4
|
var n = ({ value: n, fallback: r = "-", className: i }) => {
|
|
5
|
-
let { formatCurrency: a } = e();
|
|
5
|
+
let { formatCurrency: a, formatCurrencyTitle: o } = e();
|
|
6
6
|
return n == null ? /* @__PURE__ */ t("span", {
|
|
7
7
|
className: i,
|
|
8
8
|
children: r
|
|
9
9
|
}) : /* @__PURE__ */ t("span", {
|
|
10
10
|
className: i,
|
|
11
|
+
title: o(n) ?? void 0,
|
|
11
12
|
children: a(n)
|
|
12
13
|
});
|
|
13
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackofficeFormattedCurrency.js","names":[],"sources":["../../../../../src/components/backoffice/shared/BackofficeFormattedCurrency.tsx"],"sourcesContent":["import { type JSX, type ReactNode } from 'react';\n\nimport { useBackofficeFormats } from '../../../i18n/useBackofficeFormats.js';\n\nexport type BackofficeFormattedCurrencyProps = {\n value: number | null | undefined;\n fallback?: ReactNode;\n className?: string;\n};\n\nexport const BackofficeFormattedCurrency = ({\n value,\n fallback = '-',\n className,\n}: BackofficeFormattedCurrencyProps): JSX.Element => {\n const { formatCurrency } = useBackofficeFormats();\n\n if (value == null) {\n return <span className={className}>{fallback}</span>;\n }\n\n return <span className={className}
|
|
1
|
+
{"version":3,"file":"BackofficeFormattedCurrency.js","names":[],"sources":["../../../../../src/components/backoffice/shared/BackofficeFormattedCurrency.tsx"],"sourcesContent":["import { type JSX, type ReactNode } from 'react';\n\nimport { useBackofficeFormats } from '../../../i18n/useBackofficeFormats.js';\n\nexport type BackofficeFormattedCurrencyProps = {\n value: number | null | undefined;\n fallback?: ReactNode;\n className?: string;\n};\n\nexport const BackofficeFormattedCurrency = ({\n value,\n fallback = '-',\n className,\n}: BackofficeFormattedCurrencyProps): JSX.Element => {\n const { formatCurrency, formatCurrencyTitle } = useBackofficeFormats();\n\n if (value == null) {\n return <span className={className}>{fallback}</span>;\n }\n\n return (\n <span className={className} title={formatCurrencyTitle(value) ?? undefined}>\n {formatCurrency(value)}\n </span>\n );\n};\n\nexport default BackofficeFormattedCurrency;\n"],"mappings":";;;AAUA,IAAa,KAA+B,EAC1C,UACA,cAAW,KACX,mBACmD;CACnD,IAAM,EAAE,mBAAgB,2BAAwB,GAAsB;CAMtE,OAJI,KAAS,OACJ,kBAAC,QAAD;EAAiB;YAAY;EAAgB,CAAA,GAIpD,kBAAC,QAAD;EAAiB;EAAW,OAAO,EAAoB,EAAM,IAAI,KAAA;YAC9D,EAAe,EAAM;EACjB,CAAA"}
|
|
@@ -1,23 +1,39 @@
|
|
|
1
1
|
import { useBackofficeReactTranslation as e } from "./useBackofficeReactTranslation.js";
|
|
2
2
|
//#region src/i18n/useBackofficeFormats.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
var t = {
|
|
4
|
+
style: "currency",
|
|
5
|
+
currency: "USD",
|
|
6
|
+
minimumFractionDigits: 2,
|
|
7
|
+
maximumFractionDigits: 6
|
|
8
|
+
};
|
|
9
|
+
function n() {
|
|
10
|
+
let { i18n: n, t: r } = e();
|
|
11
|
+
function i(e) {
|
|
12
|
+
return r("format.number", { value: e });
|
|
7
13
|
}
|
|
8
|
-
function
|
|
9
|
-
return
|
|
14
|
+
function a(e) {
|
|
15
|
+
return r("format.currency", { value: e });
|
|
10
16
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
17
|
+
function o(e) {
|
|
18
|
+
if (e == null || !Number.isFinite(e)) return null;
|
|
19
|
+
try {
|
|
20
|
+
let r = e;
|
|
21
|
+
return Object.is(e, -0) && (r = 0), new Intl.NumberFormat(n.language, t).format(r);
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function s(e) {
|
|
27
|
+
return r("format.percent", { value: e });
|
|
13
28
|
}
|
|
14
29
|
return {
|
|
15
|
-
formatNumber:
|
|
16
|
-
formatCurrency:
|
|
17
|
-
|
|
30
|
+
formatNumber: i,
|
|
31
|
+
formatCurrency: a,
|
|
32
|
+
formatCurrencyTitle: o,
|
|
33
|
+
formatPercent: s
|
|
18
34
|
};
|
|
19
35
|
}
|
|
20
36
|
//#endregion
|
|
21
|
-
export {
|
|
37
|
+
export { n as useBackofficeFormats };
|
|
22
38
|
|
|
23
39
|
//# sourceMappingURL=useBackofficeFormats.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBackofficeFormats.js","names":[],"sources":["../../../src/i18n/useBackofficeFormats.ts"],"sourcesContent":["import { useBackofficeReactTranslation } from './useBackofficeReactTranslation.js';\n\nexport type BackofficeFormats = {\n formatNumber: (value: number | null | undefined) => string;\n formatCurrency: (value: number | null | undefined) => string;\n formatPercent: (value: number | null | undefined) => string;\n};\n\n/**\n *\n */\nexport function useBackofficeFormats(): BackofficeFormats {\n const { t } = useBackofficeReactTranslation();\n\n /**\n *\n */\n function formatNumber(value: number | null | undefined): string {\n return t('format.number', { value });\n }\n\n /**\n *\n */\n function formatCurrency(value: number | null | undefined): string {\n return t('format.currency', { value });\n }\n\n /**\n *\n */\n function formatPercent(value: number | null | undefined): string {\n return t('format.percent', { value });\n }\n\n return { formatNumber, formatCurrency, formatPercent };\n}\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"useBackofficeFormats.js","names":[],"sources":["../../../src/i18n/useBackofficeFormats.ts"],"sourcesContent":["import { useBackofficeReactTranslation } from './useBackofficeReactTranslation.js';\n\nexport type BackofficeFormats = {\n formatNumber: (value: number | null | undefined) => string;\n formatCurrency: (value: number | null | undefined) => string;\n formatCurrencyTitle: (value: number | null | undefined) => string | null;\n formatPercent: (value: number | null | undefined) => string;\n};\n\nconst CURRENCY_TITLE_OPTIONS = {\n style: 'currency',\n currency: 'USD',\n minimumFractionDigits: 2,\n maximumFractionDigits: 6,\n} as const;\n\n/**\n *\n */\nexport function useBackofficeFormats(): BackofficeFormats {\n const { i18n, t } = useBackofficeReactTranslation();\n\n /**\n *\n */\n function formatNumber(value: number | null | undefined): string {\n return t('format.number', { value });\n }\n\n /**\n *\n */\n function formatCurrency(value: number | null | undefined): string {\n return t('format.currency', { value });\n }\n\n /**\n *\n */\n function formatCurrencyTitle(\n value: number | null | undefined,\n ): string | null {\n if (value == null || !Number.isFinite(value)) {\n return null;\n }\n try {\n let normalizedValue = value;\n if (Object.is(value, -0)) {\n normalizedValue = 0;\n }\n\n return new Intl.NumberFormat(\n i18n.language,\n CURRENCY_TITLE_OPTIONS,\n ).format(normalizedValue);\n } catch {\n return null;\n }\n }\n\n /**\n *\n */\n function formatPercent(value: number | null | undefined): string {\n return t('format.percent', { value });\n }\n\n return { formatNumber, formatCurrency, formatCurrencyTitle, formatPercent };\n}\n"],"mappings":";;AASA,IAAM,IAAyB;CAC7B,OAAO;CACP,UAAU;CACV,uBAAuB;CACvB,uBAAuB;CACxB;AAKD,SAAgB,IAA0C;CACxD,IAAM,EAAE,SAAM,SAAM,GAA+B;CAKnD,SAAS,EAAa,GAA0C;EAC9D,OAAO,EAAE,iBAAiB,EAAE,UAAO,CAAC;;CAMtC,SAAS,EAAe,GAA0C;EAChE,OAAO,EAAE,mBAAmB,EAAE,UAAO,CAAC;;CAMxC,SAAS,EACP,GACe;EACf,IAAI,KAAS,QAAQ,CAAC,OAAO,SAAS,EAAM,EAC1C,OAAO;EAET,IAAI;GACF,IAAI,IAAkB;GAKtB,OAJI,OAAO,GAAG,GAAO,GAAG,KACtB,IAAkB,IAGb,IAAI,KAAK,aACd,EAAK,UACL,EACD,CAAC,OAAO,EAAgB;UACnB;GACN,OAAO;;;CAOX,SAAS,EAAc,GAA0C;EAC/D,OAAO,EAAE,kBAAkB,EAAE,UAAO,CAAC;;CAGvC,OAAO;EAAE;EAAc;EAAgB;EAAqB;EAAe"}
|