@foodpilot/foods 2.11.6 → 2.11.8

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.
@@ -10,6 +10,7 @@ export type FoodsToggleButtonType = {
10
10
  startIcon?: keyof IconMapping;
11
11
  onClick?: () => void;
12
12
  disabled?: boolean;
13
+ color?: string;
13
14
  nav?: {
14
15
  url: string;
15
16
  isExternal?: boolean;
@@ -97,7 +97,10 @@ const _ToggleButton = (props) => {
97
97
  setSelectedId(button.id);
98
98
  },
99
99
  selected: isSelected,
100
- disabled: button.disabled
100
+ disabled: button.disabled,
101
+ sx: {
102
+ color: button.color
103
+ }
101
104
  },
102
105
  /* @__PURE__ */ jsxs(
103
106
  Stack,
@@ -0,0 +1,76 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { styled, Tab } from "@mui/material";
3
+ const a11yProps = (index) => {
4
+ return {
5
+ id: `tab-${index}`,
6
+ "aria-controls": `tabpanel-${index}`
7
+ };
8
+ };
9
+ const SpecialTab = styled((props) => {
10
+ return /* @__PURE__ */ jsx(Tab, { disableRipple: true, ...a11yProps(props.value), ...props });
11
+ })((props) => {
12
+ const { theme, variant, textVariant = "body-bold" } = props;
13
+ const typographyTheme = textVariant === "inherit" ? {} : theme.typography[textVariant];
14
+ const globalOverrides = {
15
+ textTransform: "unset",
16
+ ...typographyTheme
17
+ };
18
+ if (variant === "primary") {
19
+ return {
20
+ ...globalOverrides,
21
+ // This is applied on the base value if selected
22
+ "&.Mui-selected": {
23
+ color: theme.palette.primary[600],
24
+ background: theme.palette.background.paper
25
+ },
26
+ // This is applied on the value with Tags, like...
27
+ // <Typography>SomethingSomething</Typography>
28
+ "&.Mui-selected span": {
29
+ color: theme.palette.primary[600]
30
+ }
31
+ };
32
+ }
33
+ if (variant === "secondary") {
34
+ return {
35
+ ...globalOverrides,
36
+ borderRadius: 0,
37
+ borderRight: `1px solid ${theme.custom.grey[500]}`,
38
+ // This is applied on the base value if selected
39
+ "&.Mui-selected": {
40
+ color: theme.palette.primary[600],
41
+ background: theme.palette.background.paper
42
+ },
43
+ // This is applied on the value with Tags, like...
44
+ // <Typography>SomethingSomething</Typography>
45
+ "&.Mui-selected span": {
46
+ color: theme.palette.primary[600]
47
+ }
48
+ };
49
+ }
50
+ if (variant === "buttons") {
51
+ return {
52
+ minHeight: "40px",
53
+ margin: "4px",
54
+ background: "linear-gradient(180deg, #FFFFFF 0%, #F6F5F3 154.5%)",
55
+ border: `1px solid ${theme.custom.grey[600]}`,
56
+ // This is applied on the base value if selected
57
+ "&.Mui-selected": {
58
+ color: "white",
59
+ background: theme.custom.grey[2800],
60
+ border: `1px solid ${theme.custom.grey[2800]}`
61
+ },
62
+ // This is applied on the value with Tags, like...
63
+ // <Typography>SomethingSomething</Typography>
64
+ "&.Mui-selected span": {
65
+ color: "white"
66
+ // color: theme.palette.primary[600],
67
+ },
68
+ ...globalOverrides
69
+ // padding: theme.spacing(4),
70
+ };
71
+ }
72
+ return {};
73
+ });
74
+ export {
75
+ SpecialTab
76
+ };
@@ -0,0 +1,130 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { styled, Box, Tabs } from "@mui/material";
3
+ import { useState, useEffect } from "react";
4
+ import { useResponsiveBreakpoints } from "../../../themes/responsive/useResponsiveBreakpoints.js";
5
+ import { SpecialTab } from "./FoodsTabTemplate.js";
6
+ import { FoodsIcon } from "../../Icons/FoodsIcon.js";
7
+ const FoodsTabs = (props) => {
8
+ const {
9
+ forceScrollable,
10
+ selectedTabIndex,
11
+ tabs,
12
+ BoxProps: BoxProps2,
13
+ TabsProps: TabsProps2,
14
+ TabProps: TabProps2,
15
+ tabVariant,
16
+ textVariant = "body-bold"
17
+ } = props;
18
+ const [value, _setValue] = useState(selectedTabIndex);
19
+ const setValue = (_, newValue) => {
20
+ _setValue(newValue);
21
+ };
22
+ const { isMobile } = useResponsiveBreakpoints();
23
+ const isScrollable = forceScrollable === void 0 && isMobile === true ? true : forceScrollable;
24
+ useEffect(() => {
25
+ _setValue(selectedTabIndex);
26
+ }, [selectedTabIndex]);
27
+ return /* @__PURE__ */ jsx(Box, { sx: { width: "100%" }, ...BoxProps2, children: /* @__PURE__ */ jsx(
28
+ SpecialTabs,
29
+ {
30
+ value,
31
+ onChange: (e, value2) => {
32
+ setValue(e, value2);
33
+ },
34
+ role: "navigation",
35
+ "aria-label": "section-tabs",
36
+ variant: isScrollable ? "scrollable" : "standard",
37
+ tabVariant,
38
+ ...TabsProps2,
39
+ children: tabs.map((tab, tabIndex) => {
40
+ const extraTabProps = {
41
+ // Global Override
42
+ ...TabProps2,
43
+ // Specific Override
44
+ ...tab.TabProps
45
+ };
46
+ const isSelected = tabIndex === value;
47
+ return /* @__PURE__ */ jsx(
48
+ SpecialTab,
49
+ {
50
+ value: tabIndex,
51
+ variant: tabVariant,
52
+ textVariant,
53
+ isSelected,
54
+ label: tab.name,
55
+ icon: /* @__PURE__ */ jsx(Box, { display: "flex", alignItems: "center", children: /* @__PURE__ */ jsx(FoodsIcon, { icon: tab.icon, size: 2 }) }),
56
+ iconPosition: "start",
57
+ ...extraTabProps
58
+ }
59
+ );
60
+ })
61
+ }
62
+ ) });
63
+ };
64
+ const SpecialTabs = styled((props) => {
65
+ const { variant } = props;
66
+ return /* @__PURE__ */ jsx(
67
+ Tabs,
68
+ {
69
+ scrollButtons: variant === "scrollable" ? "auto" : false,
70
+ allowScrollButtonsMobile: variant === "scrollable",
71
+ ...props
72
+ }
73
+ );
74
+ })((props) => {
75
+ const { theme, variant, tabVariant } = props;
76
+ const scrollableStyle = variant !== "scrollable" ? {} : {
77
+ "& .MuiTabs-scrollButtons": {
78
+ "&.Mui-disabled": {
79
+ opacity: 0.3
80
+ }
81
+ }
82
+ };
83
+ if (tabVariant === "primary") {
84
+ return {
85
+ ...scrollableStyle
86
+ };
87
+ }
88
+ if (tabVariant === "secondary") {
89
+ return {
90
+ borderTopLeftRadius: "12px",
91
+ borderTopRightRadius: "12px",
92
+ borderColor: `${theme.custom.grey[500]}`,
93
+ borderWidth: `1px 1px 0px 1px`,
94
+ borderStyle: `solid`,
95
+ background: theme.custom.grey[200],
96
+ // This is the border that shows the selected item below it
97
+ // or on the side of it when it's horizontal
98
+ ".MuiTabs-indicator": {
99
+ backgroundColor: theme.palette.background.paper
100
+ },
101
+ ".MuiTabs-flexContainer::after": {
102
+ content: '" "',
103
+ background: theme.custom.grey[500],
104
+ bottom: 0,
105
+ left: 0,
106
+ right: 0,
107
+ width: "100%",
108
+ height: "1px",
109
+ position: "absolute"
110
+ },
111
+ ...scrollableStyle
112
+ };
113
+ }
114
+ if (tabVariant === "buttons") {
115
+ return {
116
+ backgroundColor: "white",
117
+ ".MuiTabs-indicator": {
118
+ backgroundColor: "white"
119
+ },
120
+ ...scrollableStyle
121
+ };
122
+ }
123
+ return {
124
+ ...scrollableStyle
125
+ };
126
+ });
127
+ export {
128
+ FoodsTabs,
129
+ SpecialTabs
130
+ };
@@ -0,0 +1,2 @@
1
+ export * from './FoodsTabs';
2
+ export * from './FoodsTabTemplate';
@@ -1,3 +1,4 @@
1
1
  export * from './ButtonTabs';
2
2
  export * from './SectionTabs/SectionTabs';
3
3
  export * from './SecondaryTabs';
4
+ export * from './FoodsTabs';
package/dist/main.js CHANGED
@@ -126,6 +126,8 @@ import { SsqCard } from "./components/Ssq/SsqCard.js";
126
126
  import { ButtonTabs } from "./components/Tabs/ButtonTabs.js";
127
127
  import { SectionTabs } from "./components/Tabs/SectionTabs/SectionTabs.js";
128
128
  import { BoxStyled, SecondaryTabs } from "./components/Tabs/SecondaryTabs.js";
129
+ import { FoodsTabs, SpecialTabs } from "./components/Tabs/FoodsTabs/FoodsTabs.js";
130
+ import { SpecialTab } from "./components/Tabs/FoodsTabs/FoodsTabTemplate.js";
129
131
  import { FoodsTags } from "./components/Tags/FoodsTags.js";
130
132
  import { FoodsUserTags } from "./components/Tags/FoodsUserTags.js";
131
133
  import { TextArrowList } from "./components/Text/TextArrowList.js";
@@ -204,6 +206,7 @@ export {
204
206
  FoodsSearch,
205
207
  FoodsSelect,
206
208
  FoodsSelectServerPagination,
209
+ FoodsTabs,
207
210
  FoodsTags,
208
211
  FoodsTextInput,
209
212
  FoodsThemeOptionsProvider,
@@ -273,6 +276,8 @@ export {
273
276
  SelectBlock,
274
277
  Separator,
275
278
  SolidGreyBox,
279
+ SpecialTab,
280
+ SpecialTabs,
276
281
  SsqCard,
277
282
  SubMenu,
278
283
  SuggestionBlock,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@foodpilot/foods",
3
3
  "private": false,
4
- "version": "2.11.6",
4
+ "version": "2.11.8",
5
5
  "type": "module",
6
6
  "main": "./dist/main.js",
7
7
  "module": "./dist/main.js",