@foodpilot/foods 0.3.76 → 0.3.77

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.
@@ -1,21 +1,22 @@
1
- export type WaterfallDataset = {
1
+ export type WaterfallData = {
2
2
  label: string;
3
3
  value: number;
4
4
  };
5
5
  export type Colors = {
6
6
  reference?: string;
7
- target?: string;
7
+ start?: string;
8
8
  values?: string;
9
- diff?: string;
9
+ target?: string;
10
+ };
11
+ export type Target = {
12
+ label: string;
13
+ overrideValues?: number;
10
14
  };
11
- type High = number;
12
- type Low = number;
13
15
  export type WaterfallChartProps = {
14
- reference: WaterfallDataset;
15
- target: WaterfallDataset;
16
- labels: string[];
17
- values: [Low, High][];
16
+ reference: WaterfallData;
17
+ start: WaterfallData;
18
+ values: WaterfallData[];
18
19
  colors?: Colors;
20
+ target: Target;
19
21
  };
20
22
  export declare const WaterfallChart: (props: WaterfallChartProps) => import("react/jsx-runtime").JSX.Element;
21
- export {};
package/dist/main.js CHANGED
@@ -42756,7 +42756,7 @@ const Lie = (e) => {
42756
42756
  });
42757
42757
  jt(() => {
42758
42758
  d !== null && n && n[d] !== void 0 && t && t[d] !== void 0 ? m(
42759
- /* @__PURE__ */ p.jsxs(p.Fragment, { children: [
42759
+ /* @__PURE__ */ p.jsxs(te, { sx: { maxWidth: "250px" }, children: [
42760
42760
  /* @__PURE__ */ p.jsx(fe, { fontWeight: 700, fontSize: "0.75rem", children: n[d] }),
42761
42761
  /* @__PURE__ */ p.jsxs(fe, { fontWeight: 700, fontSize: "1.5rem", children: [
42762
42762
  c ? c(t[d]) : t[d],
@@ -44051,46 +44051,57 @@ const Aie = (e) => {
44051
44051
  chartReady: t
44052
44052
  };
44053
44053
  }, YZ = (e, t, n, o, r) => {
44054
- const { chartReady: i, ref: a } = GZ(), l = [e.label, t.label].concat(n), c = Kt(() => {
44055
- const h = o.reduce((m, [b, v]) => [...m, v - b], []).reduce((m, b) => b + m, 0), g = [[0, t.value + h]];
44054
+ const { chartReady: i, ref: a } = GZ(), l = Me(), c = n.map((b) => b.label), d = n.map((b) => b.value), u = [e.label, t.label].concat(c).concat([o.label]), f = Kt(() => {
44055
+ const b = d.reduce(
44056
+ (x, C) => {
44057
+ const [, S] = x.slice(-1).pop();
44058
+ return [...x, [S, S + C]];
44059
+ },
44060
+ [[0, t.value]]
44061
+ );
44062
+ b.shift();
44063
+ const [[, v]] = b.slice(-1);
44056
44064
  return [
44057
44065
  {
44058
44066
  label: e.label,
44059
44067
  data: [[0, e.value]],
44060
- backgroundColor: (r == null ? void 0 : r.reference) ?? "#3c67bc",
44068
+ backgroundColor: (r == null ? void 0 : r.reference) ?? l.custom.dataviz.colors[2].main,
44061
44069
  xoffset: 0,
44062
44070
  barThickness: 80
44063
44071
  },
44064
44072
  {
44065
44073
  label: t.label,
44066
44074
  data: [[0, t.value]],
44067
- backgroundColor: (r == null ? void 0 : r.target) ?? "#b5d1ec",
44075
+ backgroundColor: (r == null ? void 0 : r.start) ?? l.custom.dataviz.colors[4].main,
44068
44076
  xoffset: 1,
44069
44077
  barThickness: 80
44070
44078
  },
44071
44079
  {
44072
44080
  label: "values",
44073
- data: o,
44074
- backgroundColor: (r == null ? void 0 : r.values) ?? "#be4f12",
44081
+ data: b,
44082
+ backgroundColor: (x) => {
44083
+ const [C, S] = x.raw;
44084
+ return S - C < 0 ? l.custom.dataviz.extra[14].main : l.custom.dataviz.colors[6].main;
44085
+ },
44075
44086
  xoffset: 2,
44076
44087
  barThickness: 80
44077
44088
  },
44078
44089
  {
44079
44090
  label: "diff",
44080
- data: g,
44081
- backgroundColor: (r == null ? void 0 : r.diff) ?? "#bddbab",
44082
- xoffset: o.length + 2,
44091
+ data: [[0, o.overrideValues !== void 0 ? o.overrideValues : v]],
44092
+ backgroundColor: (r == null ? void 0 : r.target) ?? l.custom.dataviz.colors[4].main,
44093
+ xoffset: d.length + 2,
44083
44094
  barThickness: 80
44084
44095
  }
44085
44096
  ];
44086
- }, [e, t, o, r]);
44097
+ }, [e, t, d, r, o, l]);
44087
44098
  return {
44088
44099
  type: "bar",
44089
44100
  ref: a,
44090
44101
  chartReady: i,
44091
44102
  data: {
44092
- labels: l,
44093
- datasets: c
44103
+ labels: u,
44104
+ datasets: f
44094
44105
  },
44095
44106
  options: {
44096
44107
  animation: !1,
@@ -44104,20 +44115,20 @@ const Aie = (e) => {
44104
44115
  legend: { display: !1 },
44105
44116
  datalabels: {
44106
44117
  align: "start",
44107
- anchor(h) {
44118
+ anchor(b) {
44108
44119
  const {
44109
- dataset: { data: g }
44110
- } = h;
44111
- return g[0][0] == 0 ? "end" : "start";
44120
+ dataset: { data: v }
44121
+ } = b;
44122
+ return v[0][0] == 0 ? "end" : "start";
44112
44123
  },
44113
- offset(h) {
44124
+ offset(b) {
44114
44125
  const {
44115
- dataset: { data: g }
44116
- } = h;
44117
- return g[0][0] == 0 ? -20 : 0;
44126
+ dataset: { data: v }
44127
+ } = b;
44128
+ return v[0][0] == 0 ? -20 : 0;
44118
44129
  },
44119
- formatter([h, g], m) {
44120
- return g - h;
44130
+ formatter([b, v], x) {
44131
+ return v - b;
44121
44132
  }
44122
44133
  }
44123
44134
  }
@@ -44125,7 +44136,7 @@ const Aie = (e) => {
44125
44136
  plugins: [qZ]
44126
44137
  };
44127
44138
  }, Fie = (e) => {
44128
- const { reference: t, target: n, labels: o, values: r, colors: i } = e, { data: a, ref: l, type: c, options: d, plugins: u } = YZ(t, n, o, r, i);
44139
+ const { reference: t, start: n, values: o, target: r, colors: i } = e, { data: a, ref: l, type: c, options: d, plugins: u } = YZ(t, n, o, r, i);
44129
44140
  return /* @__PURE__ */ p.jsx(ye, { position: "relative", flexWrap: "wrap", sx: { backgroundColor: "white" }, gap: 6, children: /* @__PURE__ */ p.jsx(te, { flex: 2, width: "100%", height: "100%", children: /* @__PURE__ */ p.jsx(G2, { ref: l, type: c, data: a, options: d, plugins: u }) }) });
44130
44141
  }, y8 = (e) => /* @__PURE__ */ y.createElement("svg", { width: 20, height: 20, viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ y.createElement("rect", { x: 1, y: 1, width: 18, height: 18, rx: 3, fill: "white" }), /* @__PURE__ */ y.createElement("rect", { x: 1, y: 1, width: 18, height: 18, rx: 3, stroke: "#D1CFCE", strokeWidth: 2 })), C8 = (e) => /* @__PURE__ */ y.createElement("svg", { width: 20, height: 20, viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ y.createElement("rect", { width: 20, height: 20, rx: 4, fill: "url(#paint0_linear_2034_7850)" }), /* @__PURE__ */ y.createElement("path", { d: "M8.32244 13.9335L4.56689 10.178L5.36133 9.38351L8.32244 12.3446L14.628 6.03906L15.4224 6.83351L8.32244 13.9335Z", fill: "white" }), /* @__PURE__ */ y.createElement("defs", null, /* @__PURE__ */ y.createElement("linearGradient", { id: "paint0_linear_2034_7850", x1: 7.58928, y1: 755124e-13, x2: 7.58928, y2: 20, gradientUnits: "userSpaceOnUse" }, /* @__PURE__ */ y.createElement("stop", { stopColor: "#484945" }), /* @__PURE__ */ y.createElement("stop", { offset: 1, stopColor: "#2A2B27" })))), KZ = W(or)(() => ({
44131
44142
  ":hover": {