@foodpilot/foods 2.25.1 → 2.25.3

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,7 +1,7 @@
1
- import{jsx as t,jsxs as e}from"react/jsx-runtime";import{useRef as r,useState as i,useEffect as a,useMemo as o}from"react";import{ResponsiveContainer as n,ComposedChart as s,CartesianGrid as m,XAxis as l,YAxis as d,Label as c,ReferenceLine as h}from"recharts";import{useTheme as f,useMediaQuery as p,Box as g}from"@mui/material";import{transformWaterfallData as u,calculateLabelSettings as k,wrapWaterfallLabel as v}from"./utils.js";import{WaterfallChartTick as x}from"./WaterfallChartTick.js";import{WaterfallChartBars as y}from"./WaterfallChartBars.js";import{TICK_VERTICAL_OFFSET as F,LINE_HEIGHT_PIXELS as w}from"./labelGeometry.js";const b=b=>{const W=f(),L=p(W.breakpoints.down("sm")),{reference:j,start:z,values:C,colors:M,target:D,goal:X,forcedPrecision:$,unit:A,improvement:B,targetValueFinal:E,valueFormatterFn:H=W.numbers.valueFormatterFn,precision:P,CoreOverride:S}=b,T=r(null),[G,K]=i(800);a(()=>{const t=()=>{if(T.current){const t=T.current.getBoundingClientRect().width;t>0&&K(t-60)}};t();const e=()=>t();return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const N=o(()=>u(j,z,C,M,D,X,B,E,W),[j,z,C,M,D,X,B,E,W]),O=o(()=>k(N,G),[N,G]),R=Math.max(S?.XAxisHeight??40,...N.map(t=>F+v(t.label,80).length*w));/* @__PURE__ */
2
- return t(g,{ref:T,sx:{width:"100%",height:"100%",minWidth:{xs:96*N.length+100,sm:0}},children:/* @__PURE__ */t(n,{width:"100%",height:"100%",children:/* @__PURE__ */e(s,{data:N,margin:{top:45,right:0,left:30,bottom:35},children:[
1
+ import{jsx as t,jsxs as e}from"react/jsx-runtime";import{useRef as r,useState as i,useEffect as a,useMemo as o}from"react";import{ResponsiveContainer as n,ComposedChart as s,CartesianGrid as m,XAxis as l,YAxis as d,Label as c,ReferenceLine as h}from"recharts";import{useTheme as f,useMediaQuery as p,Box as u}from"@mui/material";import{transformWaterfallData as g,calculateLabelSettings as k,wrapWaterfallLabel as v}from"./utils.js";import{WaterfallChartTick as x}from"./WaterfallChartTick.js";import{WaterfallChartBars as y}from"./WaterfallChartBars.js";import{TICK_VERTICAL_OFFSET as F,LINE_HEIGHT_PIXELS as w}from"./labelGeometry.js";const b=b=>{const W=f(),L=p(W.breakpoints.down("sm")),{reference:j,start:z,values:C,colors:M,target:D,goal:$,forcedPrecision:B,unit:E,improvement:P,targetValueFinal:S,valueFormatterFn:T=W.numbers.valueFormatterFn,precision:X,CoreOverride:A}=b,G=r(null),[H,K]=i(800);a(()=>{const t=()=>{if(G.current){const t=G.current.getBoundingClientRect().width;t>0&&K(t-60)}};t();const e=()=>t();return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const N=o(()=>g(j,z,C,M,D,$,P,S,W),[j,z,C,M,D,$,P,S,W]),O=o(()=>k(N,H),[N,H]),R=L?80:O.maxWidth,V=Math.max(A?.XAxisHeight??40,...N.map(t=>F+v(t.label,R).length*w));/* @__PURE__ */
2
+ return t(u,{ref:G,sx:{width:"100%",height:"100%",minWidth:{xs:96*N.length+100,sm:0}},children:/* @__PURE__ */t(n,{width:"100%",height:"100%",children:/* @__PURE__ */e(s,{data:N,margin:{top:45,right:0,left:30,bottom:35},children:[
3
3
  /* @__PURE__ */t(m,{strokeDasharray:"4 4",stroke:W.palette.divider}),
4
- /* @__PURE__ */t(l,{dataKey:"label",strokeWidth:0,strokeDasharray:"4 4",tick:e=>/* @__PURE__ */t(x,{...e,maxWidth:L?80:O.maxWidth}),axisLine:{stroke:W.palette.divider},interval:L?0:O.interval,tickLine:!1,padding:{left:0,right:0},height:L?R:S?.XAxisHeight??40}),
5
- /* @__PURE__ */t(d,{width:"auto",domain:([t,e])=>[t<0?t-.2*Math.abs(t):t,e],strokeWidth:0,tick:{fontFamily:"Montserrat",fontSize:14,style:{transform:`translateX(-${W.spacing(2)})`}},axisLine:{stroke:W.palette.divider},tickLine:!1,tickFormatter:t=>H(Number(t),P),children:/* @__PURE__ */t(c,{value:A,position:"insideTopLeft",style:{fontFamily:"Montserrat",fontSize:"14px",transform:`translate(-${W.spacing(2.75)}, -${W.spacing(6)})`}})}),
4
+ /* @__PURE__ */t(l,{dataKey:"label",strokeWidth:0,strokeDasharray:"4 4",tick:e=>/* @__PURE__ */t(x,{...e,maxWidth:R}),axisLine:{stroke:W.palette.divider},interval:L?0:O.interval,tickLine:!1,padding:{left:0,right:0},height:V}),
5
+ /* @__PURE__ */t(d,{width:"auto",domain:([t,e])=>[t<0?t-.2*Math.abs(t):t,e],strokeWidth:0,tick:{fontFamily:"Montserrat",fontSize:14,style:{transform:`translateX(-${W.spacing(2)})`}},axisLine:{stroke:W.palette.divider},tickLine:!1,tickFormatter:t=>T(Number(t),X),children:/* @__PURE__ */t(c,{value:E,position:"insideTopLeft",style:{fontFamily:"Montserrat",fontSize:"14px",transform:`translate(-${W.spacing(2.75)}, -${W.spacing(6)})`}})}),
6
6
  /* @__PURE__ */t(h,{y:0,stroke:W.custom.grey[600],strokeWidth:2}),
7
- /* @__PURE__ */t(y,{transformedData:N,valueFormatterFn:H,forcedPrecision:$,precision:P})]})})})};export{b as WaterfallChartCore};
7
+ /* @__PURE__ */t(y,{transformedData:N,valueFormatterFn:T,forcedPrecision:B,precision:X})]})})})};export{b as WaterfallChartCore};
@@ -1,2 +1,2 @@
1
1
  import{jsxs as e,jsx as i}from"react/jsx-runtime";import{useTheme as t,Stack as n,Box as r,Typography as o}from"@mui/material";import{FoodsIcon as l}from"../Icons/FoodsIcon.js";const a=a=>{const s=t(),{withPlus:m=!1,value:u,unit:c,size:d="small",position:p="default-side",colorOverride:f,hideUnitOnNull:g=!1,emptyLabel:h,unitVariant:b}=a,y=`number-${d}`,x="micro"===d||"small"===d,v=x?s.custom.numberWithUnit.unitOffset.compact:s.custom.numberWithUnit.unitOffset.regular,z=s.custom.numberWithUnit.emptyIndicator[d],I=null===u&&g,w="string"==typeof u||null===u?u:s.numbers.valueFormatterFn(u),O=b??(x?"small-medium":"body-medium"),U="default-side"===p?null===u?"flex-end":"baseline":"below-center-aligned"===p?"center":"flex-start";/* @__PURE__ */
2
- return e(n,{display:"inline-flex",direction:"default-side"===p?"row":"column",gap:x?s.spacing(.5):s.spacing(1),alignItems:U,children:[null===u?/* @__PURE__ */i(r,{role:void 0===h?void 0:"img","aria-label":h,"aria-hidden":void 0===h,sx:{alignItems:"center",backgroundColor:s.custom.grey[400],borderRadius:s.spacing(.5),color:s.custom.grey[1400],display:"flex",flexShrink:0,height:z.size,justifyContent:"center",width:z.size},children:/* @__PURE__ */i(l,{icon:"empty",size:z.iconSize})}):/* @__PURE__ */e(o,{variant:y,color:f,children:[m&&Number(u)>0?"+":"",w]}),!1===I&&/* @__PURE__ */i(o,{sx:{marginTop:`${v} !important`},variant:O,color:s.custom.grey[1400],children:c})]})};export{a as NumberWithUnit};
2
+ return e(n,{display:"inline-flex",direction:"default-side"===p?"row":"column",gap:x?s.spacing(.5):s.spacing(1),alignItems:U,children:[null===u?/* @__PURE__ */i(r,{role:void 0===h?void 0:"img","aria-label":h,"aria-hidden":void 0===h,sx:{alignItems:"center",backgroundColor:s.custom.grey[400],borderRadius:s.spacing(.5),color:s.custom.grey[1400],display:"flex",flexShrink:0,height:z.size,justifyContent:"center",width:z.size},children:/* @__PURE__ */i(l,{icon:"empty",size:z.iconSize})}):/* @__PURE__ */e(o,{variant:y,color:f,children:[m&&Number(u)>0?"+":"",w]}),!1===I&&/* @__PURE__ */i(o,{sx:{marginTop:`${v} !important`},variant:O,color:s.custom.grey[2500],children:c})]})};export{a as NumberWithUnit};
@@ -1,10 +1,10 @@
1
- import{jsxs as e,jsx as o}from"react/jsx-runtime";import{useTheme as t,Box as i,Typography as n,Divider as r,CircularProgress as l}from"@mui/material";import{Fragment as a}from"react";import{OptionLine as s}from"./Line/OptionLine.js";import{OptionsHeader as c}from"./Header/OptionHeader.js";import{useFoodsSelectContext as d}from"../Context/useSelect.js";import{FoodsBadge as p}from"../../../Badge/FoodsBadge.js";const m=m=>{const g=t(),{selectedOption:x,options:u,getId:f,getName:h,onChange:b,getIcon:y,getGroupName:j,infiniteScroll:C,onScroll:k}=m,{isSearchFound:B,textOptions:I}=d(),S=u.filter(e=>B(h(e))),v=S.filter(e=>null===x||f(e)!==f(x));/* @__PURE__ */
2
- return e(i,{role:"listbox","aria-label":I.placeholder,onScroll:k,sx:{marginBlock:"8px",display:"flex",flexDirection:"column",...C?{height:"280px",overflowY:"auto"}:{}},children:[
3
- /* @__PURE__ */o(c,{selectedOption:x,getName:h,getIcon:y,onChange:b}),0===S.length&&/* @__PURE__ */e(i,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"8px",marginBlock:"4px"},children:[
1
+ import{jsxs as e,jsx as o}from"react/jsx-runtime";import{useTheme as i,Box as t,Typography as n,Divider as r,CircularProgress as l}from"@mui/material";import{Fragment as a}from"react";import{OptionLine as s}from"./Line/OptionLine.js";import{OptionsHeader as c}from"./Header/OptionHeader.js";import{useFoodsSelectContext as d}from"../Context/useSelect.js";import{FoodsBadge as p}from"../../../Badge/FoodsBadge.js";const m=m=>{const g=i(),{selectedOption:x,options:u,getId:f,getName:h,onChange:b,getIcon:y,getGroupName:j,infiniteScroll:C,onScroll:k}=m,{isSearchFound:B,textOptions:I}=d(),S=u.filter(e=>B(h(e))),v=S.filter(e=>null===x||f(e)!==f(x));/* @__PURE__ */
2
+ return e(t,{role:"listbox","aria-label":I.placeholder,onScroll:k,sx:{marginBlock:"8px",display:"flex",flexDirection:"column",...C?{minHeight:0,overflowY:"auto"}:{}},children:[
3
+ /* @__PURE__ */o(c,{selectedOption:x,getName:h,getIcon:y,onChange:b}),0===S.length&&/* @__PURE__ */e(t,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"8px",marginBlock:"4px"},children:[
4
4
  /* @__PURE__ */o(p,{icon:"questionMark",size:3,boxProps:{sx:{backgroundColor:g.palette.primary[50],borderRadius:"32px"}}}),
5
- /* @__PURE__ */o(n,{variant:"body-medium",children:I.noResult})]}),v.map((t,l)=>{const c=j?.(t),d=void 0!==c&&(0===l||j?.(v[l-1])!==c);/* @__PURE__ */
6
- return e(a,{children:[d&&/* @__PURE__ */e(i,{role:"presentation",sx:{paddingInline:"5%",paddingBlock:"8px 4px"},children:[l>0&&/* @__PURE__ */o(r,{sx:{marginBottom:"12px"}}),
5
+ /* @__PURE__ */o(n,{variant:"body-medium",children:I.noResult})]}),v.map((i,l)=>{const c=j?.(i),d=void 0!==c&&(0===l||j?.(v[l-1])!==c);/* @__PURE__ */
6
+ return e(a,{children:[d&&/* @__PURE__ */e(t,{role:"presentation",sx:{paddingInline:"5%",paddingBlock:"8px 4px"},children:[l>0&&/* @__PURE__ */o(r,{sx:{marginBottom:"12px"}}),
7
7
  /* @__PURE__ */o(n,{variant:"body-bold",children:c})]}),
8
- /* @__PURE__ */o(s,{isSelected:!1,icon:y?y(t):null,displayText:h(t),onClick:()=>b(t)})]},`select-${l}`)}),!0===C?.isFetchingNextPage&&/* @__PURE__ */e(i,{role:"status","aria-label":C.loadingText??"Loading…",sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:1,padding:1},children:[
8
+ /* @__PURE__ */o(s,{isSelected:!1,icon:y?y(i):null,displayText:h(i),onClick:()=>b(i)})]},`select-${l}`)}),!0===C?.isFetchingNextPage&&/* @__PURE__ */e(t,{role:"status","aria-label":C.loadingText??"Loading…",sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:1,padding:1},children:[
9
9
  /* @__PURE__ */o(l,{size:18}),
10
10
  /* @__PURE__ */o(n,{variant:"small",children:C.loadingText??"Loading…"})]})]})};export{m as SelectOptions};
@@ -1,5 +1,5 @@
1
- import{jsxs as e,jsx as o}from"react/jsx-runtime";import{useTheme as t,Button as i,Typography as r}from"@mui/material";import{useState as n,Fragment as l}from"react";import p from"@mui/icons-material/KeyboardArrowDown";import s from"@mui/icons-material/KeyboardArrowUp";import{SelectOptions as a}from"./Options/SelectOptions.js";import{useFoodsSelectContext as c}from"./Context/useSelect.js";import{AnchoredPopover as d}from"../../Popover/AnchoredPopover.js";const m=m=>{const{textOptions:x,disabled:g,closeOnSelect:h,setSearch:u,disableOnEmpty:f}=c(),w=t(),[b,O]=n(null),v=()=>O(null),y=null!==b,{selectedOption:S,infiniteScroll:I}=m,N=/* @__PURE__ */o(y?s:p,{}),P=y?{border:`2px solid ${w.custom.grey[2800]}`}:{},C=((e,o,t,i,r)=>0===e.length?null!==t?i(t):o:null===t?r:i(t))(m.options,x.emptyOptionsText,S,m.getName,x.placeholder),j=f&&0===m.options.length;/* @__PURE__ */
1
+ import{jsxs as e,jsx as o}from"react/jsx-runtime";import{useTheme as t,Button as i,Typography as r}from"@mui/material";import{useState as n,Fragment as l}from"react";import p from"@mui/icons-material/KeyboardArrowDown";import s from"@mui/icons-material/KeyboardArrowUp";import{SelectOptions as a}from"./Options/SelectOptions.js";import{useFoodsSelectContext as c}from"./Context/useSelect.js";import{AnchoredPopover as d}from"../../Popover/AnchoredPopover.js";const m=m=>{const{textOptions:x,disabled:g,closeOnSelect:h,setSearch:u,disableOnEmpty:f}=c(),w=t(),[b,O]=n(null),y=()=>O(null),v=null!==b,{selectedOption:S,infiniteScroll:I}=m,N=/* @__PURE__ */o(v?s:p,{}),P=v?{border:`2px solid ${w.custom.grey[2800]}`}:{},C=((e,o,t,i,r)=>0===e.length?null!==t?i(t):o:null===t?r:i(t))(m.options,x.emptyOptionsText,S,m.getName,x.placeholder),j=f&&0===m.options.length;/* @__PURE__ */
2
2
  return e(l,{children:[
3
- /* @__PURE__ */e(i,{variant:"select",id:m.id,onClick:e=>y?v():O(e.currentTarget),sx:{...P,width:"100%",height:"40px",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0px 12px 0px 12px"},disabled:g||j,children:[m.getIcon&&S&&m.getIcon(S),
3
+ /* @__PURE__ */e(i,{variant:"select",id:m.id,onClick:e=>v?y():O(e.currentTarget),sx:{...P,width:"100%",height:"40px",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0px 12px 0px 12px"},disabled:g||j,children:[m.getIcon&&S&&m.getIcon(S),
4
4
  /* @__PURE__ */o(r,{variant:"body-medium",sx:{width:"100%",textAlign:"left",marginLeft:"8px",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:C}),N]}),
5
- /* @__PURE__ */o(d,{sx:{top:"5px"},paperProps:{width:"280px",maxHeight:"300px",...I?{overflow:"hidden"}:{},border:`1px solid ${w.custom.grey[500]}`,borderRadius:"12px",boxShadow:"0px 4px 20px 0px #514E4E1F",...m.BoxOptionsProps},variant:"headless",anchor:b,open:y,onClose:()=>{v(),u("")},anchorPosition:"rightside",children:/* @__PURE__ */o(a,{selectedOption:m.selectedOption,options:m.options,getId:m.getId,getName:m.getName,getIcon:m.getIcon,getGroupName:m.getGroupName,onChange:e=>{m.onChange(e),u(""),!0===h&&v()},infiniteScroll:I,onScroll:I?e=>{if(!0!==I?.hasNextPage||I.isFetchingNextPage)return;const o=e.currentTarget;o.scrollHeight-o.scrollTop-o.clientHeight<=32&&I.onLoadMore()}:void 0})})]})};export{m as Select};
5
+ /* @__PURE__ */o(d,{sx:{top:"5px"},paperProps:{width:"280px",maxHeight:"min(480px, calc(100% - 32px))",...I?{overflow:"hidden",display:"flex",flexDirection:"column"}:{},border:`1px solid ${w.custom.grey[500]}`,borderRadius:"12px",boxShadow:"0px 4px 20px 0px #514E4E1F",...m.BoxOptionsProps},variant:"headless",anchor:b,open:v,onClose:()=>{y(),u("")},anchorPosition:"rightside",children:/* @__PURE__ */o(a,{selectedOption:m.selectedOption,options:m.options,getId:m.getId,getName:m.getName,getIcon:m.getIcon,getGroupName:m.getGroupName,onChange:e=>{m.onChange(e),u(""),!0===h&&y()},infiniteScroll:I,onScroll:I?e=>{if(!0!==I?.hasNextPage||I.isFetchingNextPage)return;const o=e.currentTarget;o.scrollHeight-o.scrollTop-o.clientHeight<=32&&I.onLoadMore()}:void 0})})]})};export{m as Select};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@foodpilot/foods",
3
3
  "private": false,
4
- "version": "2.25.1",
4
+ "version": "2.25.3",
5
5
  "type": "module",
6
6
  "main": "./dist/main.js",
7
7
  "module": "./dist/main.js",
@@ -328,7 +328,7 @@
328
328
  "chroma-js": "^3.2.0",
329
329
  "i18next": "^23.0.0 || ^25.0.0",
330
330
  "i18next-browser-languagedetector": "^8.2.1",
331
- "i18next-http-backend": "^3.0.5",
331
+ "i18next-http-backend": "^4.0.2",
332
332
  "lexical": "^0.41.0",
333
333
  "lodash": "^4.18.1",
334
334
  "material-ui-popup-state": "^5.3.1",