@foodpilot/foods 2.11.45 → 2.11.47

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.
@@ -23,6 +23,12 @@ export type SelectedPoint = {
23
23
  };
24
24
  export type ScatterPlotProps = {
25
25
  values: SeriesData[];
26
+ /** When both are set, fixes the X-axis domain instead of deriving it from data. */
27
+ xMin?: number;
28
+ xMax?: number;
29
+ /** When both are set, fixes the Y-axis domain instead of deriving it from data. */
30
+ yMin?: number;
31
+ yMax?: number;
26
32
  xLabel: ReactNode;
27
33
  yLabel: ReactNode;
28
34
  width?: string;
@@ -1,15 +1,15 @@
1
- import{jsxs as e,Fragment as t,jsx as n}from"react/jsx-runtime";import{useState as i,useMemo as r}from"react";import{useTheme as a,Stack as o,Box as l,Typography as s}from"@mui/material";import{ScatterPlotCore as c}from"./ScatterPlotCore.js";const d=d=>{const{values:p,xLabel:h,yLabel:g,width:x="100%",height:m="800px",valueFormatterFn:u,precision:f,language:v,unit:y,xUnit:b,yUnit:w,textOptions:C,onLegendHover:j,tooltipOptions:k}=d,S=a(),[O,z]=i(/* @__PURE__ */new Set),E=r(()=>p.length<=1?p:p.map((e,t)=>({...e,data:O.has(t)?[]:e.data})).filter(e=>e.data.length>0),[p,O]);/* @__PURE__ */
1
+ import{jsxs as e,Fragment as t,jsx as n}from"react/jsx-runtime";import{useState as i,useMemo as a}from"react";import{useTheme as r,Stack as o,Box as l,Typography as s}from"@mui/material";import{ScatterPlotCore as c}from"./ScatterPlotCore.js";const d=d=>{const{values:p,xMin:h,xMax:x,yMin:g,yMax:m,xLabel:u,yLabel:y,width:f="100%",height:v="800px",valueFormatterFn:b,precision:w,language:M,unit:C,xUnit:j,yUnit:k,textOptions:S,onLegendHover:O,tooltipOptions:z}=d,E=r(),[F,I]=i(/* @__PURE__ */new Set),L=a(()=>p.length<=1?p:p.map((e,t)=>({...e,data:F.has(t)?[]:e.data})).filter(e=>e.data.length>0),[p,F]);/* @__PURE__ */
2
2
  return e(t,{children:[
3
- /* @__PURE__ */n(o,{direction:"column",position:"relative",width:x,minHeight:S.spacing(50),height:m,justifyContent:"stretch",sx:{"& *":{outline:"none"}},children:/* @__PURE__ */e(l,{sx:{border:`1px solid ${S.palette.divider}`,backgroundColor:S.palette.background.paper,borderRadius:S.spacing(1),width:"100%",height:m,padding:S.spacing(3),display:"flex",flexDirection:"column"},children:[
4
- /* @__PURE__ */n(l,{sx:{mb:S.spacing(2),pointerEvents:"none"},children:/* @__PURE__ */e(l,{sx:{display:"flex",alignItems:"center",gap:".5rem"},children:[
5
- /* @__PURE__ */n(s,{variant:"h4",children:g}),
3
+ /* @__PURE__ */n(o,{direction:"column",position:"relative",width:f,minHeight:E.spacing(50),height:v,justifyContent:"stretch",sx:{"& *":{outline:"none"}},children:/* @__PURE__ */e(l,{sx:{border:`1px solid ${E.palette.divider}`,backgroundColor:E.palette.background.paper,borderRadius:E.spacing(1),width:"100%",height:v,padding:E.spacing(3),display:"flex",flexDirection:"column"},children:[
4
+ /* @__PURE__ */n(l,{sx:{mb:E.spacing(2),pointerEvents:"none"},children:/* @__PURE__ */e(l,{sx:{display:"flex",alignItems:"center",gap:".5rem"},children:[
5
+ /* @__PURE__ */n(s,{variant:"h4",children:y}),
6
6
  /* @__PURE__ */n(s,{variant:"body",children:"-"}),
7
- /* @__PURE__ */n(s,{variant:"body",children:w})]})}),
8
- /* @__PURE__ */n(l,{sx:{position:"relative",width:"100%",flex:1},children:/* @__PURE__ */n(c,{values:E,valueFormatterFn:u,precision:f,language:v,unit:y,xUnit:b,yUnit:w,textOptions:C,onLegendHover:j,tooltipOptions:k,showSeriesInTooltip:p.length>1})}),
9
- /* @__PURE__ */n(l,{sx:{mt:S.spacing(2),display:"flex",justifyContent:"flex-end",pointerEvents:"none"},children:/* @__PURE__ */e(l,{sx:{display:"flex",alignItems:"center",gap:".5rem"},children:[
10
- /* @__PURE__ */n(s,{variant:"h4",children:h}),
7
+ /* @__PURE__ */n(s,{variant:"body",children:k})]})}),
8
+ /* @__PURE__ */n(l,{sx:{position:"relative",width:"100%",flex:1},children:/* @__PURE__ */n(c,{values:L,xMin:h,xMax:x,yMin:g,yMax:m,valueFormatterFn:b,precision:w,language:M,unit:C,xUnit:j,yUnit:k,textOptions:S,onLegendHover:O,tooltipOptions:z,showSeriesInTooltip:p.length>1})}),
9
+ /* @__PURE__ */n(l,{sx:{mt:E.spacing(2),display:"flex",justifyContent:"flex-end",pointerEvents:"none"},children:/* @__PURE__ */e(l,{sx:{display:"flex",alignItems:"center",gap:".5rem"},children:[
10
+ /* @__PURE__ */n(s,{variant:"h4",children:u}),
11
11
  /* @__PURE__ */n(s,{variant:"body",children:"-"}),
12
- /* @__PURE__ */n(s,{variant:"body",children:b})]})})]})}),p&&p.length>0&&/* @__PURE__ */n(l,{sx:{mt:S.spacing(4),pb:S.spacing(4)},children:/* @__PURE__ */n(l,{sx:{display:"flex",justifyContent:"flex-start",flexWrap:"wrap",gap:`${S.spacing(2)} ${S.spacing(6)}`},children:p.map((t,i)=>{const r=(i+1)%Object.keys(S.custom.dataviz.colorsWithExtra).length+1,a=t.color||S.custom.dataviz.colorsWithExtra[r].main;/* @__PURE__ */
13
- return e(l,{sx:{display:"flex",alignItems:"center",gap:S.spacing(1),cursor:p.length>1?"pointer":"default",opacity:O.has(i)?.4:1},onClick:()=>{p.length>1&&(e=>{p.length<=1||z(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.size<p.length-1&&n.add(e),n})})(i),j?.(i)},children:[
14
- /* @__PURE__ */n(l,{sx:{width:S.spacing(1.5),height:S.spacing(1.5),borderRadius:"50%",backgroundColor:a,flexShrink:0}}),
15
- /* @__PURE__ */n(s,{variant:"body2",fontWeight:500,sx:{fontSize:"14px",color:S.palette.text.primary},children:t.name})]},t.name)})})})]})};export{d as ScatterPlot};
12
+ /* @__PURE__ */n(s,{variant:"body",children:j})]})})]})}),p&&p.length>0&&/* @__PURE__ */n(l,{sx:{mt:E.spacing(4),pb:E.spacing(4)},children:/* @__PURE__ */n(l,{sx:{display:"flex",justifyContent:"flex-start",flexWrap:"wrap",gap:`${E.spacing(2)} ${E.spacing(6)}`},children:p.map((t,i)=>{const a=(i+1)%Object.keys(E.custom.dataviz.colorsWithExtra).length+1,r=t.color||E.custom.dataviz.colorsWithExtra[a].main;/* @__PURE__ */
13
+ return e(l,{sx:{display:"flex",alignItems:"center",gap:E.spacing(1),cursor:p.length>1?"pointer":"default",opacity:F.has(i)?.4:1},onClick:()=>{p.length>1&&(e=>{p.length<=1||I(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.size<p.length-1&&n.add(e),n})})(i),O?.(i)},children:[
14
+ /* @__PURE__ */n(l,{sx:{width:E.spacing(1.5),height:E.spacing(1.5),borderRadius:"50%",backgroundColor:r,flexShrink:0}}),
15
+ /* @__PURE__ */n(s,{variant:"body2",fontWeight:500,sx:{fontSize:"14px",color:E.palette.text.primary},children:t.name})]},t.name)})})})]})};export{d as ScatterPlot};
@@ -3,6 +3,12 @@ import { ButtonProps } from '@mui/material';
3
3
  import { SeriesData } from './ScatterPlot';
