@foodpilot/foods 2.7.16 → 2.7.18

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.
Files changed (26) hide show
  1. package/dist/components/Button/FoodsToggleButton.d.ts +13 -1
  2. package/dist/components/Button/FoodsToggleButton.js +51 -36
  3. package/dist/components/Button/TertiaryToggleButton.d.ts +1 -1
  4. package/dist/components/Button/TertiaryToggleButtonNodeTitle.d.ts +1 -1
  5. package/dist/components/Form/FoodsFormFields/FoodsTextInput.d.ts +2 -1
  6. package/dist/components/Form/FoodsFormFields/FoodsTextInput.js +8 -3
  7. package/dist/components/Input/SearchBox.d.ts +1 -1
  8. package/dist/components/Input/SearchBox.js +14 -63
  9. package/dist/components/Layout/BlockList/Blocks/InnerInputBlocks/index.d.ts +0 -2
  10. package/dist/components/RichTextEditor/components/ColorInput/style/index.d.ts +2 -2
  11. package/dist/components/RichTextEditor/components/Toolbar/style/index.d.ts +1 -1
  12. package/dist/components/Search/FoodsSearch.js +11 -55
  13. package/dist/components/Tabs/ButtonTabs.d.ts +3 -0
  14. package/dist/components/Tabs/SecondaryTabs.d.ts +14 -9
  15. package/dist/components/Tabs/SecondaryTabs.js +47 -6
  16. package/dist/components/Tabs/{SectionTabs.d.ts → SectionTabs/SectionTabs.d.ts} +9 -1
  17. package/dist/components/Tabs/SectionTabs/SectionTabs.js +121 -0
  18. package/dist/components/Tabs/index.d.ts +1 -1
  19. package/dist/main.js +1 -5
  20. package/dist/themes/common/components.js +50 -4
  21. package/package.json +1 -1
  22. package/dist/components/Layout/BlockList/Blocks/InnerInputBlocks/NumericalBlock.d.ts +0 -7
  23. package/dist/components/Layout/BlockList/Blocks/InnerInputBlocks/NumericalBlock.js +0 -10
  24. package/dist/components/Layout/BlockList/Blocks/InnerInputBlocks/TextBlock.d.ts +0 -7
  25. package/dist/components/Layout/BlockList/Blocks/InnerInputBlocks/TextBlock.js +0 -10
  26. package/dist/components/Tabs/SectionTabs.js +0 -108
@@ -2,13 +2,18 @@ import { ToggleButtonProps } from '@mui/material';
2
2
  import { IconMapping } from '../Icons';
3
3
  import { ForwardRefExoticComponent, RefAttributes } from 'react';
4
4
  type ToggleButtonsPropsWithoutEnforcedKeys = Omit<ToggleButtonProps, "key" | "value" | "onClick" | "selected" | "unselectable">;
5
+ type ButtonId = number | string;
5
6
  export type FoodsToggleButtonType = {
6
- id: number | string;
7
+ id: ButtonId;
7
8
  label?: string;
8
9
  endIcon?: keyof IconMapping;
9
10
  startIcon?: keyof IconMapping;
10
11
  onClick?: () => void;
11
12
  disabled?: boolean;
13
+ nav?: {
14
+ url: string;
15
+ isExternal?: boolean;
16
+ };
12
17
  };
