@foodpilot/foods 2.11.29 → 2.11.31

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,14 +1,21 @@
1
1
  import { ReactNode } from 'react';
2
+ import { StackProps, SxProps } from '@mui/material';
2
3
  import { NumberWithUnitValue } from '../Number';
3
4
  export type FormAccordionContent = {
4
- title: ReactNode;
5
5
  content: ReactNode;
6
+ title?: ReactNode;
6
7
  indicator?: {
7
8
  value: NonNullable<NumberWithUnitValue>;
8
9
  unit: string;
9
10
  };
11
+ renderTitle?: (isExpanded: boolean) => ReactNode;
10
12
  };
11
13
  export type FormAccordionProps = {
12
14
  pages: FormAccordionContent[];
15
+ initialExpandedPageIndex?: number;
16
+ StackProps?: StackProps;
17
+ AccordionSx?: SxProps;
18
+ AccordionSummarySx?: SxProps;
19
+ AccordionDetailSx?: SxProps;
13
20
  };
14
21
  export declare const FormAccordion: (props: FormAccordionProps) => import("react/jsx-runtime").JSX.Element;
@@ -7,7 +7,15 @@ import AccordionDetails from "@mui/material/AccordionDetails";
7
7
  import { FormUnit } from "../Form/FormUnit.js";
8
8
  import { FoodsIcon } from "../Icons/FoodsIcon.js";
