@embeddable.com/remarkable-pro 0.0.20 → 0.0.21
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/BarChartDefaultHorizontalPro.js +3 -3
- package/dist/BarChartDefaultPro.js +3 -3
- package/dist/BarChartGroupedHorizontalPro.js +3 -3
- package/dist/BarChartGroupedPro.js +3 -3
- package/dist/BarChartStackedHorizontalPro.js +3 -3
- package/dist/BarChartStackedPro.js +3 -3
- package/dist/ChartCard-D_A88_bS.js +116 -0
- package/dist/ChartCard-D_A88_bS.js.map +1 -0
- package/dist/{Color.type.emb-C4VcPjfM.js → Color.type.emb-Dkh_ZrO6.js} +914 -918
- package/dist/{Color.type.emb-C4VcPjfM.js.map → Color.type.emb-Dkh_ZrO6.js.map} +1 -1
- package/dist/ColorEditor.js +1 -1
- package/dist/ComparisonPeriodSelectFieldPro.js +3 -3
- package/dist/DateRangePickerCustomPro.js +3 -3
- package/dist/DateRangeSelectFieldPro.js +3 -3
- package/dist/DonutChartPro.js +3 -3
- package/dist/DonutLabelChartPro.js +3 -3
- package/dist/{EditorCard-CcsUaHcd.js → EditorCard-1Z3UFd1D.js} +3 -3
- package/dist/{EditorCard-CcsUaHcd.js.map → EditorCard-1Z3UFd1D.js.map} +1 -1
- package/dist/GranularitySelectFieldPro.js +46 -39
- package/dist/GranularitySelectFieldPro.js.map +1 -1
- package/dist/HeatMapPro.js +3 -3
- package/dist/KpiChartNumberComparisonPro.js +3 -3
- package/dist/KpiChartNumberPro.js +3 -3
- package/dist/LineChartComparisonDefaultPro.js +3 -3
- package/dist/LineChartDefaultPro.js +3 -3
- package/dist/LineChartGroupedPro.js +3 -3
- package/dist/MultiSelectFieldPro.js +3 -3
- package/dist/PieChartPro.js +3 -3
- package/dist/PivotTablePro.js +3 -3
- package/dist/SingleSelectFieldPro.js +3 -3
- package/dist/TableChartPaginated.js +3 -3
- package/dist/TableScrollable.js +4 -4
- package/dist/{bars.utils-Ck1w7NOo.js → bars.utils-CsJD9MNL.js} +4 -4
- package/dist/{bars.utils-Ck1w7NOo.js.map → bars.utils-CsJD9MNL.js.map} +1 -1
- package/dist/{charts.utils-g6NE_Jo3.js → charts.utils-CUPowt7F.js} +13 -13
- package/dist/charts.utils-CUPowt7F.js.map +1 -0
- package/dist/{component.inputs.constants-DN1efWXx.js → component.inputs.constants-CNdmawDt.js} +2 -2
- package/dist/{component.inputs.constants-DN1efWXx.js.map → component.inputs.constants-CNdmawDt.js.map} +1 -1
- package/dist/components/charts/shared/ChartCard/ChartCard.d.ts +6 -5
- package/dist/components/charts/shared/ChartCard/ChartCard.d.ts.map +1 -1
- package/dist/components/editors/GranularitySelectFieldPro/GranularitySelectFieldPro.utils.d.ts +2 -10
- package/dist/components/editors/GranularitySelectFieldPro/GranularitySelectFieldPro.utils.d.ts.map +1 -1
- package/dist/components/editors/GranularitySelectFieldPro/index.d.ts.map +1 -1
- package/dist/embeddable-components.json +15 -15
- package/dist/embeddable-theme-0137e.js +191 -191
- package/dist/{formatter.utils-pzrkapRL.js → formatter.utils-BiWZBhcE.js} +2 -2
- package/dist/{formatter.utils-pzrkapRL.js.map → formatter.utils-BiWZBhcE.js.map} +1 -1
- package/dist/{index-53w_cRnE.js → index-1vsLONt_.js} +5 -5
- package/dist/{index-53w_cRnE.js.map → index-1vsLONt_.js.map} +1 -1
- package/dist/{index-4mTCN1nI.js → index-8PpbF7SA.js} +5 -5
- package/dist/{index-4mTCN1nI.js.map → index-8PpbF7SA.js.map} +1 -1
- package/dist/{index-7Vgn0Xsn.js → index-B3m93Z4r.js} +5 -5
- package/dist/{index-7Vgn0Xsn.js.map → index-B3m93Z4r.js.map} +1 -1
- package/dist/{index-Cr68Ha2O.js → index-BBcQWvRk.js} +5 -5
- package/dist/{index-Cr68Ha2O.js.map → index-BBcQWvRk.js.map} +1 -1
- package/dist/{index-JiDnk-OU.js → index-BOI6FOwo.js} +5 -5
- package/dist/{index-JiDnk-OU.js.map → index-BOI6FOwo.js.map} +1 -1
- package/dist/{index-DCVqVqS5.js → index-Boogtc12.js} +6 -6
- package/dist/{index-DCVqVqS5.js.map → index-Boogtc12.js.map} +1 -1
- package/dist/{index-Brl5KgVS.js → index-BuBn1ktN.js} +5 -5
- package/dist/{index-Brl5KgVS.js.map → index-BuBn1ktN.js.map} +1 -1
- package/dist/{index-DXkwaXvx.js → index-CQ_mo5Eg.js} +6 -6
- package/dist/{index-DXkwaXvx.js.map → index-CQ_mo5Eg.js.map} +1 -1
- package/dist/{index-t3j3ZF8E.js → index-CSoASUv1.js} +5 -5
- package/dist/{index-t3j3ZF8E.js.map → index-CSoASUv1.js.map} +1 -1
- package/dist/{index-Dy4jGo4x.js → index-CVJKjJGv.js} +5 -5
- package/dist/{index-Dy4jGo4x.js.map → index-CVJKjJGv.js.map} +1 -1
- package/dist/{index-BUWTt_8s.js → index-Cv4JGkHO.js} +5 -5
- package/dist/{index-BUWTt_8s.js.map → index-Cv4JGkHO.js.map} +1 -1
- package/dist/{index-Cdu6WHsa.js → index-D5CZAWnJ.js} +4 -4
- package/dist/{index-Cdu6WHsa.js.map → index-D5CZAWnJ.js.map} +1 -1
- package/dist/{index-DHYMtecu.js → index-DVUJikiN.js} +5 -5
- package/dist/{index-DHYMtecu.js.map → index-DVUJikiN.js.map} +1 -1
- package/dist/{index-DG77FUkS.js → index-Dhzhtagm.js} +5 -5
- package/dist/{index-DG77FUkS.js.map → index-Dhzhtagm.js.map} +1 -1
- package/dist/{index-T15Mxwpw.js → index-DkmPuuV8.js} +6 -6
- package/dist/{index-T15Mxwpw.js.map → index-DkmPuuV8.js.map} +1 -1
- package/dist/{index-BEYR5f2d.js → index-DoFkdyxp.js} +5 -5
- package/dist/{index-BEYR5f2d.js.map → index-DoFkdyxp.js.map} +1 -1
- package/dist/{index-1mMgdK6h.js → index-Dp7Av-Oy.js} +5 -5
- package/dist/{index-1mMgdK6h.js.map → index-Dp7Av-Oy.js.map} +1 -1
- package/dist/{index-B6z6eyJE.js → index-Du2TCRQq.js} +5 -5
- package/dist/{index-B6z6eyJE.js.map → index-Du2TCRQq.js.map} +1 -1
- package/dist/{index-C_ExmNre.js → index-XTTodJI4.js} +5 -5
- package/dist/{index-C_ExmNre.js.map → index-XTTodJI4.js.map} +1 -1
- package/dist/{index-BjuvAqGb.js → index-tjFCL7Y-.js} +4 -4
- package/dist/{index-BjuvAqGb.js.map → index-tjFCL7Y-.js.map} +1 -1
- package/dist/{index-DXVl7yqM.js → index-yOOAOJHG.js} +5 -5
- package/dist/{index-DXVl7yqM.js.map → index-yOOAOJHG.js.map} +1 -1
- package/dist/index.js +29 -29
- package/dist/{pies.utils-dB2uJu3l.js → pies.utils-DCy5LWcY.js} +5 -5
- package/dist/{pies.utils-dB2uJu3l.js.map → pies.utils-DCy5LWcY.js.map} +1 -1
- package/dist/remarkable-pro.css +1 -1
- package/dist/{tables.utils-B8IT-c8T.js → tables.utils-8OmfcPmH.js} +4 -4
- package/dist/{tables.utils-B8IT-c8T.js.map → tables.utils-8OmfcPmH.js.map} +1 -1
- package/dist/{timeRange.utils-DIFMUM1C.js → timeRange.utils-81KUBS9O.js} +2 -2
- package/dist/{timeRange.utils-DIFMUM1C.js.map → timeRange.utils-81KUBS9O.js.map} +1 -1
- package/package.json +2 -2
- package/dist/ChartCard-B5IaBBTs.js +0 -124
- package/dist/ChartCard-B5IaBBTs.js.map +0 -1
- package/dist/charts.utils-g6NE_Jo3.js.map +0 -1
package/dist/ColorEditor.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineEditor as l } from "@embeddable.com/react";
|
|
2
|
-
import { j as r, A as a, I as i, r as p, V as u } from "./Color.type.emb-
|
|
2
|
+
import { j as r, A as a, I as i, r as p, V as u } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
3
3
|
import { useState as m, useEffect as C } from "react";
|
|
4
4
|
const I = "_colorInputContainer_1o1qe_1", d = "_colorInput_1o1qe_1", s = {
|
|
5
5
|
colorInputContainer: I,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as i } from "@embeddable.com/react";
|
|
2
|
-
import { V as r } from "./Color.type.emb-
|
|
3
|
-
import { D as t } from "./index-
|
|
4
|
-
import { b as e, C as a } from "./component.inputs.constants-
|
|
2
|
+
import { V as r } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
3
|
+
import { D as t } from "./index-tjFCL7Y-.js";
|
|
4
|
+
import { b as e, C as a } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
5
|
const n = {
|
|
6
6
|
name: "ComparisonPeriodSelectFieldPro",
|
|
7
7
|
label: "Comparison Period Select Field",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useTheme as v, defineComponent as C } from "@embeddable.com/react";
|
|
2
|
-
import { j as l, f as y, V as s } from "./Color.type.emb-
|
|
2
|
+
import { j as l, f as y, V as s } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
3
3
|
import { u as D, g as P, a as V, b as w } from "./dates.utils-BF32dTLi.js";
|
|
4
|
-
import { a as S, r as j, i as k, b as a } from "./component.inputs.constants-
|
|
5
|
-
import { E as M } from "./EditorCard-
|
|
4
|
+
import { a as S, r as j, i as k, b as a } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
|
+
import { E as M } from "./EditorCard-1Z3UFd1D.js";
|
|
6
6
|
const T = (e) => {
|
|
7
7
|
const t = v();
|
|
8
8
|
S(t);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as n } from "@embeddable.com/react";
|
|
2
|
-
import { V as t } from "./Color.type.emb-
|
|
3
|
-
import { D as l } from "./index-
|
|
4
|
-
import { b as e } from "./component.inputs.constants-
|
|
2
|
+
import { V as t } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
3
|
+
import { D as l } from "./index-D5CZAWnJ.js";
|
|
4
|
+
import { b as e } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
5
|
const o = {
|
|
6
6
|
name: "DateRangeSelectFieldPro",
|
|
7
7
|
label: "Date-Range Picker - Presets",
|
package/dist/DonutChartPro.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { V as o, l as n } from "./Color.type.emb-
|
|
1
|
+
import { V as o, l as n } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
2
2
|
import { defineComponent as a } from "@embeddable.com/react";
|
|
3
|
-
import { D as s } from "./index-
|
|
4
|
-
import { b as e } from "./component.inputs.constants-
|
|
3
|
+
import { D as s } from "./index-BOI6FOwo.js";
|
|
4
|
+
import { b as e } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
5
|
const r = {
|
|
6
6
|
name: "DonutChartPro",
|
|
7
7
|
label: "Donut Chart",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { D as n } from "./index-
|
|
2
|
-
import { V as r, l as t } from "./Color.type.emb-
|
|
1
|
+
import { D as n } from "./index-Boogtc12.js";
|
|
2
|
+
import { V as r, l as t } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
3
3
|
import { defineComponent as o } from "@embeddable.com/react";
|
|
4
|
-
import { b as e } from "./component.inputs.constants-
|
|
4
|
+
import { b as e } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
5
|
const s = {
|
|
6
6
|
name: "DonutLabelChartPro",
|
|
7
7
|
label: "Donut Label Chart",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { j as r, n as c, o as d, p as m, q as l } from "./Color.type.emb-
|
|
1
|
+
import { j as r, n as c, o as d, p as m, q as l } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
2
2
|
import { useTheme as p } from "@embeddable.com/react";
|
|
3
|
-
import { a as x, i as C, I as j } from "./component.inputs.constants-
|
|
3
|
+
import { a as x, i as C, I as j } from "./component.inputs.constants-CNdmawDt.js";
|
|
4
4
|
const u = "_card_15bw3_1", f = {
|
|
5
5
|
card: u
|
|
6
6
|
}, b = ({
|
|
@@ -29,4 +29,4 @@ const u = "_card_15bw3_1", f = {
|
|
|
29
29
|
export {
|
|
30
30
|
b as E
|
|
31
31
|
};
|
|
32
|
-
//# sourceMappingURL=EditorCard-
|
|
32
|
+
//# sourceMappingURL=EditorCard-1Z3UFd1D.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorCard-
|
|
1
|
+
{"version":3,"file":"EditorCard-1Z3UFd1D.js","sources":["../src/components/editors/shared/EditorCard/EditorCard.tsx"],"sourcesContent":["import { useTheme } from '@embeddable.com/react';\nimport { i18n, i18nSetup } from '../../../../theme/i18n/i18n';\nimport styles from './EditorCard.module.css';\nimport { FC } from 'react';\nimport { Theme } from '../../../../theme/theme.types';\nimport { Card, CardContent, CardFeedback, CardHeader } from '@embeddable.com/remarkable-ui';\nimport { IconAlertCircle } from '@tabler/icons-react';\n\ntype EditorCardProps = {\n title?: string;\n subtitle?: string;\n children: React.ReactNode;\n errorMessage?: string;\n};\n\nexport const EditorCard: FC<EditorCardProps> = ({\n title,\n subtitle,\n children,\n errorMessage,\n ...props\n}) => {\n const theme: Theme = useTheme() as Theme;\n i18nSetup(theme);\n\n const getDisplay = () => {\n if (errorMessage) {\n return (\n <CardFeedback\n variant=\"error\"\n icon={IconAlertCircle}\n title={i18n.t('editors.errorTitle')}\n message={errorMessage}\n />\n );\n }\n\n return children;\n };\n\n return (\n <Card className={styles.card} {...props}>\n <CardHeader title={title} subtitle={subtitle} />\n <CardContent>{getDisplay()}</CardContent>\n </Card>\n );\n};\n"],"names":["EditorCard","title","subtitle","children","errorMessage","props","theme","useTheme","i18nSetup","getDisplay","jsx","CardFeedback","IconAlertCircle","i18n","Card","styles","CardHeader","CardContent"],"mappings":";;;;;GAeaA,IAAkC,CAAC;AAAA,EAC9C,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,GAAGC;AACL,MAAM;AACJ,QAAMC,IAAeC,EAAA;AACrB,EAAAC,EAAUF,CAAK;AAEf,QAAMG,IAAa,MACbL,IAEAM,gBAAAA,EAAAA;AAAAA,IAACC;AAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,MAAMC;AAAA,MACN,OAAOC,EAAK,EAAE,oBAAoB;AAAA,MAClC,SAAST;AAAA,IAAA;AAAA,EAAA,IAKRD;AAGT,gCACGW,GAAA,EAAK,WAAWC,EAAO,MAAO,GAAGV,GAChC,UAAA;AAAA,IAAAK,gBAAAA,EAAAA,IAACM,GAAA,EAAW,OAAAf,GAAc,UAAAC,EAAA,CAAoB;AAAA,IAC9CQ,gBAAAA,EAAAA,IAACO,GAAA,EAAa,UAAAR,EAAA,EAAW,CAAE;AAAA,EAAA,GAC7B;AAEJ;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useTheme as T, defineComponent as w } from "@embeddable.com/react";
|
|
2
|
-
import { j as m, S as F, V as C } from "./Color.type.emb-
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { c as
|
|
5
|
-
import { E as P } from "./EditorCard-
|
|
2
|
+
import { j as m, S as F, V as C } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
3
|
+
import { useMemo as k, useEffect as E } from "react";
|
|
4
|
+
import { c as G, a as O, r as D, b as i } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
|
+
import { E as P } from "./EditorCard-1Z3UFd1D.js";
|
|
6
6
|
const t = {
|
|
7
7
|
second: "second",
|
|
8
8
|
minute: "minute",
|
|
@@ -23,73 +23,80 @@ const t = {
|
|
|
23
23
|
{ value: t.year, label: "defaults.granularityOptions.year|Year" }
|
|
24
24
|
], q = 1, x = 100, A = () => V.map((e) => ({
|
|
25
25
|
...e,
|
|
26
|
-
label:
|
|
27
|
-
})),
|
|
26
|
+
label: G(e.label)
|
|
27
|
+
})), p = (e) => {
|
|
28
28
|
if (e instanceof Date) return isNaN(e.getTime()) ? null : e;
|
|
29
29
|
if (typeof e == "string" || typeof e == "number") {
|
|
30
30
|
const a = new Date(e);
|
|
31
31
|
return isNaN(a.getTime()) ? null : a;
|
|
32
32
|
}
|
|
33
33
|
return null;
|
|
34
|
-
},
|
|
34
|
+
}, l = (e) => new Date(e.getTime() + 1), o = (e, a, r) => (a.getTime() - e.getTime()) / r;
|
|
35
35
|
function M(e, a, r) {
|
|
36
36
|
if (e > a) return 0;
|
|
37
37
|
switch (r) {
|
|
38
38
|
case t.second:
|
|
39
|
-
return
|
|
39
|
+
return o(e, l(a), 1e3);
|
|
40
40
|
case t.minute:
|
|
41
|
-
return
|
|
41
|
+
return o(e, l(a), 60 * 1e3);
|
|
42
42
|
case t.hour:
|
|
43
|
-
return
|
|
43
|
+
return o(e, l(a), 3600 * 1e3);
|
|
44
44
|
case t.day:
|
|
45
|
-
return
|
|
45
|
+
return o(e, l(a), 1440 * 60 * 1e3);
|
|
46
46
|
case t.week:
|
|
47
|
-
return
|
|
47
|
+
return o(e, l(a), 10080 * 60 * 1e3);
|
|
48
48
|
case t.month:
|
|
49
|
-
return
|
|
49
|
+
return o(e, l(a), 672 * 60 * 60 * 1e3);
|
|
50
50
|
// shortest month
|
|
51
51
|
case t.quarter:
|
|
52
|
-
return
|
|
52
|
+
return o(e, l(a), 2160 * 60 * 60 * 1e3);
|
|
53
53
|
// shortest quarter
|
|
54
54
|
case t.year:
|
|
55
|
-
return
|
|
55
|
+
return o(e, l(a), 365 * 24 * 60 * 60 * 1e3);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
const N = (e, a, r) => {
|
|
59
|
-
const
|
|
60
|
-
return
|
|
59
|
+
const n = M(e, a, r);
|
|
60
|
+
return n >= q && n <= x;
|
|
61
61
|
}, U = (e, a) => {
|
|
62
|
-
const r =
|
|
63
|
-
if (!r || !
|
|
64
|
-
const
|
|
65
|
-
for (const
|
|
66
|
-
const d =
|
|
67
|
-
N(r,
|
|
62
|
+
const r = p(e == null ? void 0 : e.from), n = p(e == null ? void 0 : e.to);
|
|
63
|
+
if (!r || !n) return a;
|
|
64
|
+
const s = /* @__PURE__ */ new Set();
|
|
65
|
+
for (const u of a) {
|
|
66
|
+
const d = u.value;
|
|
67
|
+
N(r, n, d) && s.add(d);
|
|
68
68
|
}
|
|
69
|
-
return a.filter((
|
|
69
|
+
return a.filter((u) => s.has(u.value));
|
|
70
|
+
}, g = (e, a) => {
|
|
71
|
+
var n;
|
|
72
|
+
if (!a)
|
|
73
|
+
return;
|
|
74
|
+
if (e.some((s) => s.value === a))
|
|
75
|
+
return a;
|
|
76
|
+
const r = e.length > 2 ? 1 : 0;
|
|
77
|
+
return (n = e[r]) == null ? void 0 : n.value;
|
|
70
78
|
}, _ = (e) => {
|
|
71
79
|
const a = T();
|
|
72
|
-
|
|
73
|
-
const { granularity: r, granularities:
|
|
74
|
-
|
|
75
|
-
v.filter((c) =>
|
|
76
|
-
), [
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
f && o(f);
|
|
80
|
+
O(a);
|
|
81
|
+
const { granularity: r, granularities: n, clearable: s, onChange: u } = e, { description: d, placeholder: b, title: h, primaryTimeRange: f } = D(e), v = A(), y = k(() => U(
|
|
82
|
+
f,
|
|
83
|
+
v.filter((c) => n == null ? void 0 : n.includes(c.value))
|
|
84
|
+
), [f, n]);
|
|
85
|
+
E(() => {
|
|
86
|
+
if (r && !y.some((c) => c.value === r)) {
|
|
87
|
+
const c = g(y, r);
|
|
88
|
+
c && u(c);
|
|
82
89
|
}
|
|
83
|
-
}, [
|
|
84
|
-
const S =
|
|
90
|
+
}, [y, r, u]);
|
|
91
|
+
const S = g(y, r);
|
|
85
92
|
return /* @__PURE__ */ m.jsx(P, { title: h, subtitle: d, children: /* @__PURE__ */ m.jsx(
|
|
86
93
|
F,
|
|
87
94
|
{
|
|
88
|
-
clearable:
|
|
95
|
+
clearable: s,
|
|
89
96
|
placeholder: b,
|
|
90
97
|
value: S,
|
|
91
|
-
options:
|
|
92
|
-
onChange:
|
|
98
|
+
options: y,
|
|
99
|
+
onChange: u
|
|
93
100
|
}
|
|
94
101
|
) });
|
|
95
102
|
}, j = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GranularitySelectFieldPro.js","sources":["../src/theme/defaults/defaults.GranularityOptions.constants.ts","../src/components/editors/GranularitySelectFieldPro/GranularitySelectFieldPro.utils.ts","../src/components/editors/GranularitySelectFieldPro/index.tsx","../src/components/editors/GranularitySelectFieldPro/GranularitySelectFieldPro.emb.ts"],"sourcesContent":["import { SelectListOptionProps } from '@embeddable.com/remarkable-ui';\n\nexport const Granularity = {\n second: 'second',\n minute: 'minute',\n hour: 'hour',\n day: 'day',\n week: 'week',\n month: 'month',\n quarter: 'quarter',\n year: 'year',\n} as const;\n\nexport type TGranularity = keyof typeof Granularity;\nexport type TGranularityValue = (typeof Granularity)[TGranularity];\n\nexport const defaultGranularitySelectFieldOptions: SelectListOptionProps[] = [\n { value: Granularity.second, label: 'defaults.granularityOptions.second|Second' },\n { value: Granularity.minute, label: 'defaults.granularityOptions.minute|Minute' },\n { value: Granularity.hour, label: 'defaults.granularityOptions.hour|Hour' },\n { value: Granularity.day, label: 'defaults.granularityOptions.day|Day' },\n { value: Granularity.week, label: 'defaults.granularityOptions.week|Week' },\n { value: Granularity.month, label: 'defaults.granularityOptions.month|Month' },\n { value: Granularity.quarter, label: 'defaults.granularityOptions.quarter|Quarter' },\n { value: Granularity.year, label: 'defaults.granularityOptions.year|Year' },\n];\n","import { SelectListOptionProps } from '@embeddable.com/remarkable-ui';\nimport { TimeRange } from '@embeddable.com/core';\nimport {\n defaultGranularitySelectFieldOptions,\n Granularity,\n TGranularity,\n TGranularityValue,\n} from '../../../theme/defaults/defaults.GranularityOptions.constants';\nimport { resolveI18nString } from '../../component.utils';\n\nconst DEFAULT_MIN_BUCKETS = 1;\nconst DEFAULT_MAX_BUCKETS = 100;\n\nexport const getGranularitySelectFieldOptions = () =>\n defaultGranularitySelectFieldOptions.map((opt) => ({\n ...opt,\n label: resolveI18nString(opt.label),\n }));\n\n// Convert possibly-string timestamps to Date safely.\nconst toDate = (d: unknown): Date | null => {\n if (d instanceof Date) return isNaN(d.getTime()) ? null : d;\n if (typeof d === 'string' || typeof d === 'number') {\n const parsed = new Date(d);\n return isNaN(parsed.getTime()) ? null : parsed;\n }\n return null;\n};\n\n// Inclusive end -> Exclusive end helper (only used for sub-day diffs)\nconst toExclusiveEnd = (endInclusive: Date): Date => new Date(endInclusive.getTime() + 1);\n\nconst bucketCountByUnit = (start: Date, endExclusive: Date, unitMs: number): number => {\n return (endExclusive.getTime() - start.getTime()) / unitMs;\n};\n\n// Bucket counting (treat end as INCLUSIVE)\nfunction bucketCount(start: Date, endInclusive: Date, granularity: TGranularity): number {\n if (start > endInclusive) return 0;\n\n switch (granularity) {\n case Granularity.second:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 1000);\n\n case Granularity.minute:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 60 * 1000);\n\n case Granularity.hour:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 60 * 60 * 1000);\n\n case Granularity.day:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 24 * 60 * 60 * 1000);\n\n case Granularity.week:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 7 * 24 * 60 * 60 * 1000);\n\n case Granularity.month:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 28 * 24 * 60 * 60 * 1000); // shortest month\n\n case Granularity.quarter:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 90 * 24 * 60 * 60 * 1000); // shortest quarter\n\n case Granularity.year:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 365 * 24 * 60 * 60 * 1000); // shortest year\n }\n}\n\nconst isGranularityValid = (\n start: Date,\n endInclusive: Date,\n granularity: TGranularityValue,\n): boolean => {\n const buckets = bucketCount(start, endInclusive, granularity);\n return buckets >= DEFAULT_MIN_BUCKETS && buckets <= DEFAULT_MAX_BUCKETS;\n};\n\nexport const getAvailableGranularityOptionsFromTimeRange = (\n timeRange: TimeRange,\n allOptions: SelectListOptionProps[],\n): SelectListOptionProps[] => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const from = toDate((timeRange as any)?.from);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const to = toDate((timeRange as any)?.to);\n\n // If we can’t parse range, don’t hide anything (fail open)\n if (!from || !to) return allOptions;\n\n const validSet = new Set<TGranularityValue>();\n\n for (const opt of allOptions) {\n const g = opt.value as TGranularityValue;\n if (isGranularityValid(from, to, g)) {\n validSet.add(g);\n }\n }\n\n // preserve original UI ordering\n return allOptions.filter((opt) => validSet.has(opt.value as TGranularityValue));\n};\n","import { useEffect, useMemo } from 'react';\nimport { useTheme } from '@embeddable.com/react';\nimport { SingleSelectField } from '@embeddable.com/remarkable-ui';\nimport { TimeRange } from '@embeddable.com/core';\nimport { Theme } from '../../../theme/theme.types';\nimport { i18nSetup } from '../../../theme/i18n/i18n';\nimport { resolveI18nProps } from '../../component.utils';\nimport { EditorCard } from '../shared/EditorCard/EditorCard';\nimport {\n getAvailableGranularityOptionsFromTimeRange,\n getGranularitySelectFieldOptions,\n} from './GranularitySelectFieldPro.utils';\n\ntype GranularitySelectFieldProProps = {\n description?: string;\n onChange: (newGranularity: string) => void;\n placeholder?: string;\n primaryTimeRange: TimeRange;\n title?: string;\n granularity?: string;\n granularities?: string[];\n clearable?: boolean;\n};\n\nconst GranularitySelectFieldPro = (props: GranularitySelectFieldProProps) => {\n const theme: Theme = useTheme() as Theme;\n i18nSetup(theme);\n\n const { granularity, granularities, clearable, onChange } = props;\n const { description, placeholder, title, primaryTimeRange } = resolveI18nProps(props);\n\n const granularitySelectFieldOptions = getGranularitySelectFieldOptions();\n\n const availableOptions = useMemo(() => {\n return getAvailableGranularityOptionsFromTimeRange(\n primaryTimeRange,\n granularitySelectFieldOptions.filter((opt) => granularities?.includes(opt.value as string)),\n );\n }, [primaryTimeRange, granularities]);\n\n useEffect(() => {\n if (granularity) {\n // Selected granularity is not available - select 2nd or 1st available (if 2nd is not available)\n if (!availableOptions.some((opt) => opt.value === granularity)) {\n const newGranularity = (availableOptions[1] ?? availableOptions[0])?.value as string;\n if (newGranularity) {\n onChange(newGranularity);\n }\n }\n }\n }, [availableOptions, granularity, onChange]);\n\n const safeValue = availableOptions.some((opt) => opt.value === granularity)\n ? granularity\n : undefined;\n\n return (\n <EditorCard title={title} subtitle={description}>\n <SingleSelectField\n clearable={clearable}\n placeholder={placeholder}\n value={safeValue}\n options={availableOptions}\n onChange={onChange}\n />\n </EditorCard>\n );\n};\n\nexport default GranularitySelectFieldPro;\n","import { defineComponent, EmbeddedComponentMeta, Inputs } from '@embeddable.com/react';\nimport { Value } from '@embeddable.com/core';\nimport DateTimeSelectFieldPro from './index';\nimport { inputs } from '../../component.inputs.constants';\nimport { Granularity } from '../../../theme/defaults/defaults.GranularityOptions.constants';\n\nexport const meta = {\n name: 'GranularitySelectFieldPro',\n label: 'Granularity Select Field',\n category: 'Dropdowns',\n defaultWidth: 300,\n defaultHeight: 120,\n inputs: [\n inputs.title,\n inputs.description,\n { ...inputs.placeholder, defaultValue: 'Select a granularity' },\n {\n ...inputs.granularities,\n label: 'Available granularities',\n category: 'Pre-configured variables',\n // Ignore seconds and minutes\n defaultValue: [\n Granularity.hour,\n Granularity.day,\n Granularity.week,\n Granularity.month,\n Granularity.quarter,\n Granularity.year,\n ],\n },\n {\n ...inputs.granularity,\n label: 'Selected granularity',\n category: 'Pre-configured variables',\n },\n {\n ...inputs.timeRange,\n name: 'primaryTimeRange',\n label: 'Primary date-range',\n description:\n 'Connect your primary date-range variable to enable automatic selection of the most appropriate granularity',\n category: 'Pre-configured variables',\n },\n { ...inputs.clearable, defaultValue: false },\n ],\n events: [\n {\n name: 'onChange',\n label: 'Selected granularity updated',\n properties: [\n {\n name: 'value',\n label: 'Selected granularity',\n type: 'granularity',\n },\n ],\n },\n ],\n variables: [\n {\n name: 'granularity value',\n type: 'granularity',\n defaultValue: 'day',\n inputs: ['granularity'],\n events: [{ name: 'onChange', property: 'value' }],\n },\n ],\n} as const satisfies EmbeddedComponentMeta;\n\nexport default defineComponent(DateTimeSelectFieldPro, meta, {\n props: (inputs: Inputs<typeof meta>) => {\n return {\n ...inputs,\n };\n },\n events: {\n onChange: (granularity) => ({\n value: granularity ?? Value.noFilter(),\n }),\n },\n});\n"],"names":["Granularity","defaultGranularitySelectFieldOptions","DEFAULT_MIN_BUCKETS","DEFAULT_MAX_BUCKETS","getGranularitySelectFieldOptions","opt","resolveI18nString","toDate","d","parsed","toExclusiveEnd","endInclusive","bucketCountByUnit","start","endExclusive","unitMs","bucketCount","granularity","isGranularityValid","buckets","getAvailableGranularityOptionsFromTimeRange","timeRange","allOptions","from","to","validSet","g","GranularitySelectFieldPro","props","theme","useTheme","i18nSetup","granularities","clearable","onChange","description","placeholder","title","primaryTimeRange","resolveI18nProps","granularitySelectFieldOptions","availableOptions","useMemo","useEffect","newGranularity","_a","safeValue","jsx","EditorCard","SingleSelectField","meta","inputs","GranularitySelectFieldPro_emb","defineComponent","DateTimeSelectFieldPro","Value"],"mappings":";;;;;AAEO,MAAMA,IAAc;AAAA,EACzB,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AACR,GAKaC,IAAgE;AAAA,EAC3E,EAAE,OAAOD,EAAY,QAAQ,OAAO,4CAAA;AAAA,EACpC,EAAE,OAAOA,EAAY,QAAQ,OAAO,4CAAA;AAAA,EACpC,EAAE,OAAOA,EAAY,MAAM,OAAO,wCAAA;AAAA,EAClC,EAAE,OAAOA,EAAY,KAAK,OAAO,sCAAA;AAAA,EACjC,EAAE,OAAOA,EAAY,MAAM,OAAO,wCAAA;AAAA,EAClC,EAAE,OAAOA,EAAY,OAAO,OAAO,0CAAA;AAAA,EACnC,EAAE,OAAOA,EAAY,SAAS,OAAO,8CAAA;AAAA,EACrC,EAAE,OAAOA,EAAY,MAAM,OAAO,wCAAA;AACpC,GCfME,IAAsB,GACtBC,IAAs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,WAAW,cAAc,GAAA;AAAA,EAAM;AAAA,EAE7C,QAAQ;AAAA,IACN;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,YAAY;AAAA,QACV;AAAA,UACE,MAAM;AAAA,UACN,OAAO;AAAA,UACP,MAAM;AAAA,QAAA;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EAEF,WAAW;AAAA,IACT;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,MACN,cAAc;AAAA,MACd,QAAQ,CAAC,aAAa;AAAA,MACtB,QAAQ,CAAC,EAAE,MAAM,YAAY,UAAU,SAAS;AAAA,IAAA;AAAA,EAClD;AAEJ,GAEAC,IAAeC,EAAgBC,GAAwBJ,GAAM;AAAA,EAC3D,OAAO,CAACC,OACC;AAAA,IACL,GAAGA;AAAAA,EAAA;AAAA,EAGP,QAAQ;AAAA,IACN,UAAU,CAAClC,OAAiB;AAAA,MAC1B,OAAOA,KAAesC,EAAM,SAAA;AAAA,IAAS;AAAA,EACvC;AAEJ,CAAC;"}
|
|
1
|
+
{"version":3,"file":"GranularitySelectFieldPro.js","sources":["../src/theme/defaults/defaults.GranularityOptions.constants.ts","../src/components/editors/GranularitySelectFieldPro/GranularitySelectFieldPro.utils.ts","../src/components/editors/GranularitySelectFieldPro/index.tsx","../src/components/editors/GranularitySelectFieldPro/GranularitySelectFieldPro.emb.ts"],"sourcesContent":["import { SelectListOptionProps } from '@embeddable.com/remarkable-ui';\n\nexport const Granularity = {\n second: 'second',\n minute: 'minute',\n hour: 'hour',\n day: 'day',\n week: 'week',\n month: 'month',\n quarter: 'quarter',\n year: 'year',\n} as const;\n\nexport type TGranularity = keyof typeof Granularity;\nexport type TGranularityValue = (typeof Granularity)[TGranularity];\n\nexport const defaultGranularitySelectFieldOptions: SelectListOptionProps[] = [\n { value: Granularity.second, label: 'defaults.granularityOptions.second|Second' },\n { value: Granularity.minute, label: 'defaults.granularityOptions.minute|Minute' },\n { value: Granularity.hour, label: 'defaults.granularityOptions.hour|Hour' },\n { value: Granularity.day, label: 'defaults.granularityOptions.day|Day' },\n { value: Granularity.week, label: 'defaults.granularityOptions.week|Week' },\n { value: Granularity.month, label: 'defaults.granularityOptions.month|Month' },\n { value: Granularity.quarter, label: 'defaults.granularityOptions.quarter|Quarter' },\n { value: Granularity.year, label: 'defaults.granularityOptions.year|Year' },\n];\n","import { SelectListOptionProps } from '@embeddable.com/remarkable-ui';\nimport { TimeRange } from '@embeddable.com/core';\nimport {\n defaultGranularitySelectFieldOptions,\n Granularity,\n TGranularity,\n TGranularityValue,\n} from '../../../theme/defaults/defaults.GranularityOptions.constants';\nimport { resolveI18nString } from '../../component.utils';\n\nconst DEFAULT_MIN_BUCKETS = 1;\nconst DEFAULT_MAX_BUCKETS = 100;\n\nexport const getGranularitySelectFieldOptions = (): SelectListOptionProps[] => {\n return defaultGranularitySelectFieldOptions.map((opt) => ({\n ...opt,\n label: resolveI18nString(opt.label),\n }));\n};\n\n// Convert possibly-string timestamps to Date safely.\nconst toDate = (d: unknown): Date | null => {\n if (d instanceof Date) return isNaN(d.getTime()) ? null : d;\n if (typeof d === 'string' || typeof d === 'number') {\n const parsed = new Date(d);\n return isNaN(parsed.getTime()) ? null : parsed;\n }\n return null;\n};\n\n// Inclusive end -> Exclusive end helper (only used for sub-day diffs)\nconst toExclusiveEnd = (endInclusive: Date): Date => new Date(endInclusive.getTime() + 1);\n\nconst bucketCountByUnit = (start: Date, endExclusive: Date, unitMs: number): number => {\n return (endExclusive.getTime() - start.getTime()) / unitMs;\n};\n\n// Bucket counting (treat end as INCLUSIVE)\nfunction bucketCount(start: Date, endInclusive: Date, granularity: TGranularity): number {\n if (start > endInclusive) return 0;\n\n switch (granularity) {\n case Granularity.second:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 1000);\n\n case Granularity.minute:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 60 * 1000);\n\n case Granularity.hour:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 60 * 60 * 1000);\n\n case Granularity.day:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 24 * 60 * 60 * 1000);\n\n case Granularity.week:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 7 * 24 * 60 * 60 * 1000);\n\n case Granularity.month:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 28 * 24 * 60 * 60 * 1000); // shortest month\n\n case Granularity.quarter:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 90 * 24 * 60 * 60 * 1000); // shortest quarter\n\n case Granularity.year:\n return bucketCountByUnit(start, toExclusiveEnd(endInclusive), 365 * 24 * 60 * 60 * 1000); // shortest year\n }\n}\n\nconst isGranularityValid = (\n start: Date,\n endInclusive: Date,\n granularity: TGranularityValue,\n): boolean => {\n const buckets = bucketCount(start, endInclusive, granularity);\n return buckets >= DEFAULT_MIN_BUCKETS && buckets <= DEFAULT_MAX_BUCKETS;\n};\n\nexport const getAvailableGranularityOptionsFromTimeRange = (\n timeRange: TimeRange,\n allOptions: SelectListOptionProps[],\n): SelectListOptionProps[] => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const from = toDate((timeRange as any)?.from);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const to = toDate((timeRange as any)?.to);\n\n // If we can’t parse range, don’t hide anything (fail open)\n if (!from || !to) return allOptions;\n\n const validSet = new Set<TGranularityValue>();\n\n for (const opt of allOptions) {\n const g = opt.value as TGranularityValue;\n if (isGranularityValid(from, to, g)) {\n validSet.add(g);\n }\n }\n\n // preserve original UI ordering\n return allOptions.filter((opt) => validSet.has(opt.value as TGranularityValue));\n};\n\nexport const getSafeSelection = (\n availableOptions: SelectListOptionProps[],\n granularity?: string,\n): string | undefined => {\n if (!granularity) {\n return undefined;\n }\n\n if (availableOptions.some((opt) => opt.value === granularity)) {\n return granularity;\n }\n\n const optionToSelect = availableOptions.length > 2 ? 1 : 0;\n\n return availableOptions[optionToSelect]?.value as string;\n};\n","import { useEffect, useMemo } from 'react';\nimport { useTheme } from '@embeddable.com/react';\nimport { SingleSelectField } from '@embeddable.com/remarkable-ui';\nimport { TimeRange } from '@embeddable.com/core';\nimport { Theme } from '../../../theme/theme.types';\nimport { i18nSetup } from '../../../theme/i18n/i18n';\nimport { resolveI18nProps } from '../../component.utils';\nimport { EditorCard } from '../shared/EditorCard/EditorCard';\nimport {\n getAvailableGranularityOptionsFromTimeRange,\n getGranularitySelectFieldOptions,\n getSafeSelection,\n} from './GranularitySelectFieldPro.utils';\n\ntype GranularitySelectFieldProProps = {\n description?: string;\n onChange: (newGranularity: string) => void;\n placeholder?: string;\n primaryTimeRange: TimeRange;\n title?: string;\n granularity?: string;\n granularities?: string[];\n clearable?: boolean;\n};\n\nconst GranularitySelectFieldPro = (props: GranularitySelectFieldProProps) => {\n const theme: Theme = useTheme() as Theme;\n i18nSetup(theme);\n\n const { granularity, granularities, clearable, onChange } = props;\n const { description, placeholder, title, primaryTimeRange } = resolveI18nProps(props);\n\n const granularitySelectFieldOptions = getGranularitySelectFieldOptions();\n\n const availableOptions = useMemo(() => {\n return getAvailableGranularityOptionsFromTimeRange(\n primaryTimeRange,\n granularitySelectFieldOptions.filter((opt) => granularities?.includes(opt.value as string)),\n );\n }, [primaryTimeRange, granularities]);\n\n useEffect(() => {\n if (granularity) {\n // Selected granularity is not available\n // Select 1st available option when number of options is =< 2\n // Select 2nd option to avoid when number of options > 2\n if (!availableOptions.some((opt) => opt.value === granularity)) {\n const newGranularity = getSafeSelection(availableOptions, granularity);\n if (newGranularity) {\n onChange(newGranularity);\n }\n }\n }\n }, [availableOptions, granularity, onChange]);\n\n const safeValue = getSafeSelection(availableOptions, granularity);\n\n return (\n <EditorCard title={title} subtitle={description}>\n <SingleSelectField\n clearable={clearable}\n placeholder={placeholder}\n value={safeValue}\n options={availableOptions}\n onChange={onChange}\n />\n </EditorCard>\n );\n};\n\nexport default GranularitySelectFieldPro;\n","import { defineComponent, EmbeddedComponentMeta, Inputs } from '@embeddable.com/react';\nimport { Value } from '@embeddable.com/core';\nimport DateTimeSelectFieldPro from './index';\nimport { inputs } from '../../component.inputs.constants';\nimport { Granularity } from '../../../theme/defaults/defaults.GranularityOptions.constants';\n\nexport const meta = {\n name: 'GranularitySelectFieldPro',\n label: 'Granularity Select Field',\n category: 'Dropdowns',\n defaultWidth: 300,\n defaultHeight: 120,\n inputs: [\n inputs.title,\n inputs.description,\n { ...inputs.placeholder, defaultValue: 'Select a granularity' },\n {\n ...inputs.granularities,\n label: 'Available granularities',\n category: 'Pre-configured variables',\n // Ignore seconds and minutes\n defaultValue: [\n Granularity.hour,\n Granularity.day,\n Granularity.week,\n Granularity.month,\n Granularity.quarter,\n Granularity.year,\n ],\n },\n {\n ...inputs.granularity,\n label: 'Selected granularity',\n category: 'Pre-configured variables',\n },\n {\n ...inputs.timeRange,\n name: 'primaryTimeRange',\n label: 'Primary date-range',\n description:\n 'Connect your primary date-range variable to enable automatic selection of the most appropriate granularity',\n category: 'Pre-configured variables',\n },\n { ...inputs.clearable, defaultValue: false },\n ],\n events: [\n {\n name: 'onChange',\n label: 'Selected granularity updated',\n properties: [\n {\n name: 'value',\n label: 'Selected granularity',\n type: 'granularity',\n },\n ],\n },\n ],\n variables: [\n {\n name: 'granularity value',\n type: 'granularity',\n defaultValue: 'day',\n inputs: ['granularity'],\n events: [{ name: 'onChange', property: 'value' }],\n },\n ],\n} as const satisfies EmbeddedComponentMeta;\n\nexport default defineComponent(DateTimeSelectFieldPro, meta, {\n props: (inputs: Inputs<typeof meta>) => {\n return {\n ...inputs,\n };\n },\n events: {\n onChange: (granularity) => ({\n value: granularity ?? Value.noFilter(),\n }),\n },\n});\n"],"names":["Granularity","defaultGranularitySelectFieldOptions","DEFAULT_MIN_BUCKETS","DEFAULT_MAX_BUCKETS","getGranularitySelectFieldOptions","opt","resolveI18nString","toDate","d","parsed","toExclusiveEnd","endInclusive","bucketCountByUnit","start","endExclusive","unitMs","bucketCount","granularity","isGranularityValid","buckets","getAvailableGranularityOptionsFromTimeRange","timeRange","allOptions","from","to","validSet","g","getSafeSelection","availableOptions","optionToSelect","_a","GranularitySelectFieldPro","props","theme","useTheme","i18nSetup","granularities","clearable","onChange","description","placeholder","title","primaryTimeRange","resolveI18nProps","granularitySelectFieldOptions","useMemo","useEffect","newGranularity","safeValue","jsx","EditorCard","SingleSelectField","meta","inputs","GranularitySelectFieldPro_emb","defineComponent","DateTimeSelectFieldPro","Value"],"mappings":";;;;;AAEO,MAAMA,IAAc;AAAA,EACzB,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AACR,GAKaC,IAAgE;AAAA,EAC3E,EAAE,OAAOD,EAAY,QAAQ,OAAO,4CAAA;AAAA,EACpC,EAAE,OAAOA,EAAY,QAAQ,OAAO,4CAAA;AAAA,EACpC,EAAE,OAAOA,EAAY,MAAM,OAAO,wCAAA;AAAA,EAClC,EAAE,OAAOA,EAAY,KAAK,OAAO,sCAAA;AAAA,EACjC,EAAE,OAAOA,EAAY,MAAM,OAAO,wCAAA;AAAA,EAClC,EAAE,OAAOA,EAAY,OAAO,OAAO,0CAAA;AAAA,EACnC,EAAE,OAAOA,EAAY,SAAS,OAAO,8CAAA;AAAA,EACrC,EAAE,OAAOA,EAAY,MAAM,OAAO,wCAAA;AACpC,GCfME,IAAsB,GACtBC,IAAsB,KAEfC,IAAmC,MACvCH,EAAqC,IAAI,CAACI,OAAS;AAAA,EACxD,GAAGA;AAAA,EACH,OAAOC,EAAkBD,EAAI,KAAK;AAAA,EAClC,GAIEE,IAAS,CAACC,MAA4B;AAC1C,MAAIA,aAAa,KAAM,QAAO,MAAMA,EAAE,QAAA,CAAS,IAAI,OAAOA;AAC1D,MAAI,OAAOA,KAAM,YAAY,OAAOA,KAAM,UAAU;AAClD,UAAMC,IAAS,IAAI,KAAKD,CAAC;AACzB,WAAO,MAAMC,EAAO,QAAA,CAA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AAM;AAAA,QAAA;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EAEF,WAAW;AAAA,IACT;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,MACN,cAAc;AAAA,MACd,QAAQ,CAAC,aAAa;AAAA,MACtB,QAAQ,CAAC,EAAE,MAAM,YAAY,UAAU,SAAS;AAAA,IAAA;AAAA,EAClD;AAEJ,GAEAC,IAAeC,EAAgBC,GAAwBJ,GAAM;AAAA,EAC3D,OAAO,CAACC,OACC;AAAA,IACL,GAAGA;AAAAA,EAAA;AAAA,EAGP,QAAQ;AAAA,IACN,UAAU,CAACpC,OAAiB;AAAA,MAC1B,OAAOA,KAAewC,EAAM,SAAA;AAAA,IAAS;AAAA,EACvC;AAEJ,CAAC;"}
|
package/dist/HeatMapPro.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { g as t, l as a } from "./Color.type.emb-
|
|
1
|
+
import { g as t, l as a } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
2
2
|
import { defineComponent as n } from "@embeddable.com/react";
|
|
3
|
-
import { H as i } from "./index-
|
|
4
|
-
import { b as e } from "./component.inputs.constants-
|
|
3
|
+
import { H as i } from "./index-Cv4JGkHO.js";
|
|
4
|
+
import { b as e } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
5
|
const r = {
|
|
6
6
|
name: "HeatMapPro",
|
|
7
7
|
label: "Heat Map",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as n } from "@embeddable.com/react";
|
|
2
|
-
import { K as m } from "./index-
|
|
3
|
-
import { l as r } from "./Color.type.emb-
|
|
4
|
-
import { b as a } from "./component.inputs.constants-
|
|
2
|
+
import { K as m } from "./index-DkmPuuV8.js";
|
|
3
|
+
import { l as r } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
4
|
+
import { b as a } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
5
|
const l = {
|
|
6
6
|
name: "KpiChartNumberComparisonPro",
|
|
7
7
|
label: "Kpi Chart - Number Comparison",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as e } from "@embeddable.com/react";
|
|
2
|
-
import { K as a } from "./index-
|
|
3
|
-
import { l as o } from "./Color.type.emb-
|
|
4
|
-
import { b as r } from "./component.inputs.constants-
|
|
2
|
+
import { K as a } from "./index-Dhzhtagm.js";
|
|
3
|
+
import { l as o } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
4
|
+
import { b as r } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
5
|
const m = {
|
|
6
6
|
name: "KpiChartNumberPro",
|
|
7
7
|
label: "Kpi Chart - Number",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as m } from "@embeddable.com/react";
|
|
2
|
-
import { L as p } from "./index-
|
|
3
|
-
import { V as c, l as s } from "./Color.type.emb-
|
|
4
|
-
import { b as e, s as i } from "./component.inputs.constants-
|
|
2
|
+
import { L as p } from "./index-CQ_mo5Eg.js";
|
|
3
|
+
import { V as c, l as s } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
4
|
+
import { b as e, s as i } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
5
|
const d = {
|
|
6
6
|
name: "LineChartComparisonDefaultPro",
|
|
7
7
|
label: "Line Chart Comparison - Default",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as s } from "@embeddable.com/react";
|
|
2
|
-
import { L as n } from "./index-
|
|
3
|
-
import { V as i, l as o } from "./Color.type.emb-
|
|
4
|
-
import { b as e, s as l } from "./component.inputs.constants-
|
|
2
|
+
import { L as n } from "./index-XTTodJI4.js";
|
|
3
|
+
import { V as i, l as o } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
4
|
+
import { b as e, s as l } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
5
|
const t = {
|
|
6
6
|
name: "LineChartDefaultPro",
|
|
7
7
|
label: "Line Chart - Default",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as a } from "@embeddable.com/react";
|
|
2
|
-
import { L as o } from "./index-
|
|
3
|
-
import { V as i, l as s } from "./Color.type.emb-
|
|
4
|
-
import { b as e } from "./component.inputs.constants-
|
|
2
|
+
import { L as o } from "./index-BBcQWvRk.js";
|
|
3
|
+
import { V as i, l as s } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
4
|
+
import { b as e } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
5
|
const t = {
|
|
6
6
|
name: "LineChartGroupedPro",
|
|
7
7
|
label: "Line Chart - Grouped",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as r } from "@embeddable.com/react";
|
|
2
|
-
import { V as t, l as s } from "./Color.type.emb-
|
|
3
|
-
import { M as d, a as u } from "./index-
|
|
4
|
-
import { b as a } from "./component.inputs.constants-
|
|
2
|
+
import { V as t, l as s } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
3
|
+
import { M as d, a as u } from "./index-CSoASUv1.js";
|
|
4
|
+
import { b as a } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
5
|
const m = {
|
|
6
6
|
name: "MultiSelectFieldPro",
|
|
7
7
|
label: "Multi Select Field",
|
package/dist/PieChartPro.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { V as o, l as a } from "./Color.type.emb-
|
|
1
|
+
import { V as o, l as a } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
2
2
|
import { defineComponent as s } from "@embeddable.com/react";
|
|
3
|
-
import { P as i } from "./index-
|
|
4
|
-
import { b as e } from "./component.inputs.constants-
|
|
3
|
+
import { P as i } from "./index-Dp7Av-Oy.js";
|
|
4
|
+
import { b as e } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
5
|
const n = {
|
|
6
6
|
name: "PieChartPro",
|
|
7
7
|
label: "Pie Chart",
|
package/dist/PivotTablePro.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { l as a } from "./Color.type.emb-
|
|
1
|
+
import { l as a } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
2
2
|
import { defineComponent as n } from "@embeddable.com/react";
|
|
3
|
-
import { P as s } from "./index-
|
|
4
|
-
import { b as e, s as t } from "./component.inputs.constants-
|
|
3
|
+
import { P as s } from "./index-DoFkdyxp.js";
|
|
4
|
+
import { b as e, s as t } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
5
|
const l = {
|
|
6
6
|
name: "PivotTablePro",
|
|
7
7
|
label: "Pivot Table",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as r } from "@embeddable.com/react";
|
|
2
|
-
import { V as l, l as s } from "./Color.type.emb-
|
|
3
|
-
import { M as d, S as m } from "./index-
|
|
4
|
-
import { b as a } from "./component.inputs.constants-
|
|
2
|
+
import { V as l, l as s } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
3
|
+
import { M as d, S as m } from "./index-Du2TCRQq.js";
|
|
4
|
+
import { b as a } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
5
|
const c = {
|
|
6
6
|
name: "SingleSelectFieldPro",
|
|
7
7
|
label: "Single Select Field",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { V as u, l as s, m as f } from "./Color.type.emb-
|
|
1
|
+
import { V as u, l as s, m as f } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
2
2
|
import { defineComponent as g } from "@embeddable.com/react";
|
|
3
|
-
import { T as p } from "./index-
|
|
4
|
-
import { b as n, s as l } from "./component.inputs.constants-
|
|
3
|
+
import { T as p } from "./index-1vsLONt_.js";
|
|
4
|
+
import { b as n, s as l } from "./component.inputs.constants-CNdmawDt.js";
|
|
5
5
|
const b = {
|
|
6
6
|
name: "TableChartPaginated",
|
|
7
7
|
label: "Table Chart - Paginated",
|
package/dist/TableScrollable.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { j as V, t as re, V as oe, l as T, m as ae } from "./Color.type.emb-
|
|
1
|
+
import { j as V, t as re, V as oe, l as T, m as ae } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
2
2
|
import { useTheme as se, defineComponent as ie } from "@embeddable.com/react";
|
|
3
|
-
import { a as le, r as ue, i as ce, b as E, s as S } from "./component.inputs.constants-
|
|
4
|
-
import { C as fe } from "./ChartCard-
|
|
3
|
+
import { a as le, r as ue, i as ce, b as E, s as S } from "./component.inputs.constants-CNdmawDt.js";
|
|
4
|
+
import { C as fe } from "./ChartCard-D_A88_bS.js";
|
|
5
5
|
import { useState as N, useRef as R, useEffect as M, useCallback as de } from "react";
|
|
6
|
-
import { b as me, c as pe } from "./tables.utils-
|
|
6
|
+
import { b as me, c as pe } from "./tables.utils-8OmfcPmH.js";
|
|
7
7
|
const v = 25, { getOwnPropertyNames: ge, getOwnPropertySymbols: he } = Object, { hasOwnProperty: be } = Object.prototype;
|
|
8
8
|
function k(t, e) {
|
|
9
9
|
return function(n, a, i) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as N, C as P, b as v } from "./Color.type.emb-
|
|
2
|
-
import { r as x, g as F } from "./charts.utils-
|
|
3
|
-
import { g as h } from "./formatter.utils-
|
|
1
|
+
import { a as N, C as P, b as v } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
2
|
+
import { r as x, g as F } from "./charts.utils-CUPowt7F.js";
|
|
3
|
+
import { g as h } from "./formatter.utils-BiWZBhcE.js";
|
|
4
4
|
import { g as p, a as g } from "./object.utils-D_Zzon-H.js";
|
|
5
5
|
const I = (c, d) => {
|
|
6
6
|
var b;
|
|
@@ -142,4 +142,4 @@ export {
|
|
|
142
142
|
K as b,
|
|
143
143
|
I as g
|
|
144
144
|
};
|
|
145
|
-
//# sourceMappingURL=bars.utils-
|
|
145
|
+
//# sourceMappingURL=bars.utils-CsJD9MNL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bars.utils-Ck1w7NOo.js","sources":["../src/components/charts/bars/bars.utils.ts"],"sourcesContent":["import { CUBE_DIMENSION_TYPE_TIME, DataResponse, Dimension, Measure } from '@embeddable.com/core';\nimport { Theme } from '../../../theme/theme.types';\nimport { remarkableTheme } from '../../../theme/theme.constants';\nimport { ChartData, ChartOptions } from 'chart.js';\nimport { getThemeFormatter } from '../../../theme/formatter/formatter.utils';\nimport { groupTailAsOther } from '../charts.utils';\nimport { getColor } from '../../../theme/styles/styles.utils';\nimport { getChartColors, getChartContrastColors } from '@embeddable.com/remarkable-ui';\nimport { getObjectStableKey } from '../../../utils.ts/object.utils';\nimport { Context } from 'chartjs-plugin-datalabels';\n\nexport const getBarStackedChartProData = (\n props: {\n data: DataResponse['data'];\n dimension: Dimension;\n groupDimension: Dimension;\n measure: Measure;\n },\n theme: Theme,\n): ChartData<'bar'> => {\n const themeFormatter = getThemeFormatter(theme);\n const { data = [], dimension, groupDimension, measure } = props;\n\n const axis = [...new Set(data.map((d) => d[dimension.name]).filter((d) => d != null))].sort();\n const groupDimensionName = `${groupDimension.name}${groupDimension.nativeType === CUBE_DIMENSION_TYPE_TIME && groupDimension.inputs?.granularity ? `.${groupDimension.inputs.granularity}` : ''}`;\n const groupBy = [...new Set(data.map((d) => d[groupDimensionName]))].filter((d) => d != null);\n\n const themeKey = getObjectStableKey(theme);\n const chartContrastColors = getChartContrastColors();\n const datasets = groupBy.map((groupByItem, index) => {\n const backgroundColor = getColor(\n `${themeKey}.charts.backgroundColors`,\n `${groupDimension.name}.${groupByItem}`,\n theme.charts.backgroundColors ?? chartContrastColors,\n index,\n );\n\n const borderColor = getColor(\n `${themeKey}.charts.borderColors`,\n `${groupDimension.name}.${groupByItem}`,\n theme.charts.borderColors ?? chartContrastColors,\n index,\n );\n\n return {\n label: themeFormatter.data(groupDimension, groupByItem),\n rawLabel: groupByItem,\n backgroundColor,\n borderColor,\n data: axis.map((axisItem) => {\n const record = data.find(\n (d) => d[groupDimensionName] === groupByItem && d[dimension.name] === axisItem,\n );\n return record ? Number(record[measure.name]) : 0;\n }),\n };\n });\n\n return {\n labels: axis,\n datasets,\n };\n};\n\nexport const getBarChartProData = (\n props: {\n data: DataResponse['data'];\n dimension: Dimension;\n measures: Measure[];\n maxItems?: number;\n },\n theme: Theme = remarkableTheme,\n): ChartData<'bar'> => {\n if (!props.data) {\n return {\n labels: [],\n datasets: [{ data: [] }],\n };\n }\n\n const themeFormatter = getThemeFormatter(theme);\n const themeKey = getObjectStableKey(theme);\n const groupedData = groupTailAsOther(props.data, props.dimension, props.measures, props.maxItems);\n const chartColors = getChartColors();\n\n return {\n labels: groupedData.map((item) => {\n return item[props.dimension.name];\n }),\n datasets: props.measures.map((measure, index) => {\n const backgroundColor = getColor(\n `${themeKey}.charts.backgroundColors`,\n measure.name,\n theme.charts.backgroundColors ?? chartColors,\n index,\n );\n\n const borderColor = getColor(\n `${themeKey}.charts.borderColors`,\n measure.name,\n theme.charts.borderColors ?? chartColors,\n index,\n );\n\n return {\n label: themeFormatter.dimensionOrMeasureTitle(measure),\n data: groupedData.map((item) => item[measure.name] ?? 0),\n backgroundColor,\n borderColor,\n };\n }),\n };\n};\n\nconst getBarChartProDatalabelTotalFormatter = (\n context: Context,\n formatter: (value: number) => string,\n) => {\n const { datasets } = context.chart.data;\n const i = context.dataIndex;\n\n const total = datasets.reduce((sum, ds) => {\n const val = ds.data[i] as number;\n return sum + (val || 0);\n }, 0);\n\n return formatter(total);\n};\n\nexport const getBarChartProOptions = (\n options: {\n onBarClicked: (args: {\n axisDimensionValue: string | null;\n groupingDimensionValue: string | null;\n }) => void;\n measures: Measure[];\n dimension: Dimension;\n horizontal: boolean;\n data: ChartData<'bar'>;\n },\n theme: Theme,\n): Partial<ChartOptions<'bar'>> => {\n const { onBarClicked, measures, dimension, horizontal, data } = options;\n\n const themeFormatter = getThemeFormatter(theme);\n return {\n plugins: {\n legend: { position: theme.charts.legendPosition ?? 'bottom' },\n datalabels: {\n labels: {\n total: {\n formatter: (_value: string | number, context: Context) =>\n getBarChartProDatalabelTotalFormatter(context, (value: number) =>\n themeFormatter.data(measures[0]!, value),\n ),\n },\n value: {\n formatter: (value: string | number, context) => {\n const measure = measures[context.datasetIndex % measures.length]!;\n return themeFormatter.data(measure, value);\n },\n },\n },\n },\n tooltip: {\n callbacks: {\n title: (context) => {\n const label = context[0]?.label;\n return themeFormatter.data(dimension, label);\n },\n label: (context) => {\n const measure = measures[context.datasetIndex % measures.length]!;\n const raw = context.raw as number;\n return `${themeFormatter.data(dimension, context.dataset.label) || ''}: ${themeFormatter.data(measure, raw)}`;\n },\n },\n },\n },\n scales: {\n x: {\n ticks: {\n callback: (value) => {\n if (horizontal) {\n return themeFormatter.data(measures[0]!, value);\n }\n\n if (!data || !data.labels) return undefined;\n\n const label = data.labels[Number(value)] as string;\n\n return themeFormatter.data(dimension, label);\n },\n },\n },\n y: {\n ticks: {\n callback: (value) => {\n if (!horizontal) {\n return themeFormatter.data(measures[0]!, value);\n }\n if (!data || !data.labels) return undefined;\n const label = data.labels[Number(value)] as string;\n return themeFormatter.data(dimension, label);\n },\n },\n },\n },\n onClick: (_event, elements, chart) => {\n const element = elements[0];\n const axisDimensionValue = (element ? chart.data.labels![element.index] : null) as\n | string\n | null;\n const groupingDimensionValue = (\n element\n ? (chart.data.datasets[element.datasetIndex] as { rawLabel?: string | null })?.rawLabel\n : null\n ) as string | null;\n\n onBarClicked({\n axisDimensionValue,\n groupingDimensionValue,\n });\n },\n };\n};\n"],"names":["getBarStackedChartProData","props","theme","themeFormatter","getThemeFormatter","data","dimension","groupDimension","measure","axis","d","groupDimensionName","CUBE_DIMENSION_TYPE_TIME","_a","groupBy","themeKey","getObjectStableKey","chartContrastColors","getChartContrastColors","datasets","groupByItem","index","backgroundColor","getColor","borderColor","axisItem","record","getBarChartProData","remarkableTheme","groupedData","groupTailAsOther","chartColors","getChartColors","item","getBarChartProDatalabelTotalFormatter","context","formatter","i","total","sum","ds","val","getBarChartProOptions","options","onBarClicked","measures","horizontal","_value","value","label","raw","_event","elements","chart","element","axisDimensionValue","groupingDimensionValue"],"mappings":";;;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KAAKK,GAAS0C,CAAG,CAAC;AAAA,UAC7G;AAAA,QAAA;AAAA,MACF;AAAA,IACF;AAAA,IAEF,QAAQ;AAAA,MACN,GAAG;AAAA,QACD,OAAO;AAAA,UACL,UAAU,CAACF,MAAU;AACnB,gBAAIF;AACF,qBAAO3C,EAAe,KAAK0C,EAAS,CAAC,GAAIG,CAAK;AAGhD,gBAAI,CAAC3C,KAAQ,CAACA,EAAK,OAAQ;AAE3B,kBAAM4C,IAAQ5C,EAAK,OAAO,OAAO2C,CAAK,CAAC;AAEvC,mBAAO7C,EAAe,KAAKG,GAAW2C,CAAK;AAAA,UAC7C;AAAA,QAAA;AAAA,MACF;AAAA,MAEF,GAAG;AAAA,QACD,OAAO;AAAA,UACL,UAAU,CAACD,MAAU;AACnB,gBAAI,CAACF;AACH,qBAAO3C,EAAe,KAAK0C,EAAS,CAAC,GAAIG,CAAK;AAEhD,gBAAI,CAAC3C,KAAQ,CAACA,EAAK,OAAQ;AAC3B,kBAAM4C,IAAQ5C,EAAK,OAAO,OAAO2C,CAAK,CAAC;AACvC,mBAAO7C,EAAe,KAAKG,GAAW2C,CAAK;AAAA,UAC7C;AAAA,QAAA;AAAA,MACF;AAAA,IACF;AAAA,IAEF,SAAS,CAACE,GAAQC,GAAUC,MAAU;;AACpC,YAAMC,IAAUF,EAAS,CAAC,GACpBG,IAAsBD,IAAUD,EAAM,KAAK,OAAQC,EAAQ,KAAK,IAAI,MAGpEE,IACJF,KACKzC,IAAAwC,EAAM,KAAK,SAASC,EAAQ,YAAY,MAAxC,gBAAAzC,EAA4E,WAC7E;AAGN,MAAA+B,EAAa;AAAA,QACX,oBAAAW;AAAA,QACA,wBAAAC;AAAA,MAAA,CACD;AAAA,IACH;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"bars.utils-CsJD9MNL.js","sources":["../src/components/charts/bars/bars.utils.ts"],"sourcesContent":["import { CUBE_DIMENSION_TYPE_TIME, DataResponse, Dimension, Measure } from '@embeddable.com/core';\nimport { Theme } from '../../../theme/theme.types';\nimport { remarkableTheme } from '../../../theme/theme.constants';\nimport { ChartData, ChartOptions } from 'chart.js';\nimport { getThemeFormatter } from '../../../theme/formatter/formatter.utils';\nimport { groupTailAsOther } from '../charts.utils';\nimport { getColor } from '../../../theme/styles/styles.utils';\nimport { getChartColors, getChartContrastColors } from '@embeddable.com/remarkable-ui';\nimport { getObjectStableKey } from '../../../utils.ts/object.utils';\nimport { Context } from 'chartjs-plugin-datalabels';\n\nexport const getBarStackedChartProData = (\n props: {\n data: DataResponse['data'];\n dimension: Dimension;\n groupDimension: Dimension;\n measure: Measure;\n },\n theme: Theme,\n): ChartData<'bar'> => {\n const themeFormatter = getThemeFormatter(theme);\n const { data = [], dimension, groupDimension, measure } = props;\n\n const axis = [...new Set(data.map((d) => d[dimension.name]).filter((d) => d != null))].sort();\n const groupDimensionName = `${groupDimension.name}${groupDimension.nativeType === CUBE_DIMENSION_TYPE_TIME && groupDimension.inputs?.granularity ? `.${groupDimension.inputs.granularity}` : ''}`;\n const groupBy = [...new Set(data.map((d) => d[groupDimensionName]))].filter((d) => d != null);\n\n const themeKey = getObjectStableKey(theme);\n const chartContrastColors = getChartContrastColors();\n const datasets = groupBy.map((groupByItem, index) => {\n const backgroundColor = getColor(\n `${themeKey}.charts.backgroundColors`,\n `${groupDimension.name}.${groupByItem}`,\n theme.charts.backgroundColors ?? chartContrastColors,\n index,\n );\n\n const borderColor = getColor(\n `${themeKey}.charts.borderColors`,\n `${groupDimension.name}.${groupByItem}`,\n theme.charts.borderColors ?? chartContrastColors,\n index,\n );\n\n return {\n label: themeFormatter.data(groupDimension, groupByItem),\n rawLabel: groupByItem,\n backgroundColor,\n borderColor,\n data: axis.map((axisItem) => {\n const record = data.find(\n (d) => d[groupDimensionName] === groupByItem && d[dimension.name] === axisItem,\n );\n return record ? Number(record[measure.name]) : 0;\n }),\n };\n });\n\n return {\n labels: axis,\n datasets,\n };\n};\n\nexport const getBarChartProData = (\n props: {\n data: DataResponse['data'];\n dimension: Dimension;\n measures: Measure[];\n maxItems?: number;\n },\n theme: Theme = remarkableTheme,\n): ChartData<'bar'> => {\n if (!props.data) {\n return {\n labels: [],\n datasets: [{ data: [] }],\n };\n }\n\n const themeFormatter = getThemeFormatter(theme);\n const themeKey = getObjectStableKey(theme);\n const groupedData = groupTailAsOther(props.data, props.dimension, props.measures, props.maxItems);\n const chartColors = getChartColors();\n\n return {\n labels: groupedData.map((item) => {\n return item[props.dimension.name];\n }),\n datasets: props.measures.map((measure, index) => {\n const backgroundColor = getColor(\n `${themeKey}.charts.backgroundColors`,\n measure.name,\n theme.charts.backgroundColors ?? chartColors,\n index,\n );\n\n const borderColor = getColor(\n `${themeKey}.charts.borderColors`,\n measure.name,\n theme.charts.borderColors ?? chartColors,\n index,\n );\n\n return {\n label: themeFormatter.dimensionOrMeasureTitle(measure),\n data: groupedData.map((item) => item[measure.name] ?? 0),\n backgroundColor,\n borderColor,\n };\n }),\n };\n};\n\nconst getBarChartProDatalabelTotalFormatter = (\n context: Context,\n formatter: (value: number) => string,\n) => {\n const { datasets } = context.chart.data;\n const i = context.dataIndex;\n\n const total = datasets.reduce((sum, ds) => {\n const val = ds.data[i] as number;\n return sum + (val || 0);\n }, 0);\n\n return formatter(total);\n};\n\nexport const getBarChartProOptions = (\n options: {\n onBarClicked: (args: {\n axisDimensionValue: string | null;\n groupingDimensionValue: string | null;\n }) => void;\n measures: Measure[];\n dimension: Dimension;\n horizontal: boolean;\n data: ChartData<'bar'>;\n },\n theme: Theme,\n): Partial<ChartOptions<'bar'>> => {\n const { onBarClicked, measures, dimension, horizontal, data } = options;\n\n const themeFormatter = getThemeFormatter(theme);\n return {\n plugins: {\n legend: { position: theme.charts.legendPosition ?? 'bottom' },\n datalabels: {\n labels: {\n total: {\n formatter: (_value: string | number, context: Context) =>\n getBarChartProDatalabelTotalFormatter(context, (value: number) =>\n themeFormatter.data(measures[0]!, value),\n ),\n },\n value: {\n formatter: (value: string | number, context) => {\n const measure = measures[context.datasetIndex % measures.length]!;\n return themeFormatter.data(measure, value);\n },\n },\n },\n },\n tooltip: {\n callbacks: {\n title: (context) => {\n const label = context[0]?.label;\n return themeFormatter.data(dimension, label);\n },\n label: (context) => {\n const measure = measures[context.datasetIndex % measures.length]!;\n const raw = context.raw as number;\n return `${themeFormatter.data(dimension, context.dataset.label) || ''}: ${themeFormatter.data(measure, raw)}`;\n },\n },\n },\n },\n scales: {\n x: {\n ticks: {\n callback: (value) => {\n if (horizontal) {\n return themeFormatter.data(measures[0]!, value);\n }\n\n if (!data || !data.labels) return undefined;\n\n const label = data.labels[Number(value)] as string;\n\n return themeFormatter.data(dimension, label);\n },\n },\n },\n y: {\n ticks: {\n callback: (value) => {\n if (!horizontal) {\n return themeFormatter.data(measures[0]!, value);\n }\n if (!data || !data.labels) return undefined;\n const label = data.labels[Number(value)] as string;\n return themeFormatter.data(dimension, label);\n },\n },\n },\n },\n onClick: (_event, elements, chart) => {\n const element = elements[0];\n const axisDimensionValue = (element ? chart.data.labels![element.index] : null) as\n | string\n | null;\n const groupingDimensionValue = (\n element\n ? (chart.data.datasets[element.datasetIndex] as { rawLabel?: string | null })?.rawLabel\n : null\n ) as string | null;\n\n onBarClicked({\n axisDimensionValue,\n groupingDimensionValue,\n });\n },\n };\n};\n"],"names":["getBarStackedChartProData","props","theme","themeFormatter","getThemeFormatter","data","dimension","groupDimension","measure","axis","d","groupDimensionName","CUBE_DIMENSION_TYPE_TIME","_a","groupBy","themeKey","getObjectStableKey","chartContrastColors","getChartContrastColors","datasets","groupByItem","index","backgroundColor","getColor","borderColor","axisItem","record","getBarChartProData","remarkableTheme","groupedData","groupTailAsOther","chartColors","getChartColors","item","getBarChartProDatalabelTotalFormatter","context","formatter","i","total","sum","ds","val","getBarChartProOptions","options","onBarClicked","measures","horizontal","_value","value","label","raw","_event","elements","chart","element","axisDimensionValue","groupingDimensionValue"],"mappings":";;;;AAWO,MAAMA,IAA4B,CACvCC,GAMAC,MACqB;;AACrB,Q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A;AAAA,MACF;AAAA,IACF;AAAA,IAEF,QAAQ;AAAA,MACN,GAAG;AAAA,QACD,OAAO;AAAA,UACL,UAAU,CAACF,MAAU;AACnB,gBAAIF;AACF,qBAAO3C,EAAe,KAAK0C,EAAS,CAAC,GAAIG,CAAK;AAGhD,gBAAI,CAAC3C,KAAQ,CAACA,EAAK,OAAQ;AAE3B,kBAAM4C,IAAQ5C,EAAK,OAAO,OAAO2C,CAAK,CAAC;AAEvC,mBAAO7C,EAAe,KAAKG,GAAW2C,CAAK;AAAA,UAC7C;AAAA,QAAA;AAAA,MACF;AAAA,MAEF,GAAG;AAAA,QACD,OAAO;AAAA,UACL,UAAU,CAACD,MAAU;AACnB,gBAAI,CAACF;AACH,qBAAO3C,EAAe,KAAK0C,EAAS,CAAC,GAAIG,CAAK;AAEhD,gBAAI,CAAC3C,KAAQ,CAACA,EAAK,OAAQ;AAC3B,kBAAM4C,IAAQ5C,EAAK,OAAO,OAAO2C,CAAK,CAAC;AACvC,mBAAO7C,EAAe,KAAKG,GAAW2C,CAAK;AAAA,UAC7C;AAAA,QAAA;AAAA,MACF;AAAA,IACF;AAAA,IAEF,SAAS,CAACE,GAAQC,GAAUC,MAAU;;AACpC,YAAMC,IAAUF,EAAS,CAAC,GACpBG,IAAsBD,IAAUD,EAAM,KAAK,OAAQC,EAAQ,KAAK,IAAI,MAGpEE,IACJF,KACKzC,IAAAwC,EAAM,KAAK,SAASC,EAAQ,YAAY,MAAxC,gBAAAzC,EAA4E,WAC7E;AAGN,MAAA+B,EAAa;AAAA,QACX,oBAAAW;AAAA,QACA,wBAAAC;AAAA,MAAA,CACD;AAAA,IACH;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Y as ls } from "./Color.type.emb-
|
|
2
|
-
import { a as si, i as hn } from "./component.inputs.constants-
|
|
1
|
+
import { Y as ls } from "./Color.type.emb-Dkh_ZrO6.js";
|
|
2
|
+
import { a as si, i as hn } from "./component.inputs.constants-CNdmawDt.js";
|
|
3
3
|
import { d as Te, u as oi } from "./utc-ZJfc90oL.js";
|
|
4
4
|
import { i as fi, q as li } from "./quarterOfYear-Dy3NbBBT.js";
|
|
5
5
|
import { g as cs } from "./_commonjsHelpers-C6fGbg64.js";
|
|
6
|
-
import { g as hs } from "./formatter.utils-
|
|
6
|
+
import { g as hs } from "./formatter.utils-BiWZBhcE.js";
|
|
7
7
|
var us = {
|
|
8
8
|
"--em-core-border-radius--000": "0px",
|
|
9
9
|
"--em-core-border-radius--050": "2px",
|
|
@@ -87,15 +87,15 @@ var us = {
|
|
|
87
87
|
"--em-sem-background--neutral": "var(--em-core-color-gray--0000)",
|
|
88
88
|
"--em-sem-background--subtle": "var(--em-core-color-gray--0200)",
|
|
89
89
|
"--em-sem-chart-color--1": "rgb(255 84 0)",
|
|
90
|
-
"--em-sem-chart-color--10": "rgb(
|
|
91
|
-
"--em-sem-chart-color--2": "rgb(
|
|
92
|
-
"--em-sem-chart-color--3": "rgb(255
|
|
93
|
-
"--em-sem-chart-color--4": "rgb(255
|
|
94
|
-
"--em-sem-chart-color--5": "rgb(
|
|
95
|
-
"--em-sem-chart-color--6": "rgb(
|
|
96
|
-
"--em-sem-chart-color--7": "rgb(
|
|
97
|
-
"--em-sem-chart-color--8": "rgb(
|
|
98
|
-
"--em-sem-chart-color--9": "rgb(
|
|
90
|
+
"--em-sem-chart-color--10": "rgb(141 153 174)",
|
|
91
|
+
"--em-sem-chart-color--2": "rgb(58 134 255)",
|
|
92
|
+
"--em-sem-chart-color--3": "rgb(255 138 0)",
|
|
93
|
+
"--em-sem-chart-color--4": "rgb(255 47 109)",
|
|
94
|
+
"--em-sem-chart-color--5": "rgb(46 196 182)",
|
|
95
|
+
"--em-sem-chart-color--6": "rgb(106 76 255)",
|
|
96
|
+
"--em-sem-chart-color--7": "rgb(131 56 236)",
|
|
97
|
+
"--em-sem-chart-color--8": "rgb(0 180 216)",
|
|
98
|
+
"--em-sem-chart-color--9": "rgb(76 175 80)",
|
|
99
99
|
"--em-sem-status-error-background": "rgb(246 226 226)",
|
|
100
100
|
"--em-sem-status-error-text": "rgb(188 16 16)",
|
|
101
101
|
"--em-sem-status-success-background": "rgb(225 240 233)",
|
|
@@ -17383,4 +17383,4 @@ export {
|
|
|
17383
17383
|
Zm as g,
|
|
17384
17384
|
Qm as r
|
|
17385
17385
|
};
|
|
17386
|
-
//# sourceMappingURL=charts.utils-
|
|
17386
|
+
//# sourceMappingURL=charts.utils-CUPowt7F.js.map
|