4
4
  export type ScatterPlotCoreProps = {
5
5
  values: SeriesData[];
6
+ /** When both are set, fixes the X-axis domain instead of deriving it from data. */
7
+ xMin?: number;
8
+ xMax?: number;
9
+ /** When both are set, fixes the Y-axis domain instead of deriving it from data. */
10
+ yMin?: number;
11
+ yMax?: number;
6
12
  valueFormatterFn?: (value: number, precision?: number) => string;
7
13
  precision?: number;
8
14
  language?: string;
@@ -1,7 +1,7 @@
1
- import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useMemo as e,useState as i,useRef as n,useCallback as r,useEffect as a}from"react";import{useTheme as s,Box as l}from"@mui/material";import{ResponsiveContainer as m,ScatterChart as c,CartesianGrid as p,XAxis as d,YAxis as h}from"recharts";import{useScatterPlotInteraction as u}from"./useScatterPlotInteraction.js";import{ScatterPlotHoverOverlay as v}from"./ScatterPlotHoverOverlay.js";import{ScatterPlotTooltip as x}from"./ScatterPlotTooltip.js";import{ScatterPlotPoints as f}from"./ScatterPlotPoints.js";import{processScatterPlotData as y,createGroupedData as g,ANIMATION_DURATION as P,CHART_MARGIN_BOTTOM as D,CHART_MARGIN_LEFT as k,CHART_MARGIN_RIGHT as F,CHART_MARGIN_TOP as L}from"./utils.js";import M from"i18next";const T=T=>{const E=s(),{values:S,valueFormatterFn:b=E.numbers.valueFormatterFn,precision:w,language:z,unit:I,xUnit:j,yUnit:O,textOptions:W,showSeriesInTooltip:U=!0,tooltipOptions:A}=T,{hoveredIndex:C,hover:H,pinnedIndex:K,pinnedHover:$,isPinned:R,handlePointEnter:X,handlePointClick:Y,handlePointLeave:q,handleTooltipEnter:B,handleTooltipLeave:G,handleDismissTooltip:J}=u(),{allPoints:N,shouldShowLabels:Q}=e(()=>y(S,E.custom.dataviz.colorsWithExtra),[S,E.custom.dataviz.colorsWithExtra]),V=e(()=>g(S,E.custom.dataviz.colorsWithExtra,N),[S,E.custom.dataviz.colorsWithExtra,N]),{xDomain:Z,yDomain:_}=e(()=>{const t=S.flatMap(t=>t.data);if(0===t.length)return{xDomain:[0,100],yDomain:[0,100]};const o=t.map(t=>t.x),e=t.map(t=>t.y),i=Math.min(...o),n=Math.max(...o),r=Math.min(...e),a=Math.max(...e);return{xDomain:[Math.max(0,i),n],yDomain:[Math.max(0,r),a]}},[S]),[tt,ot]=i(!0),et=n(null),it=n(null),[nt,rt]=i(0),at=z??M.language,st="number"==typeof w?Math.min(100,Math.max(0,w)):void 0,lt=r(t=>b(t,st),[b,st]);return a(()=>{const t=setTimeout(()=>{ot(!1)},P);return()=>clearTimeout(t)},[]),a(()=>{const t=et.current;if(!t)return;const o=()=>rt(t.clientWidth);o();const e=new ResizeObserver(o);return e.observe(t),()=>e.disconnect()},[]),/* @__PURE__ */t(l,{onClick:t=>{const o=t.target;if(o.classList.contains("recharts-dot"))return;const e=it.current;e&&e.contains(o)||J()},onMouseLeave:()=>J(),ref:et,sx:{position:"relative",width:"100%",height:"100%"},children:[
2
- /* @__PURE__ */o(m,{width:"100%",height:"100%",children:/* @__PURE__ */t(c,{margin:{top:L,right:F,left:k,bottom:D},children:[
3
- /* @__PURE__ */o(p,{strokeDasharray:"4 4",stroke:E.palette.divider}),
4
- /* @__PURE__ */o(d,{type:"number",dataKey:"x",domain:Z,tickLine:!1,axisLine:{stroke:E.palette.divider},tick:{fontFamily:"Montserrat",fontSize:14,style:{transform:`translateY(${E.spacing(2)})`}},tickFormatter:lt,allowDecimals:!0}),
5
- /* @__PURE__ */o(h,{type:"number",dataKey:"y",domain:_,tickLine:!1,axisLine:{stroke:E.palette.divider},tick:{fontFamily:"Montserrat",fontSize:14,style:{transform:`translateX(-${E.spacing(2)})`,pointerEvents:"none"}},tickFormatter:lt,allowDecimals:!0,style:{pointerEvents:"none"}}),
6
- /* @__PURE__ */o(v,{hover:H,valueFormatterFn:b,precision:st,language:at,xDomain:Z,yDomain:_}),
7
- /* @__PURE__ */o(f,{groupedData:V,allPoints:N,hoveredIndex:C,pinnedIndex:K,isTooltipActive:!!(R&&null!==K&&$&&N[K]),isAnimationActive:tt,shouldShowLabels:Q,containerWidth:nt,onPointEnter:X,onPointLeave:q,onPointClick:(t,o,e,i)=>{i.stopPropagation(),Y(t,o,e)}})]})}),!!(R&&null!==K&&$&&N[K])&&/* @__PURE__ */o(x,{ref:it,point:N[K],coordinate:$,series:S,valueFormatterFn:b,precision:w,unit:I,xUnit:j,yUnit:O,textOptions:W,showSeriesInTooltip:U,handleDismissTooltip:J,tooltipOptions:A,onTooltipEnter:B,onTooltipLeave:G})]})};export{T as ScatterPlotCore};
1
+ import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useMemo as i,useState as e,useRef as n,useCallback as r,useEffect as a}from"react";import{useTheme as s,Box as l}from"@mui/material";import{ResponsiveContainer as m,ScatterChart as c,CartesianGrid as d,XAxis as p,YAxis as h}from"recharts";import{useScatterPlotInteraction as u}from"./useScatterPlotInteraction.js";import{ScatterPlotHoverOverlay as v}from"./ScatterPlotHoverOverlay.js";import{ScatterPlotTooltip as x}from"./ScatterPlotTooltip.js";import{ScatterPlotPoints as f}from"./ScatterPlotPoints.js";import{processScatterPlotData as y,createGroupedData as g,ANIMATION_DURATION as M,CHART_MARGIN_BOTTOM as P,CHART_MARGIN_LEFT as D,CHART_MARGIN_RIGHT as k,CHART_MARGIN_TOP as F}from"./utils.js";import L from"i18next";const T=T=>{const E=s(),{values:S,xMin:b,xMax:w,yMin:z,yMax:I,valueFormatterFn:j=E.numbers.valueFormatterFn,precision:O,language:W,unit:U,xUnit:A,yUnit:C,textOptions:H,showSeriesInTooltip:K=!0,tooltipOptions:$}=T,{hoveredIndex:R,hover:X,pinnedIndex:Y,pinnedHover:q,isPinned:B,handlePointEnter:G,handlePointClick:J,handlePointLeave:N,handleTooltipEnter:Q,handleTooltipLeave:V,handleDismissTooltip:Z}=u(),{allPoints:_,shouldShowLabels:tt}=i(()=>y(S,E.custom.dataviz.colorsWithExtra),[S,E.custom.dataviz.colorsWithExtra]),ot=i(()=>g(S,E.custom.dataviz.colorsWithExtra,_),[S,E.custom.dataviz.colorsWithExtra,_]),{xDomain:it,yDomain:et}=i(()=>{const t=S.flatMap(t=>t.data);if(0===t.length)return{xDomain:void 0!==b&&void 0!==w?[b,w]:[0,100],yDomain:void 0!==z&&void 0!==I?[z,I]:[0,100]};const o=t.map(t=>t.x),i=t.map(t=>t.y),e=Math.min(...o),n=Math.max(...o),r=Math.min(...i),a=Math.max(...i);return{xDomain:void 0!==b&&void 0!==w?[b,w]:[Math.max(0,e),n],yDomain:void 0!==z&&void 0!==I?[z,I]:[Math.max(0,r),a]}},[S,b,w,z,I]),[nt,rt]=e(!0),at=n(null),st=n(null),[lt,mt]=e(0),ct=W??L.language,dt="number"==typeof O?Math.min(100,Math.max(0,O)):void 0,pt=r(t=>j(t,dt),[j,dt]);return a(()=>{const t=setTimeout(()=>{rt(!1)},M);return()=>clearTimeout(t)},[]),a(()=>{const t=at.current;if(!t)return;const o=()=>mt(t.clientWidth);o();const i=new ResizeObserver(o);return i.observe(t),()=>i.disconnect()},[]),/* @__PURE__ */t(l,{onClick:t=>{const o=t.target;if(o.classList.contains("recharts-dot"))return;const i=st.current;i&&i.contains(o)||Z()},onMouseLeave:()=>Z(),ref:at,sx:{position:"relative",width:"100%",height:"100%"},children:[
2
+ /* @__PURE__ */o(m,{width:"100%",height:"100%",children:/* @__PURE__ */t(c,{margin:{top:F,right:k,left:D,bottom:P},children:[
3
+ /* @__PURE__ */o(d,{strokeDasharray:"4 4",stroke:E.palette.divider}),
4
+ /* @__PURE__ */o(p,{type:"number",dataKey:"x",domain:it,tickLine:!1,axisLine:{stroke:E.palette.divider},tick:{fontFamily:"Montserrat",fontSize:14,style:{transform:`translateY(${E.spacing(2)})`}},tickFormatter:pt,allowDecimals:!0}),
5
+ /* @__PURE__ */o(h,{type:"number",dataKey:"y",domain:et,tickLine:!1,axisLine:{stroke:E.palette.divider},tick:{fontFamily:"Montserrat",fontSize:14,style:{transform:`translateX(-${E.spacing(2)})`,pointerEvents:"none"}},tickFormatter:pt,allowDecimals:!0,style:{pointerEvents:"none"}}),
6
+ /* @__PURE__ */o(v,{hover:X,valueFormatterFn:j,precision:dt,language:ct,xDomain:it,yDomain:et}),
7
+ /* @__PURE__ */o(f,{groupedData:ot,allPoints:_,hoveredIndex:R,pinnedIndex:Y,isTooltipActive:!!(B&&null!==Y&&q&&_[Y]),isAnimationActive:nt,shouldShowLabels:tt,containerWidth:lt,onPointEnter:G,onPointLeave:N,onPointClick:(t,o,i,e)=>{e.stopPropagation(),J(t,o,i)}})]})}),!!(B&&null!==Y&&q&&_[Y])&&/* @__PURE__ */o(x,{ref:st,point:_[Y],coordinate:q,series:S,valueFormatterFn:j,precision:O,unit:U,xUnit:A,yUnit:C,textOptions:H,showSeriesInTooltip:K,handleDismissTooltip:Z,tooltipOptions:$,onTooltipEnter:Q,onTooltipLeave:V})]})};export{T as ScatterPlotCore};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@foodpilot/foods",
3
3
  "private": false,