13
18
  export type FoodsToggleButtonProps = ToggleButtonsPropsWithoutEnforcedKeys & {
14
19
  buttons: FoodsToggleButtonType[];
@@ -18,5 +23,12 @@ export type FoodsToggleButtonProps = ToggleButtonsPropsWithoutEnforcedKeys & {
18
23
  unselectable?: boolean;
19
24
  className?: string;
20
25
  };
26
+ /**
27
+ * This component needs to be refactored because this is used for NAVIGATION and we should use the TABS component
28
+ * instead.
29
+ * Because https://mui.com/material-ui/react-toggle-button/
30
+ * The ToggleButton is meant to be used as an INPUT.
31
+ * Not a Navigation Component, but we use it as a Navigation regardless.
32
+ */
21
33
  export declare const FoodsToggleButton: ForwardRefExoticComponent<Omit<FoodsToggleButtonProps, "ref"> & RefAttributes<unknown>>;
22
34
  export {};
@@ -30,14 +30,10 @@ const ToggleButtonStyled = styled(ToggleButton)(({ theme }) => ({
30
30
  }));
31
31
  const FoodsToggleButton = forwardRef((props, ref) => {
32
32
  const { buttons, initialSelected, ToggleButtonProps: ToggleButtonProps2, buttonGroup = false, unselectable = false, className } = props;
33
- const [selected, setSelected] = useState(initialSelected || null);
34
- const theme = useTheme();
33
+ const [selectedId, setSelectedId] = useState((initialSelected == null ? void 0 : initialSelected.id) ?? null);
35
34
  useEffect(() => {
36
- setSelected(initialSelected ?? null);
35
+ setSelectedId((initialSelected == null ? void 0 : initialSelected.id) ?? null);
37
36
  }, [initialSelected]);
38
- const isSelected = (button) => {
39
- return (selected == null ? void 0 : selected.id) === button.id;
40
- };
41
37
  return /* @__PURE__ */ jsx(
42
38
  Box,
43
39
  {
@@ -67,42 +63,61 @@ const FoodsToggleButton = forwardRef((props, ref) => {
67
63
  },
68
64
  className,
69
65
  children: buttons.map((button) => {
70
- return /* @__PURE__ */ createElement(
71
- ToggleButtonStyled,
66
+ const isSelected = button.id === selectedId;
67
+ return /* @__PURE__ */ jsx(
68
+ _ToggleButton,
72
69
  {
73
- ...ToggleButtonProps2,
74
- key: `${button.id}-button-toggle`,
75
- value: button.id,
76
- onClick: () => {
77
- button.onClick && button.onClick();
78
- if (unselectable && (selected == null ? void 0 : selected.id) === button.id) {
79
- setSelected(null);
80
- return;
81
- }
82
- setSelected(button);
83
- },
84
- selected: isSelected(button),
85
- disabled: button.disabled
86
- },
87
- /* @__PURE__ */ jsxs(
88
- Stack,
89
- {
90
- flexDirection: "row",
91
- justifyContent: "center",
92
- alignItems: "center",
93
- gap: theme.spacing(0.5),
94
- children: [
95
- button.startIcon && /* @__PURE__ */ jsx(FoodsIcon, { size: 2, icon: button.startIcon }),
96
- button.label,
97
- button.endIcon && /* @__PURE__ */ jsx(FoodsIcon, { size: 2, icon: button.endIcon })
98
- ]
99
- }
100
- )
70
+ button,
71
+ unselectable,
72
+ isSelected,
73
+ setSelectedId,
74
+ ToggleButtonProps: ToggleButtonProps2
75
+ }
101
76
  );
102
77
  })
103
78
  }
104
79
  );
105
80
  });
81
+ const _ToggleButton = (props) => {
82
+ const theme = useTheme();
83
+ const { button, ToggleButtonProps: ToggleButtonProps2 = {}, unselectable, isSelected, setSelectedId } = props;
84
+ const { url, isExternal = false } = button.nav || {};
85
+ return /* @__PURE__ */ createElement(
86
+ ToggleButtonStyled,
87
+ {
88
+ ...ToggleButtonProps2,
89
+ key: `${button.id}-button-toggle`,
90
+ value: button.id,
91
+ onClick: () => {
92
+ button.onClick && button.onClick();
93
+ if (unselectable && isSelected) {
94
+ setSelectedId(null);
95
+ return;
96
+ }
97
+ setSelectedId(button.id);
98
+ },
99
+ selected: isSelected,
100
+ disabled: button.disabled
101
+ },
102
+ /* @__PURE__ */ jsxs(
103
+ Stack,
104
+ {
105
+ flexDirection: "row",
106
+ justifyContent: "center",
107
+ alignItems: "center",
108
+ gap: theme.spacing(0.5),
109
+ component: "a",
110
+ href: url ? url : void 0,
111
+ target: isExternal ? "_blank" : void 0,
112
+ children: [
113
+ button.startIcon && /* @__PURE__ */ jsx(FoodsIcon, { size: 2, icon: button.startIcon }),
114
+ button.label,
115
+ button.endIcon && /* @__PURE__ */ jsx(FoodsIcon, { size: 2, icon: button.endIcon })
116
+ ]
117
+ }
118
+ )
119
+ );
120
+ };
106
121
  export {
107
122
  FoodsToggleButton
108
123
  };
@@ -5,7 +5,7 @@ import { DetailedHTMLProps, ButtonHTMLAttributes, DO_NOT_USE_OR_YOU_WILL_BE_FIRE
5
5
  import { MUIStyledCommonProps } from '@mui/system';
6
6
  export declare const CustomToggleButton: StyledComponent< ToggleButtonOwnProps & Omit< ButtonBaseOwnProps, "classes"> & CommonProps & Omit<Omit< DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
7
7
  ref?: ((instance: HTMLButtonElement | null) => void | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLButtonElement> | null | undefined;
8
- }, "className" | "classes" | "style" | "tabIndex" | "color" | "children" | "onChange" | "onClick" | "sx" | "size" | "disabled" | "value" | "action" | "selected" | "disableFocusRipple" | "disableRipple" | "fullWidth" | "centerRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef"> & MUIStyledCommonProps<Theme>, {}, {}>;
8
+ }, "className" | "classes" | "style" | "tabIndex" | "color" | "children" | "onChange" | "onClick" | "sx" | "size" | "disabled" | "value" | "action" | "selected" | "fullWidth" | "disableFocusRipple" | "disableRipple" | "centerRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef"> & MUIStyledCommonProps<Theme>, {}, {}>;
9
9
  type ToggleButtonsPropsWithoutEnforcedKeys = Omit<ToggleButtonProps, "value" | "onClick" | "selected">;
10
10
  export type TertiaryToggleButtonProps = ToggleButtonsPropsWithoutEnforcedKeys & {
11
11
  choices: string[];
@@ -5,7 +5,7 @@ import { CommonProps } from '@mui/material/OverridableComponent';
5
5
  import { MUIStyledCommonProps } from '@mui/system';
6
6
  export declare const CustomToggleButtonNodeTitle: StyledComponent< ToggleButtonOwnProps & Omit< ButtonBaseOwnProps, "classes"> & CommonProps & Omit<Omit< DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
7
7
  ref?: ((instance: HTMLButtonElement | null) => void | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLButtonElement> | null | undefined;
8
- }, "className" | "classes" | "style" | "tabIndex" | "color" | "children" | "onChange" | "onClick" | "sx" | "size" | "disabled" | "value" | "action" | "selected" | "disableFocusRipple" | "disableRipple" | "fullWidth" | "centerRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef"> & MUIStyledCommonProps<Theme>, {}, {}>;
8
+ }, "className" | "classes" | "style" | "tabIndex" | "color" | "children" | "onChange" | "onClick" | "sx" | "size" | "disabled" | "value" | "action" | "selected" | "fullWidth" | "disableFocusRipple" | "disableRipple" | "centerRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef"> & MUIStyledCommonProps<Theme>, {}, {}>;
9
9
  type ToggleButtonsPropsWithoutEnforcedKeys = Omit<ToggleButtonProps, "value" | "onClick" | "selected">;
10
10
  export type TertiaryToggleButtonPropsNodeTitle = ToggleButtonsPropsWithoutEnforcedKeys & {
11
11
  choices: ReactNode[];
@@ -1,4 +1,4 @@
1
- import { InputBaseProps } from '@mui/material';
1
+ import { InputBaseProps, StackProps } from '@mui/material';
2
2
  import { FoodsIconButtonProps } from '../../Button/FoodsIconButton';
3
3
  type DefaultOption = {
4
4
  label: string;
@@ -17,6 +17,7 @@ type FoodsInputBase = Omit<InputBaseProps, keyof OverridenProps>;
17
17
  export type FoodsTextInputProps = OverridenProps & {
18
18
  ExtraInputProps?: FoodsInputBase;
19
19
  Tooltip?: FoodsIconButtonProps["tooltip"];
20
+ StackProps?: StackProps;
20
21
  };
21
22
  export declare const FoodsTextInput: (props: FoodsTextInputProps) => import("react/jsx-runtime").JSX.Element;
22
23
  export {};
@@ -10,11 +10,12 @@ const FoodsTextInput = (props) => {
10
10
  error = false,
11
11
  disabled = false,
12
12
  ExtraInputProps = {},
13
- Tooltip = {}
13
+ Tooltip = {},
14
+ StackProps: StackProps2 = {}
14
15
  } = props;
15
16
  const theme = useTheme();
16
17
  const { text, props: propsTooltip } = Tooltip;
17
- return /* @__PURE__ */ jsxs(Stack, { gap: theme.spacing(1), children: [
18
+ return /* @__PURE__ */ jsxs(Stack, { gap: theme.spacing(1), ...StackProps2, children: [
18
19
  /* @__PURE__ */ jsxs(Stack, { flexDirection: "row", gap: theme.spacing(1.5), alignItems: "center", children: [
19
20
  /* @__PURE__ */ jsx(
20
21
  TextInput,
@@ -70,7 +71,8 @@ const TextInput = styled(InputBase)(({ theme }) => ({
70
71
  "&.MuiInputBase-root": {
71
72
  backgroundColor: "white",
72
73
  height: "40px",
73
- borderRadius: "24px",
74
+ // borderRadius: "24px",
75
+ borderRadius: theme.spacing(1),
74
76
  paddingRight: "12px",
75
77
  paddingLeft: "20px",
76
78
  border: `1px solid ${theme.custom.grey[500]}`,
@@ -100,6 +102,9 @@ const TextInput = styled(InputBase)(({ theme }) => ({
100
102
  ":hover": {
101
103
  backgroundColor: theme.custom.red[200]
102
104
  }
105
+ },
106
+ "&.Mui-error.Mui-focused": {
107
+ border: `2px solid ${theme.custom.red[600]}`
103
108
  }
104
109
  }));
105
110
  export {
@@ -2,6 +2,6 @@ export interface ISearchBoxProps {
2
2
  placeholder?: string;
3
3
  value: string | null;
4
4
  onChange: (value: string) => void;
5
- variant: "standalone" | "inline";
5
+ variant?: "standalone";
6
6
  }
7
7
  export declare function SearchBox(props: ISearchBoxProps): import("react/jsx-runtime").JSX.Element;
@@ -1,68 +1,19 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { SearchOutlined } from "@mui/icons-material";
3
- import { useTheme, Stack, TextField } from "@mui/material";
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { FoodsTextInput } from "../Form/FoodsFormFields/FoodsTextInput.js";
3
+ import { FoodsIcon } from "../Icons/FoodsIcon.js";
4
4
  function SearchBox(props) {
5
- const theme = useTheme();
6
- const stackStyleStandalone = {
7
- height: "40px",
8
- padding: "0px 6px 0px 20px",
9
- ...theme.custom.searchBox,
10
- minWidth: "350px"
11
- };
12
- const buttonStyleStandalone = {
13
- height: "20px",
14
- padding: "0px",
15
- width: "100%",
16
- "&>.MuiInputBase-root>fieldset": {
17
- border: "none"
18
- },
19
- "&>.MuiInputBase-root>input": {
20
- padding: "0"
21
- }
22
- };
23
- const stackStyleInline = {
24
- height: "48px",
25
- padding: "0px 16px 0px 24px",
26
- borderTop: "1px solid " + theme.custom.grey[500],
27
- borderBottom: "1px solid " + theme.custom.grey[500],
28
- background: theme.custom.grey[200]
29
- };
30
- const buttonStyleInline = {
31
- "&>.MuiInputBase-root>fieldset": {
32
- border: "none"
33
- },
34
- "&>.MuiInputBase-root>input": {
35
- width: "100%",
36
- height: "48px",
37
- padding: "0",
38
- border: "none"
39
- }
40
- };
41
- return /* @__PURE__ */ jsxs(
42
- Stack,
5
+ return /* @__PURE__ */ jsx(
6
+ FoodsTextInput,
43
7
  {
44
- direction: "row",
45
- useFlexGap: true,
46
- gap: "10px",
47
- justifyContent: "space-between",
48
- alignItems: "center",
49
- sx: props.variant === "standalone" ? stackStyleStandalone : stackStyleInline,
50
- children: [
51
- /* @__PURE__ */ jsx(
52
- TextField,
53
- {
54
- label: "",
55
- type: "search",
56
- placeholder: props.placeholder,
57
- value: props.value,
58
- onChange: (e) => {
59
- props.onChange(e.target.value);
60
- },
61
- sx: props.variant === "standalone" ? buttonStyleStandalone : buttonStyleInline
62
- }
63
- ),
64
- /* @__PURE__ */ jsx(SearchOutlined, {})
65
- ]
8
+ value: props.value ?? "",
9
+ onChange: (e) => {
10
+ props.onChange(e);
11
+ },
12
+ ExtraInputProps: {
13
+ type: "search",
14
+ placeholder: props.placeholder,
15
+ endAdornment: /* @__PURE__ */ jsx(FoodsIcon, { size: 2, icon: "search" })
16
+ }
66
17
  }
67
18
  );
68
19
  }
@@ -1,5 +1,3 @@
1
1
  export * from './CheckboxBlock';
2
- export * from './NumericalBlock';
3
2
  export * from './RadioBlock';
4
3
  export * from './SelectBlock';
5
- export * from './TextBlock';
@@ -22,12 +22,12 @@ export declare const ColorInputContainer: StyledComponent< BoxOwnProps<Theme> &
22
22
  }, keyof BoxOwnProps<Theme>> & MUIStyledCommonProps<Theme>, {}, {}>;
23
23
  export declare const ColorButton: StyledComponent< ButtonOwnProps & Omit< ButtonBaseOwnProps, "classes"> & CommonProps & Omit<Omit< DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
24
24
  ref?: ((instance: HTMLButtonElement | null) => void | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLButtonElement> | null | undefined;
25
- }, "className" | "classes" | "style" | "tabIndex" | "color" | "children" | "sx" | "size" | "variant" | "href" | "disabled" | "action" | "loading" | "disableElevation" | "disableFocusRipple" | "disableRipple" | "fullWidth" | "centerRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "endIcon" | "loadingIndicator" | "loadingPosition" | "startIcon"> & MUIStyledCommonProps<Theme> & {
25
+ }, "className" | "classes" | "style" | "tabIndex" | "color" | "children" | "sx" | "size" | "variant" | "href" | "disabled" | "action" | "loading" | "fullWidth" | "disableElevation" | "disableFocusRipple" | "disableRipple" | "centerRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "endIcon" | "loadingIndicator" | "loadingPosition" | "startIcon"> & MUIStyledCommonProps<Theme> & {
26
26
  currentColor?: string;
27
27
  }, {}, {}>;
28
28
  export declare const ColorButtonBackground: StyledComponent< ButtonOwnProps & Omit< ButtonBaseOwnProps, "classes"> & CommonProps & Omit<Omit< DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
29
29
  ref?: ((instance: HTMLButtonElement | null) => void | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLButtonElement> | null | undefined;
30
- }, "className" | "classes" | "style" | "tabIndex" | "color" | "children" | "sx" | "size" | "variant" | "href" | "disabled" | "action" | "loading" | "disableElevation" | "disableFocusRipple" | "disableRipple" | "fullWidth" | "centerRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "endIcon" | "loadingIndicator" | "loadingPosition" | "startIcon"> & MUIStyledCommonProps<Theme> & {
30
+ }, "className" | "classes" | "style" | "tabIndex" | "color" | "children" | "sx" | "size" | "variant" | "href" | "disabled" | "action" | "loading" | "fullWidth" | "disableElevation" | "disableFocusRipple" | "disableRipple" | "centerRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "endIcon" | "loadingIndicator" | "loadingPosition" | "startIcon"> & MUIStyledCommonProps<Theme> & {
31
31
  currentColor?: string;
32
32
  }, {}, {}>;
33
33
  export declare const HiddenInput: StyledComponent<MUIStyledCommonProps<Theme>, DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, {}>;
@@ -5,7 +5,7 @@ import { DetailedHTMLProps, ButtonHTMLAttributes, DO_NOT_USE_OR_YOU_WILL_BE_FIRE
5
5
  import { MUIStyledCommonProps, BoxOwnProps } from '@mui/system';
6
6
  export declare const ToolbarButton: StyledComponent< ButtonOwnProps & Omit< ButtonBaseOwnProps, "classes"> & CommonProps & Omit<Omit< DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
7
7
  ref?: ((instance: HTMLButtonElement | null) => void | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLButtonElement> | null | undefined;
8
- }, "className" | "classes" | "style" | "tabIndex" | "color" | "children" | "sx" | "size" | "variant" | "href" | "disabled" | "action" | "loading" | "disableElevation" | "disableFocusRipple" | "disableRipple" | "fullWidth" | "centerRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "endIcon" | "loadingIndicator" | "loadingPosition" | "startIcon"> & MUIStyledCommonProps<Theme>, {}, {}>;
8
+ }, "className" | "classes" | "style" | "tabIndex" | "color" | "children" | "sx" | "size" | "variant" | "href" | "disabled" | "action" | "loading" | "fullWidth" | "disableElevation" | "disableFocusRipple" | "disableRipple" | "centerRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "endIcon" | "loadingIndicator" | "loadingPosition" | "startIcon"> & MUIStyledCommonProps<Theme>, {}, {}>;
9
9
  export declare const TextCommandsContainer: StyledComponent< BoxOwnProps<Theme> & Omit<Omit< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
10
10
  ref?: ((instance: HTMLDivElement | null) => void | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLDivElement> | null | undefined;
11
11
  }, keyof BoxOwnProps<Theme>> & MUIStyledCommonProps<Theme>, {}, {}>;
@@ -1,64 +1,20 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useTheme, Box, TextField } from "@mui/material";
1
+ import { jsx } from "react/jsx-runtime";
3
2
  import { FoodsIcon } from "../Icons/FoodsIcon.js";
4
3
  import { useFoodsSelectContext } from "../Select/FoodsSelect/Context/useSelect.js";
4
+ import { FoodsTextInput } from "../Form/FoodsFormFields/FoodsTextInput.js";
5
5
  const FoodsSearch = () => {
6
6
  const { search, setSearch, textOptions } = useFoodsSelectContext();
7
- const theme = useTheme();
8
- return /* @__PURE__ */ jsxs(
9
- Box,
7
+ return /* @__PURE__ */ jsx(
8
+ FoodsTextInput,
10
9
  {
11
- sx: {
12
- display: "flex",
13
- gap: "8px",
14
- justifyContent: "space-between",
15
- alignItems: "center",
16
- width: "100%",
17
- height: "40px",
18
- padding: "0px 20px 0px 20px",
19
- borderRadius: "24px",
20
- border: `1px solid ${theme.custom.grey[500]}`,
21
- background: "white",
22
- boxShadow: "0px 2px 8px 0px " + theme.custom.grey[500]
10
+ value: search,
11
+ onChange: (newValue) => {
12
+ setSearch(newValue);
23
13
  },
24
- children: [
25
- /* @__PURE__ */ jsx(
26
- TextField,
27
- {
28
- label: "",
29
- placeholder: textOptions.searchPlaceholder,
30
- value: search,
31
- onChange: (e) => {
32
- setSearch(e.target.value);
33
- },
34
- sx: {
35
- width: "100%",
36
- "&>.MuiInputBase-root": {
37
- ">fieldset": {
38
- border: "none"
39
- },
40
- ">input": {
41
- padding: 0
42
- }
43
- }
44
- }
45
- }
46
- ),
47
- /* @__PURE__ */ jsxs(
48
- Box,
49
- {
50
- sx: {
51
- display: "flex",
52
- gap: "8px",
53
- alignItems: "center"
54
- },
55
- children: [
56
- search !== "" && /* @__PURE__ */ jsx(Box, { sx: { display: "flex" }, onClick: () => setSearch(""), children: /* @__PURE__ */ jsx(FoodsIcon, { size: 2, icon: "close" }) }),
57
- /* @__PURE__ */ jsx(FoodsIcon, { size: 3, icon: "search" })
58
- ]
59
- }
60
- )
61
- ]
14
+ ExtraInputProps: {
15
+ placeholder: textOptions.searchPlaceholder,
16
+ endAdornment: /* @__PURE__ */ jsx(FoodsIcon, { size: 2, icon: "search" })
17
+ }
62
18
  }
63
19
  );
64
20
  };
@@ -6,5 +6,8 @@ export type ButtonTabsProps = ToggleButtonsPropsWithoutEnforcedKeys & {
6
6
  onClick?: (index: number) => void;
7
7
  defaultIndex?: number;
8
8
  };
9
+ /**
10
+ * @deprecated
11
+ */
9
12
  export declare const ButtonTabs: (props: ButtonTabsProps) => import("react/jsx-runtime").JSX.Element;
10
13
  export {};
@@ -1,22 +1,27 @@
1
1
  import { ReactElement, ReactNode, DetailedHTMLProps, HTMLAttributes, DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES, RefObject } from 'react';
2
- import { BoxProps, Theme } from '@mui/material';
2
+ import { BoxProps, TabProps, TabsProps, Theme } from '@mui/material';
3
3
  import { StyledComponent } from '@emotion/styled';
4
4
  import { BoxOwnProps, MUIStyledCommonProps } from '@mui/system';
5
5
  export declare const BoxStyled: StyledComponent< BoxOwnProps<Theme> & Omit<Omit< DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
6
6
  ref?: ((instance: HTMLDivElement | null) => void | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLDivElement> | null | undefined;
7
7
  }, keyof BoxOwnProps<Theme>> & MUIStyledCommonProps<Theme>, {}, {}>;
8
- export type SecondaryTab<T = Record<string, unknown>> = {
9
- id: number;
8
+ export type SecondaryTab = {
10
9
  name: string;
11
- onClick: () => void;
10
+ onClick?: () => void;
12
11
  component?: ReactNode;
13
12
  disabled?: boolean | false;
14
13
  icon?: ReactElement;
15
- props?: T;
14
+ tabProps?: {
15
+ href?: string;
16
+ hrefLang?: string;
17
+ isExternal?: boolean;
18
+ };
16
19
  };
17
- export type SecondaryTabsProps<T> = {
18
- tabs: SecondaryTab<T>[];
19
- selectedTab: (tab: SecondaryTab<T>) => boolean;
20
+ export type SecondaryTabsProps = {
21
+ tabs: SecondaryTab[];
22
+ selectedTabIndex: number;
23
+ tabsProps?: TabsProps;
24
+ tabProps?: TabProps;
20
25
  boxProps?: BoxProps;
21
26
  };
22
- export declare const SecondaryTabs: <T>({ tabs, selectedTab, boxProps }: SecondaryTabsProps<T>) => import("react/jsx-runtime").JSX.Element;
27
+ export declare const SecondaryTabs: (props: SecondaryTabsProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useState, useEffect } from "react";
2
3
  import { styled, Box, Tabs, Tab } from "@mui/material";
3
4
  import { greyTheme } from "../../themes/common/colors.js";
4
5
  const BoxStyled = styled(Box)(({ theme }) => () => ({
@@ -67,13 +68,53 @@ const BoxStyled = styled(Box)(({ theme }) => () => ({
67
68
  const TabPanel = ({ children, value, index }) => {
68
69
  return /* @__PURE__ */ jsx(Box, { role: "tabpanel", hidden: value !== index, className: "secondary-tabs-tabpanel", children: value === index && /* @__PURE__ */ jsx(Box, { children }) });
69
70
  };
70
- const SecondaryTabs = ({ tabs, selectedTab, boxProps }) => {
71
- const getIsSelected = () => {
72
- return tabs.findIndex((tab) => selectedTab(tab));
73
- };
71
+ const SecondaryTabs = (props) => {
72
+ const {
73
+ tabs,
74
+ selectedTabIndex,
75
+ boxProps,
76
+ tabProps,
77
+ tabsProps
78
+ } = props;
79
+ const [value, setValue] = useState(selectedTabIndex);
80
+ useEffect(() => {
81
+ setValue(selectedTabIndex);
82
+ }, [selectedTabIndex]);
74
83
  return /* @__PURE__ */ jsxs(BoxStyled, { ...boxProps, className: "secondary-tabs-wrapper", children: [
75
- /* @__PURE__ */ jsx(Tabs, { TabIndicatorProps: { hidden: true }, value: getIsSelected(), className: "secondary-tabs", children: tabs.map((tab, index) => /* @__PURE__ */ jsx(Tab, { label: tab.name, disabled: tab.disabled, icon: tab.icon, onClick: tab.onClick }, index)) }),
76
- /* @__PURE__ */ jsx(Box, { className: "secondary-tabs-content", children: tabs.map((tab, index) => /* @__PURE__ */ jsx(TabPanel, { value: getIsSelected(), index, children: tab.component }, index)) })
84
+ /* @__PURE__ */ jsx(
85
+ Tabs,
86
+ {
87
+ value,
88
+ onChange: (_, value2) => {
89
+ setValue(value2);
90
+ },
91
+ className: "secondary-tabs",
92
+ role: "navigation",
93
+ ...tabsProps,
94
+ children: tabs.map((tab, index) => {
95
+ const { href, hrefLang, isExternal = false } = tab.tabProps || {};
96
+ return /* @__PURE__ */ jsx(
97
+ Tab,
98
+ {
99
+ label: tab.name,
100
+ disabled: tab.disabled,
101
+ icon: (
102
+ // <Box>{tab.icon}</Box>
103
+ tab.icon
104
+ ),
105
+ onClick: tab.onClick,
106
+ component: "a",
107
+ href,
108
+ hrefLang,
109
+ target: isExternal ? "_blank" : void 0,
110
+ ...tabProps
111
+ },
112
+ index
113
+ );
114
+ })
115
+ }
116
+ ),
117
+ /* @__PURE__ */ jsx(Box, { className: "secondary-tabs-content", children: tabs.map((tab, index) => /* @__PURE__ */ jsx(TabPanel, { value, index, children: tab.component }, index)) })
77
118
  ] });
78
119
  };
79
120
  export {
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { BoxProps } from '@mui/material';
2
+ import { BoxProps, TabsProps, TabProps } from '@mui/material';
3
3
  export type SectionTab = {
4
4
  name: string;
5
5
  onClick?: () => void;
@@ -7,6 +7,11 @@ export type SectionTab = {
7
7
  disabled?: boolean | false;
8
8
  icon?: ReactNode;
9
9
  tooltip?: ReactNode;
10
+ tabProps?: {
11
+ href?: string;
12
+ hrefLang?: string;
13
+ isExternal?: boolean;
14
+ };
10
15
  };
11
16
  export type SectionTabsProps = BoxProps & {
12
17
  tabs: SectionTab[];
@@ -17,6 +22,9 @@ export type SectionTabsProps = BoxProps & {
17
22
  * If not provided, scrollable will be automatically enabled on mobile devices.
18
23
  */
19
24
  scrollable?: boolean;
25
+ tabsProps?: TabsProps;
26
+ tabProps?: TabProps;
27
+ boxProps?: BoxProps;
20
28
  };
21
29
  export declare const SectionTabs: (props: SectionTabsProps) => import("react/jsx-runtime").JSX.Element;
22
30
  export type SectionTabPanelProps = {
@@ -0,0 +1,121 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useState, useEffect } from "react";
3
+ import { useTheme, useMediaQuery, Box, Tabs, Tooltip, Tab, Typography } from "@mui/material";
4
+ const SectionTabs = (props) => {
5
+ const {
6
+ tabs,
7
+ value: initialValue = 0,
8
+ renderComponents,
9
+ scrollable = false,
10
+ tabsProps,
11
+ tabProps,
12
+ boxProps,
13
+ ...remainingBoxProps
14
+ } = props;
15
+ const [value, setValue] = useState(initialValue);
16
+ const theme = useTheme();
17
+ const isMobile = useMediaQuery(theme.breakpoints.down("md"));
18
+ const isScrollable = isMobile ? true : scrollable;
19
+ useEffect(() => {
20
+ setValue(initialValue);
21
+ }, [initialValue]);
22
+ return /* @__PURE__ */ jsxs(Box, { sx: { width: "100%" }, ...boxProps, ...remainingBoxProps, children: [
23
+ /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
24
+ Tabs,
25
+ {
26
+ value,
27
+ onChange: (_, value2) => {
28
+ setValue(value2);
29
+ },
30
+ role: "navigation",
31
+ "aria-label": "section-tabs",
32
+ variant: isScrollable ? "scrollable" : "standard",
33
+ scrollButtons: isScrollable ? "auto" : false,
34
+ allowScrollButtonsMobile: isScrollable,
35
+ sx: {
36
+ ...isScrollable && {
37
+ "& .MuiTabs-scrollButtons": {
38
+ "&.Mui-disabled": {
39
+ opacity: 0.3
40
+ }
41
+ }
42
+ }
43
+ },
44
+ ...tabsProps,
45
+ children: tabs.map((tab, tabIndex) => {
46
+ const isSelected = tabIndex === value;
47
+ const { href, hrefLang, isExternal = false } = tab.tabProps || {};
48
+ return /* @__PURE__ */ jsx(Tooltip, { title: tab.tooltip || "", arrow: true, children: /* @__PURE__ */ jsx(
49
+ Tab,
50
+ {
51
+ component: "a",
52
+ href,
53
+ hrefLang,
54
+ target: isExternal ? "_blank" : void 0,
55
+ icon: /* @__PURE__ */ jsx(
56
+ Box,
57
+ {
58
+ sx: {
59
+ ...isSelected && { color: theme.palette.primary[600] }
60
+ },
61
+ children: tab == null ? void 0 : tab.icon
62
+ }
63
+ ),
64
+ label: /* @__PURE__ */ jsx(
65
+ Typography,
66
+ {
67
+ variant: "h4",
68
+ sx: {
69
+ textTransform: "none",
70
+ ...isSelected && {
71
+ color: theme.palette.primary[600]
72
+ }
73
+ },
74
+ children: tab.name
75
+ }
76
+ ),
77
+ disabled: tab.disabled,
78
+ sx: {
79
+ opacity: tab.disabled ? 0.36 : 1,
80
+ ...isScrollable && {
81
+ minWidth: "auto",
82
+ whiteSpace: "nowrap"
83
+ }
84
+ },
85
+ onClick: () => {
86
+ tab.onClick && tab.onClick();
87
+ },
88
+ iconPosition: "start",
89
+ ...a11yProps(tabIndex),
90
+ ...tabProps
91
+ }
92
+ ) }, tabIndex);
93
+ })
94
+ }
95
+ ) }),
96
+ renderComponents && (tabs == null ? void 0 : tabs.map((tab, i) => /* @__PURE__ */ jsx(SectionTabPanel, { value, index: i, children: tab.component }, i)))
97
+ ] });
98
+ };
99
+ const SectionTabPanel = (props) => {
100
+ const { children, value, index, ...otherProps } = props;
101
+ return /* @__PURE__ */ jsx(
102
+ "div",
103
+ {
104
+ role: "tabpanel",
105
+ hidden: value !== index,
106
+ id: `tabpanel-${index}`,
107
+ "aria-labelledby": `tab-${index}`,
108
+ ...otherProps,
109
+ children: value === index && /* @__PURE__ */ jsx(Box, { sx: { padding: 3 }, children })
110
+ }
111
+ );
112
+ };
113
+ const a11yProps = (index) => {
114
+ return {
115
+ id: `tab-${index}`,
116
+ "aria-controls": `tabpanel-${index}`
117
+ };
118
+ };
119
+ export {
120
+ SectionTabs
121
+ };
@@ -1,3 +1,3 @@
1
1
  export * from './ButtonTabs';
2
- export * from './SectionTabs';
2
+ export * from './SectionTabs/SectionTabs';
3
3
  export * from './SecondaryTabs';
package/dist/main.js CHANGED
@@ -89,10 +89,8 @@ import { BlockItemInner } from "./components/Layout/BlockList/Blocks/Container/B
89
89
  import { EmptyForm } from "./components/Layout/BlockList/Blocks/InnerInfoBlocks/EmptyForm.js";
90
90
  import { SuggestionBlock } from "./components/Layout/BlockList/Blocks/InnerInfoBlocks/SuggestionBlock.js";
91
91
  import { CheckboxBlock } from "./components/Layout/BlockList/Blocks/InnerInputBlocks/CheckboxBlock.js";
92
- import { NumericalBlock } from "./components/Layout/BlockList/Blocks/InnerInputBlocks/NumericalBlock.js";
93
92
  import { RadioBlock } from "./components/Layout/BlockList/Blocks/InnerInputBlocks/RadioBlock.js";
94
93
  import { SelectBlock } from "./components/Layout/BlockList/Blocks/InnerInputBlocks/SelectBlock.js";
95
- import { TextBlock } from "./components/Layout/BlockList/Blocks/InnerInputBlocks/TextBlock.js";
96
94
  import { ListHeader } from "./components/Layout/BlockList/Headers/ListHeader.js";
97
95
  import { EditHeader } from "./components/Layout/BlockList/Headers/EditHeader.js";
98
96
  import { InitHeader } from "./components/Layout/BlockList/Headers/InitHeader.js";
@@ -124,7 +122,7 @@ import { FoodsSearch } from "./components/Search/FoodsSearch.js";
124
122
  import { FoodsSelect, FoodsSelectServerPagination } from "./components/Select/FoodsSelect/FoodsSelect.js";
125
123
  import { SsqCard } from "./components/Ssq/SsqCard.js";
126
124
  import { ButtonTabs } from "./components/Tabs/ButtonTabs.js";
127
- import { SectionTabs } from "./components/Tabs/SectionTabs.js";
125
+ import { SectionTabs } from "./components/Tabs/SectionTabs/SectionTabs.js";
128
126
  import { BoxStyled, SecondaryTabs } from "./components/Tabs/SecondaryTabs.js";
129
127
  import { FoodsTags } from "./components/Tags/FoodsTags.js";
130
128
  import { FoodsUserTags } from "./components/Tags/FoodsUserTags.js";
@@ -240,7 +238,6 @@ export {
240
238
  Navbar,
241
239
  NumberField,
242
240
  NumberWithUnit,
243
- NumericalBlock,
244
241
  OptionsPopover,
245
242
  FoodsPills as Pills,
246
243
  PointsCell,
@@ -276,7 +273,6 @@ export {
276
273
  TertiaryToggleButton,
277
274
  TertiaryToggleButtonNodeTitle,
278
275
  TextArrowList,
279
- TextBlock,
280
276
  TextField,
281
277
  TextTitle,
282
278
  TextTitleGreyIcon,
@@ -7,6 +7,13 @@ const components = {
7
7
  }
8
8
  }
9
9
  },
10
+ MuiAutocomplete: {
11
+ styleOverrides: {
12
+ root: () => {
13
+ return {};
14
+ }
15
+ }
16
+ },
10
17
  MuiAvatar: {
11
18
  defaultProps: {
12
19
  children: []
@@ -169,7 +176,7 @@ const components = {
169
176
  },
170
177
  ...ownerState.variant === "select" && {
171
178
  backgroundColor: theme.custom.grey[100],
172
- borderRadius: "24px",
179
+ borderRadius: theme.spacing(1),
173
180
  border: `1px solid ${theme.custom.grey[500]}`
174
181
  },
175
182
  ...ownerState.variant === "validate" && {
@@ -633,9 +640,48 @@ const components = {
633
640
  })
634
641
  }
635
642
  },
636
- MuiInputBase: {
637
- styleOverrides: {}
638
- },
643
+ // This should be activated, but there is too many ripple effect on the codebase right now
644
+ // MuiInputBase: {
645
+ // styleOverrides: {
646
+ // root: ({ theme }) => ({
647
+ // backgroundColor: "white",
648
+ // height: "40px",
649
+ // borderRadius: theme.spacing(1),
650
+ // paddingRight: "12px",
651
+ // paddingLeft: "20px",
652
+ // border: `1px solid ${theme.custom.grey[500]}`,
653
+ // "&:hover": {
654
+ // backgroundColor: theme.custom.grey[300],
655
+ // },
656
+ // color: theme.custom.grey[2800],
657
+ // ...theme.typography["body-medium"],
658
+ // "& ::placeholder": {
659
+ // ...theme.typography["body-medium"],
660
+ // color: theme.custom.grey[1400],
661
+ // },
662
+ // "&.Mui-disabled": {
663
+ // backgroundColor: theme.custom.grey[500],
664
+ // "&:hover": {
665
+ // backgroundColor: theme.custom.grey[500],
666
+ // },
667
+ // },
668
+ // "&.Mui-focused": {
669
+ // border: `2px solid ${theme.custom.grey[2800]}`,
670
+ // },
671
+ // "&.Mui-error": {
672
+ // border: `1px solid ${theme.custom.red[600]}`,
673
+ // backgroundColor: theme.custom.red[100],
674
+ // color: theme.custom.red[600],
675
+ // "&:hover": {
676
+ // backgroundColor: theme.custom.red[200],
677
+ // },
678
+ // },
679
+ // "&.Mui-error.Mui-focused": {
680
+ // border: `2px solid ${theme.custom.red[600]}`,
681
+ // },
682
+ // }),
683
+ // },
684
+ // },
639
685
  MuiChip: {
640
686
  styleOverrides: {
641
687
  root: ({ theme, ownerState }) => ({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@foodpilot/foods",
3
3
  "private": false,
4
- "version": "2.7.16",
4
+ "version": "2.7.18",
5
5
  "type": "module",
6
6
  "main": "./dist/main.js",
7
7
  "module": "./dist/main.js",
@@ -1,7 +0,0 @@
1
- import { BlockOptions } from '../Container/BlockItemInner';
2
- import { RoundInputProps } from '../../../../Input';
3
- type NumericalBlockProps = RoundInputProps & {
4
- blockOptions: BlockOptions;
5
- };
6
- export declare const NumericalBlock: (props: NumericalBlockProps) => import("react/jsx-runtime").JSX.Element;
7
- export {};
@@ -1,10 +0,0 @@
1
- import { jsx, Fragment } from "react/jsx-runtime";
2
- import { BlockItemInner } from "../Container/BlockItemInner.js";
3
- import { RoundInput } from "../../../../Input/RoundInput.js";
4
- const NumericalBlock = (props) => {
5
- const { blockOptions, ...FoodsRoundInputProps } = props;
6
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(BlockItemInner, { blockOptions, children: /* @__PURE__ */ jsx(RoundInput, { ...FoodsRoundInputProps, type: "number" }) }) });
7
- };
8
- export {
9
- NumericalBlock
10
- };
@@ -1,7 +0,0 @@
1
- import { BlockOptions } from '../Container/BlockItemInner';
2
- import { RoundInputProps } from '../../../../Input';
3
- type TextBlockProps = RoundInputProps & {
4
- blockOptions: BlockOptions;
5
- };
6
- export declare const TextBlock: (props: TextBlockProps) => import("react/jsx-runtime").JSX.Element;
7
- export {};
@@ -1,10 +0,0 @@
1
- import { jsx, Fragment } from "react/jsx-runtime";
2
- import { BlockItemInner } from "../Container/BlockItemInner.js";
3
- import { RoundInput } from "../../../../Input/RoundInput.js";
4
- const TextBlock = (props) => {
5
- const { blockOptions, ...FoodsRoundInputProps } = props;
6
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(BlockItemInner, { blockOptions, children: /* @__PURE__ */ jsx(RoundInput, { ...FoodsRoundInputProps }) }) });
7
- };
8
- export {
9
- TextBlock
10
- };
@@ -1,108 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useState, useEffect } from "react";
3
- import { useTheme, useMediaQuery, Box, Tabs, Tooltip, Tab, Typography } from "@mui/material";
4
- const SectionTabs = (props) => {
5
- const { tabs, value: initialValue, renderComponents, scrollable, ...boxProps } = props;
6
- const [value, setValue] = useState(0);
7
- const theme = useTheme();
8
- const isMobile = useMediaQuery(theme.breakpoints.down("md"));
9
- const isScrollable = scrollable !== void 0 ? scrollable : isMobile;
10
- const handleChange = (_, value2) => {
11
- setValue(value2);
12
- };
13
- useEffect(() => {
14
- setValue(initialValue ?? 0);
15
- }, [initialValue]);
16
- return /* @__PURE__ */ jsxs(Box, { sx: { width: "100%" }, ...boxProps, children: [
17
- /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
18
- Tabs,
19
- {
20
- TabIndicatorProps: {
21
- sx: {
22
- backgroundColor: theme.palette.primary[600],
23
- color: theme.palette.primary[600]
24
- }
25
- },
26
- value,
27
- onChange: handleChange,
28
- "aria-label": "section-tabs",
29
- variant: isScrollable ? "scrollable" : "standard",
30
- scrollButtons: isScrollable ? "auto" : false,
31
- allowScrollButtonsMobile: isScrollable,
32
- sx: {
33
- ...isScrollable && {
34
- "& .MuiTabs-scrollButtons": {
35
- "&.Mui-disabled": {
36
- opacity: 0.3
37
- }
38
- }
39
- }
40
- },
41
- children: tabs.map((tab, i) => /* @__PURE__ */ jsx(Tooltip, { title: tab.tooltip || "", arrow: true, children: /* @__PURE__ */ jsx(
42
- Tab,
43
- {
44
- icon: /* @__PURE__ */ jsx(
45
- Box,
46
- {
47
- sx: {
48
- ...i === value && { fill: theme.palette.primary[600] }
49
- },
50
- children: tab == null ? void 0 : tab.icon
51
- }
52
- ),
53
- label: /* @__PURE__ */ jsx(
54
- Typography,
55
- {
56
- variant: "h4",
57
- sx: {
58
- textTransform: "none",
59
- ...i === value && {
60
- color: theme.palette.primary[600]
61
- }
62
- },
63
- children: tab.name
64
- }
65
- ),
66
- disabled: tab.disabled,
67
- sx: {
68
- opacity: tab.disabled ? 0.36 : 1,
69
- ...isScrollable && {
70
- minWidth: "auto",
71
- whiteSpace: "nowrap"
72
- }
73
- },
74
- onClick: () => {
75
- tab.onClick && tab.onClick();
76
- },
77
- iconPosition: "start",
78
- ...loadInnerComponents(i)
79
- }
80
- ) }, i))
81
- }
82
- ) }),
83
- renderComponents && (tabs == null ? void 0 : tabs.map((tab, i) => /* @__PURE__ */ jsx(SectionTabPanel, { value, index: i, children: tab.component }, i)))
84
- ] });
85
- };
86
- const SectionTabPanel = (props) => {
87
- const { children, value, index, ...otherProps } = props;
88
- return /* @__PURE__ */ jsx(
89
- "div",
90
- {
91
- role: "tabpanel",
92
- hidden: value !== index,
93
- id: `tabpanel-${index}`,
94
- "aria-labelledby": `tab-${index}`,
95
- ...otherProps,
96
- children: value === index && /* @__PURE__ */ jsx(Box, { sx: { padding: 3 }, children })
97
- }
98
- );
99
- };
100
- const loadInnerComponents = (index) => {
101
- return {
102
- id: `tab-${index}`,
103
- "aria-controls": `tabpanel-${index}`
104
- };
105
- };
106
- export {
107
- SectionTabs
108
- };