9
9
  const FormAccordion = (props) => {
10
- const [expanded, setExpanded] = useState(null);
10
+ const {
11
+ pages,
12
+ initialExpandedPageIndex,
13
+ StackProps: StackProps2 = {},
14
+ AccordionSx = {},
15
+ AccordionSummarySx = {},
16
+ AccordionDetailSx = {}
17
+ } = props;
18
+ const [expanded, setExpanded] = useState(initialExpandedPageIndex ?? null);
11
19
  const theme = useTheme();
12
20
  const refs = useRef([]);
13
21
  const selectWindow = (index) => {
@@ -17,12 +25,13 @@ const FormAccordion = (props) => {
17
25
  }
18
26
  setExpanded(index);
19
27
  };
20
- return /* @__PURE__ */ jsx(Stack, { direction: "column", children: props.pages.map((page, index) => {
28
+ return /* @__PURE__ */ jsx(Stack, { direction: "column", gap: theme.spacing(2), ...StackProps2, children: pages.map((page, index) => {
29
+ const isExpanded = expanded === index;
21
30
  return /* @__PURE__ */ jsxs(
22
31
  Accordion,
23
32
  {
24
33
  ref: (el) => refs.current[index] = el,
25
- expanded: expanded === index,
34
+ expanded: isExpanded,
26
35
  slotProps: {
27
36
  transition: {
28
37
  onEntered: (_node, isAppearing) => {
@@ -41,9 +50,8 @@ const FormAccordion = (props) => {
41
50
  }
42
51
  },
43
52
  sx: {
44
- background: "transparent",
45
- borderTop: `1px solid ${theme.custom.grey[500]}`,
46
- borderRadius: "0 !important",
53
+ border: `1px solid ${theme.custom.grey[500]}`,
54
+ borderRadius: "12px !important",
47
55
  boxShadow: "none",
48
56
  ":before": {
49
57
  height: 0
@@ -53,7 +61,8 @@ const FormAccordion = (props) => {
53
61
  },
54
62
  "&.Mui-expanded": {
55
63
  margin: 0
56
- }
64
+ },
65
+ ...AccordionSx
57
66
  },
58
67
  children: [
59
68
  /* @__PURE__ */ jsx(
@@ -62,11 +71,13 @@ const FormAccordion = (props) => {
62
71
  expandIcon: /* @__PURE__ */ jsx(FoodsIcon, { size: 4, icon: "arrowDownShort" }),
63
72
  onClick: () => selectWindow(index),
64
73
  sx: {
74
+ backgroundColor: theme.custom.grey[100],
65
75
  minHeight: "84px",
66
76
  // I need to somehow FORCE the Font family here. It should be the one defined in the theme to make sure we have
67
77
  // one source of truth, but i can't seem to be able to import it,
68
78
  fontFamily: ["Montserrat", "serif"].join(","),
69
- borderRadius: 0,
79
+ // borderRadius: "12px",
80
+ // borderRadius: "0",
70
81
  padding: 0,
71
82
  "&.Mui-expanded": {
72
83
  minHeight: "84px"
@@ -80,21 +91,35 @@ const FormAccordion = (props) => {
80
91
  display: "flex",
81
92
  alignItems: "center",
82
93
  justifyContent: "center",
83
- marginLeft: "12px",
94
+ // marginLeft: "12px",
84
95
  color: theme.custom.grey[2800]
85
- }
96
+ },
97
+ ...AccordionSummarySx
86
98
  },
87
- children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", gap: "28px", flex: 1, children: [
88
- /* @__PURE__ */ jsx(Typography, { variant: "h3", flex: 1, children: page.title }),
89
- page.indicator && /* @__PURE__ */ jsx(FormUnit, { value: page.indicator.value, unit: page.indicator.unit })
90
- ] })
99
+ children: page.renderTitle ? page.renderTitle(isExpanded) : /* @__PURE__ */ jsxs(
100
+ Stack,
101
+ {
102
+ direction: "row",
103
+ alignItems: "center",
104
+ gap: "28px",
105
+ paddingInline: theme.spacing(2),
106
+ flex: 1,
107
+ children: [
108
+ /* @__PURE__ */ jsx(Typography, { variant: "h3", flex: 1, children: page.title }),
109
+ page.indicator && /* @__PURE__ */ jsx(FormUnit, { value: page.indicator.value, unit: page.indicator.unit })
110
+ ]
111
+ }
112
+ )
91
113
  }
92
114
  ),
93
115
  /* @__PURE__ */ jsx(
94
116
  AccordionDetails,
95
117
  {
96
118
  sx: {
97
- padding: "8px 0 28px 0"
119
+ backgroundColor: theme.custom.grey[400],
120
+ borderBottomLeftRadius: "12px",
121
+ borderBottomRightRadius: "12px",
122
+ ...AccordionDetailSx
98
123
  },
99
124
  children: page.content
100
125
  }
@@ -53,8 +53,12 @@ export type SidebarTexts = {
53
53
  shortenSidebar: string;
54
54
  logout: string;
55
55
  };
56
+ type OrganizationPopoverActions = {
57
+ closePopover: () => void;
58
+ };
56
59
  export type OrganizationPopover = {
57
60
  element: JSX.Element;
61
+ renderPopover?: (actions: OrganizationPopoverActions) => ReactNode;
58
62
  };
59
63
  export type Organization = {
60
64
  name: string;
@@ -76,3 +80,4 @@ export type FoodsNavbarProps = {
76
80
  onMobileDrawerClose?: () => void;
77
81
  };
78
82
  export declare const FoodsNavbar: (props: FoodsNavbarProps) => import("react/jsx-runtime").JSX.Element;
83
+ export {};
@@ -1,9 +1,10 @@
1
1
  import { SxProps } from '@mui/material';
2
+ import { ReactNode } from 'react';
2
3
  type Anchor = HTMLElement | null;
3
4
  type ButtonPopoverProps = {
4
5
  anchor: Anchor;
5
6
  setAnchor: (elementToAttachTo: Anchor) => void;
6
- children: JSX.Element | undefined;
7
+ children: ReactNode;
7
8
  paperOverrides: SxProps | undefined;
8
9
  };
9
10
  export declare const ButtonPopover: (props: ButtonPopoverProps) => import("react/jsx-runtime").JSX.Element;
@@ -7,6 +7,11 @@ const Organization = (props) => {
7
7
  const { isExtended, name, picture, popover } = props;
8
8
  const theme = useTheme();
9
9
  const [anchor, setAnchor] = useState(null);
10
+ const closePopover = () => setAnchor(null);
11
+ const actions = {
12
+ closePopover
13
+ };
14
+ const toRender = (popover == null ? void 0 : popover.renderPopover) ? popover.renderPopover(actions) : popover == null ? void 0 : popover.element;
10
15
  return /* @__PURE__ */ jsxs(Fragment, { children: [
11
16
  /* @__PURE__ */ jsxs(
12
17
  Box,
@@ -82,15 +87,7 @@ const Organization = (props) => {
82
87
  sx: {
83
88
  flex: 1
84
89
  },
85
- children: /* @__PURE__ */ jsx(
86
- ButtonPopover,
87
- {
88
- anchor,
89
- setAnchor,
90
- children: popover == null ? void 0 : popover.element,
91
- paperOverrides: void 0
92
- }
93
- )
90
+ children: /* @__PURE__ */ jsx(ButtonPopover, { anchor, setAnchor, paperOverrides: void 0, children: toRender })
94
91
  }
95
92
  )
96
93
  ] });
package/dist/main.js CHANGED
@@ -146,7 +146,6 @@ import { allColors, allMainColors, dataVisualizationColors, extraColors, greenTh
146
146
  import { components } from "./themes/common/components.js";
147
147
  import { custom, numbers } from "./themes/common/custom.js";
148
148
  import { spacing } from "./themes/common/spacing.js";
149
- import { BredTheme, BredThemeOptions } from "./themes/themes/BredTheme.js";
150
149
  import { CollectiveTheme, CollectiveThemeOptions } from "./themes/themes/CollectiveTheme.js";
151
150
  import { FoodPilotTheme, FoodpilotThemeOptions } from "./themes/themes/FoodPilotTheme.js";
152
151
  import { WinePilotTheme, WinepilotThemeOptions } from "./themes/themes/WinePilotTheme.js";
@@ -168,8 +167,6 @@ export {
168
167
  BottomSheetDialog,
169
168
  BoxStyled,
170
169
  BreakdownTable,
171
- BredTheme,
172
- BredThemeOptions,
173
170
  Button,
174
171
  ButtonTabs,
175
172
  CardImage,
@@ -1,7 +1,7 @@
1
1
  import { Theme } from '@mui/material';
2
2
  import { FoodsThemeProvider, FoodsThemeOptionsProvider } from './FoodsThemeProvider';
3
3
  import { ThemeOptions } from '@mui/material/styles';
4
- declare const THEMES: readonly ["foodpilot", "winepilot", "collective", "bred"];
4
+ declare const THEMES: readonly ["foodpilot", "winepilot", "collective"];
5
5
  export type Themes = (typeof THEMES)[number];
6
6
  export declare const isTheme: (theme: string) => theme is Themes;
7
7
  export declare const themes: Record<Themes, Theme>;
@@ -1,32 +1,27 @@
1
1
  import { ReactComponent as SvgFoodpilot } from "../assets/logos/foodpilot.svg.js";
2
2
  import { ReactComponent as SvgWinepilot } from "../assets/logos/winepilot.svg.js";
3
3
  import { ReactComponent as SvgPositive } from "../assets/logos/positive.svg.js";
4
- import { BredTheme, BredThemeOptions } from "./themes/BredTheme.js";
5
4
  import { CollectiveTheme, CollectiveThemeOptions } from "./themes/CollectiveTheme.js";
6
5
  import { WinePilotTheme, WinepilotThemeOptions } from "./themes/WinePilotTheme.js";
7
6
  import { FoodPilotTheme, FoodpilotThemeOptions } from "./themes/FoodPilotTheme.js";
8
- const THEMES = ["foodpilot", "winepilot", "collective", "bred"];
7
+ const THEMES = ["foodpilot", "winepilot", "collective"];
9
8
  const isTheme = (theme) => {
10
9
  return THEMES.includes(theme);
11
10
  };
12
11
  const themes = {
13
12
  foodpilot: FoodPilotTheme,
14
13
  winepilot: WinePilotTheme,
15
- collective: CollectiveTheme,
16
- bred: BredTheme
14
+ collective: CollectiveTheme
17
15
  };
18
16
  const themeOptions = {
19
17
  foodpilot: FoodpilotThemeOptions,
20
18
  winepilot: WinepilotThemeOptions,
21
- collective: CollectiveThemeOptions,
22
- bred: BredThemeOptions
19
+ collective: CollectiveThemeOptions
23
20
  };
24
21
  const themeLogos = {
25
22
  foodpilot: SvgFoodpilot,
26
23
  winepilot: SvgWinepilot,
27
- collective: SvgPositive,
28
- bred: SvgPositive
29
- // Utilise le logo foodpilot en fallback pour l'instant
24
+ collective: SvgPositive
30
25
  };
31
26
  const getThemeLogo = (theme) => {
32
27
  if (isTheme(theme)) {
@@ -35,8 +30,6 @@ const getThemeLogo = (theme) => {
35
30
  return SvgFoodpilot;
36
31
  };
37
32
  export {
38
- BredTheme,
39
- BredThemeOptions,
40
33
  CollectiveTheme,
41
34
  CollectiveThemeOptions,
42
35
  FoodPilotTheme,
@@ -1,4 +1,3 @@
1
- export { BredTheme, BredThemeOptions } from './BredTheme';
2
1
  export { CollectiveTheme, CollectiveThemeOptions } from './CollectiveTheme';
3
2
  export { FoodPilotTheme, FoodpilotThemeOptions } from './FoodPilotTheme';
4
3
  export { WinePilotTheme, WinepilotThemeOptions } from './WinePilotTheme';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@foodpilot/foods",
3
3
  "private": false,
4
- "version": "2.11.29",
4
+ "version": "2.11.31",
5
5
  "type": "module",
6
6
  "main": "./dist/main.js",
7
7
  "module": "./dist/main.js",
@@ -1,3 +0,0 @@
1
- import { ThemeOptions, Theme } from '@mui/material';
2
- export declare const BredThemeOptions: ThemeOptions;
3
- export declare const BredTheme: Theme;
@@ -1,40 +0,0 @@
1
- import { createTheme } from "@mui/material";
2
- import { redTheme, greyTheme } from "../common/colors.js";
3
- import { components } from "../common/components.js";
4
- import { typographyConfig } from "../common/MUIComponents/typography.js";
5
- import { spacing } from "../common/spacing.js";
6
- import { numbers, custom } from "../common/custom.js";
7
- const BredThemeOptions = {
8
- palette: {
9
- primary: {
10
- 50: "#F2F6FB",
11
- 100: "#C4DCFA",
12
- 200: "#95C3F8",
13
- 300: "#67A9F7",
14
- 400: "#388FF5",
15
- 500: "#317FDB",
16
- 600: "#2A6FC1",
17
- 700: "#2360A6",
18
- 800: "#1C508C",
19
- 900: "#154072"
20
- // main: "linear-gradient(180deg, #388FF5 0%, #2A6FC1 100%)",
21
- },
22
- grey: greyTheme,
23
- text: { primary: "#393a36" },
24
- error: {
25
- light: redTheme[100],
26
- main: redTheme[600],
27
- dark: redTheme[800]
28
- }
29
- },
30
- spacing,
31
- typography: typographyConfig,
32
- custom,
33
- numbers,
34
- components
35
- };
36
- const BredTheme = createTheme(BredThemeOptions);
37
- export {
38
- BredTheme,
39
- BredThemeOptions
40
- };