4
- "version": "2.11.45",
4
+ "version": "2.11.47",
5
5
  "type": "module",
6
6
  "main": "./dist/main.js",
7
7
  "module": "./dist/main.js",
@@ -211,7 +211,7 @@
211
211
  "@mui/x-date-pickers": "^7.0.0",
212
212
  "@mui/x-tree-view": "^7.0.0",
213
213
  "i18next": "^23.0.0 || ^25.0.0",
214
- "lodash": "^4.17.23",
214
+ "lodash": "^4.18.1",
215
215
  "material-react-table": "^2.0.0",
216
216
  "react": "^18.0.0 || ^19.0.0",
217
217
  "react-dom": "^18.0.0 || ^19.0.0",
@@ -283,7 +283,7 @@
283
283
  "storybook": "^10.2.13",
284
284
  "typescript": "^5.9.3",
285
285
  "typescript-eslint": "^8.56.1",
286
- "vite": "^7.3.1",
286
+ "vite": "^7.3.2",
287
287
  "vite-bundle-visualizer": "^1.2.1",
288
288
  "vite-plugin-dts": "^4.5.0",
289
289
  "vite-plugin-svgr": "^4.5.0"
@@ -292,7 +292,6 @@
292
292
  "@lexical/react": "^0.41.0",
293
293
  "@mui/lab": "^6.0.0-beta.0",
294
294
  "@mui/x-data-grid": "^7.0.0",
295
- "@mui/x-data-grid-generator": "^7.29.8",
296
295
  "@mui/x-tree-view": "^7.0.0",
297
296
  "@tiptap/extension-color": "^2.26.1",
298
297
  "@tiptap/extension-font-family": "^2.26.1",
@@ -311,9 +310,9 @@
311
310
  "chroma-js": "^3.2.0",
312
311
  "i18next": "^23.0.0 || ^25.0.0",
313
312
  "i18next-browser-languagedetector": "^8.2.1",
314
- "i18next-http-backend": "^3.0.2",
313
+ "i18next-http-backend": "^3.0.5",
315
314
  "lexical": "^0.41.0",
316
- "lodash": "^4.17.23",
315
+ "lodash": "^4.18.1",
317
316
  "material-ui-popup-state": "^5.3.1",
318
317
  "react-dnd": "^16.0.1",
319
318
  "react-dnd-html5-backend": "^16.0.1",