@popmenu/ordering-ui 0.151.1 → 0.153.0
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.
- package/build/cjs/components/Button/Button.d.ts +1 -1
- package/build/cjs/components/DialogSection/DialogSection.d.ts +2 -2
- package/build/cjs/components/DialogTitle/DialogTitle.d.ts +2 -2
- package/build/cjs/components/DishCheckoutCard/DishCheckoutCard.d.ts +1 -2
- package/build/cjs/components/DishModifierCard/DishModifierCard.d.ts +1 -2
- package/build/cjs/components/DishModifierCard/ModifierControls.d.ts +1 -2
- package/build/cjs/components/DishModifierCard/ModifierForm.d.ts +2 -3
- package/build/cjs/components/ExpandableModifierGroup/ExpandableModifierGroup.d.ts +5 -0
- package/build/cjs/components/ExpandableModifierGroup/ExpandableModifierGroup.styles.d.ts +1 -0
- package/build/cjs/components/ExpandableModifierGroup/ExpandableModifierGroupProps.d.ts +11 -0
- package/build/cjs/components/ExpandableModifierGroup/index.d.ts +2 -0
- package/build/cjs/components/ItemTagGroup/ItemTagGroup.d.ts +2 -2
- package/build/cjs/components/LocationCard/LocationCard.d.ts +1 -2
- package/build/cjs/components/MenuBanner/MenuBanner.d.ts +1 -2
- package/build/cjs/components/MenuBanner/MenuBannerIcons.d.ts +3 -4
- package/build/cjs/components/MenuItemCard/MenuItemCardImg.d.ts +1 -2
- package/build/cjs/components/MenuItemCard/MenuItemCardInfo.d.ts +1 -1
- package/build/cjs/components/MenuItemCard/MenuItemCardPrice.d.ts +1 -2
- package/build/cjs/components/MenuItemCard/MenuItemCardReactions.d.ts +1 -2
- package/build/cjs/components/MenuItemCard/MenuItemCardTags.d.ts +1 -2
- package/build/cjs/components/MenuItemModifiersList/MenuItemModifiersList.d.ts +1 -2
- package/build/cjs/components/MenuItemModifiersList/ModifierGroup.d.ts +1 -2
- package/build/cjs/components/MenuTab/MenuTab.d.ts +1 -2
- package/build/cjs/components/MenuTabGroup/MenuTabGroup.d.ts +1 -2
- package/build/cjs/components/NestedModsV2DishModifierCard/DishModifierCard.styles.d.ts +5 -0
- package/build/cjs/components/NestedModsV2DishModifierCard/DishModifierCardProps.d.ts +79 -0
- package/build/cjs/components/NestedModsV2DishModifierCard/ModifierControls.d.ts +2 -0
- package/build/cjs/components/NestedModsV2DishModifierCard/NestedModsV2DishModifierCard.d.ts +5 -0
- package/build/cjs/components/NestedModsV2DishModifierCard/index.d.ts +2 -0
- package/build/cjs/components/OrderingAppContext/OrderingAppContext.d.ts +1 -1
- package/build/cjs/components/PageSection/PageSection.d.ts +1 -1
- package/build/cjs/components/ReactionCounter/ReactionCounter.d.ts +1 -2
- package/build/cjs/components/ReactionCounterGroup/ReactionCounterGroup.d.ts +2 -2
- package/build/cjs/components/SelectableChip/SelectableChip.d.ts +1 -2
- package/build/cjs/components/SelectableChipGroup/SelectableChipGroup.d.ts +1 -1
- package/build/cjs/components/SelectedMenuFiltersList/SelectedMenuFiltersList.d.ts +1 -2
- package/build/cjs/components/StatusTag/StatusTag.d.ts +1 -2
- package/build/cjs/components/index.d.ts +4 -0
- package/build/cjs/index.js +455 -28
- package/build/cjs/index.js.map +1 -1
- package/build/esm/components/Button/Button.d.ts +1 -1
- package/build/esm/components/DialogSection/DialogSection.d.ts +2 -2
- package/build/esm/components/DialogTitle/DialogTitle.d.ts +2 -2
- package/build/esm/components/DishCheckoutCard/DishCheckoutCard.d.ts +1 -2
- package/build/esm/components/DishModifierCard/DishModifierCard.d.ts +1 -2
- package/build/esm/components/DishModifierCard/ModifierControls.d.ts +1 -2
- package/build/esm/components/DishModifierCard/ModifierForm.d.ts +2 -3
- package/build/esm/components/ExpandableModifierGroup/ExpandableModifierGroup.d.ts +5 -0
- package/build/esm/components/ExpandableModifierGroup/ExpandableModifierGroup.js +23 -0
- package/build/esm/components/ExpandableModifierGroup/ExpandableModifierGroup.js.map +1 -0
- package/build/esm/components/ExpandableModifierGroup/ExpandableModifierGroup.styles.d.ts +1 -0
- package/build/esm/components/ExpandableModifierGroup/ExpandableModifierGroup.styles.js +57 -0
- package/build/esm/components/ExpandableModifierGroup/ExpandableModifierGroup.styles.js.map +1 -0
- package/build/esm/components/ExpandableModifierGroup/ExpandableModifierGroupProps.d.ts +11 -0
- package/build/esm/components/ExpandableModifierGroup/index.d.ts +2 -0
- package/build/esm/components/ItemTagGroup/ItemTagGroup.d.ts +2 -2
- package/build/esm/components/LocationCard/LocationCard.d.ts +1 -2
- package/build/esm/components/MenuBanner/MenuBanner.d.ts +1 -2
- package/build/esm/components/MenuBanner/MenuBannerIcons.d.ts +3 -4
- package/build/esm/components/MenuItemCard/MenuItemCardImg.d.ts +1 -2
- package/build/esm/components/MenuItemCard/MenuItemCardInfo.d.ts +1 -1
- package/build/esm/components/MenuItemCard/MenuItemCardPrice.d.ts +1 -2
- package/build/esm/components/MenuItemCard/MenuItemCardReactions.d.ts +1 -2
- package/build/esm/components/MenuItemCard/MenuItemCardTags.d.ts +1 -2
- package/build/esm/components/MenuItemModifiersList/MenuItemModifiersList.d.ts +1 -2
- package/build/esm/components/MenuItemModifiersList/ModifierGroup.d.ts +1 -2
- package/build/esm/components/MenuTab/MenuTab.d.ts +1 -2
- package/build/esm/components/MenuTabGroup/MenuTabGroup.d.ts +1 -2
- package/build/esm/components/NestedModsV2DishModifierCard/DishModifierCard.styles.d.ts +5 -0
- package/build/esm/components/NestedModsV2DishModifierCard/DishModifierCard.styles.js +165 -0
- package/build/esm/components/NestedModsV2DishModifierCard/DishModifierCard.styles.js.map +1 -0
- package/build/esm/components/NestedModsV2DishModifierCard/DishModifierCardProps.d.ts +79 -0
- package/build/esm/components/NestedModsV2DishModifierCard/ModifierControls.d.ts +2 -0
- package/build/esm/components/NestedModsV2DishModifierCard/ModifierControls.js +171 -0
- package/build/esm/components/NestedModsV2DishModifierCard/ModifierControls.js.map +1 -0
- package/build/esm/components/NestedModsV2DishModifierCard/NestedModsV2DishModifierCard.d.ts +5 -0
- package/build/esm/components/NestedModsV2DishModifierCard/NestedModsV2DishModifierCard.js +47 -0
- package/build/esm/components/NestedModsV2DishModifierCard/NestedModsV2DishModifierCard.js.map +1 -0
- package/build/esm/components/NestedModsV2DishModifierCard/index.d.ts +2 -0
- package/build/esm/components/OrderingAppContext/OrderingAppContext.d.ts +1 -1
- package/build/esm/components/PageSection/PageSection.d.ts +1 -1
- package/build/esm/components/ReactionCounter/ReactionCounter.d.ts +1 -2
- package/build/esm/components/ReactionCounterGroup/ReactionCounterGroup.d.ts +2 -2
- package/build/esm/components/SelectableChip/SelectableChip.d.ts +1 -2
- package/build/esm/components/SelectableChipGroup/SelectableChipGroup.d.ts +1 -1
- package/build/esm/components/SelectedMenuFiltersList/SelectedMenuFiltersList.d.ts +1 -2
- package/build/esm/components/StatusTag/StatusTag.d.ts +1 -2
- package/build/esm/components/index.d.ts +4 -0
- package/build/esm/index.js +2 -0
- package/build/esm/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { makeStyles } from '@material-ui/core';
|
|
2
|
+
|
|
3
|
+
const useExpandableModifierGroupStyles = makeStyles((theme) => ({
|
|
4
|
+
root: {
|
|
5
|
+
backgroundColor: theme.palette.grey[100],
|
|
6
|
+
borderRadius: '8px',
|
|
7
|
+
},
|
|
8
|
+
header: {
|
|
9
|
+
alignItems: 'center',
|
|
10
|
+
background: 'none',
|
|
11
|
+
border: 'none',
|
|
12
|
+
borderRadius: '8px',
|
|
13
|
+
cursor: 'pointer',
|
|
14
|
+
display: 'flex',
|
|
15
|
+
justifyContent: 'space-between',
|
|
16
|
+
padding: theme.spacing(1.5, 2),
|
|
17
|
+
width: '100%',
|
|
18
|
+
},
|
|
19
|
+
name: {
|
|
20
|
+
color: theme.palette.grey[700],
|
|
21
|
+
fontSize: '0.75rem',
|
|
22
|
+
fontWeight: 600,
|
|
23
|
+
letterSpacing: '0.08em',
|
|
24
|
+
textTransform: 'uppercase',
|
|
25
|
+
},
|
|
26
|
+
chevron: {
|
|
27
|
+
color: theme.palette.info.main,
|
|
28
|
+
transition: 'transform 0.2s ease',
|
|
29
|
+
},
|
|
30
|
+
chevronExpanded: {
|
|
31
|
+
transform: 'rotate(90deg)',
|
|
32
|
+
},
|
|
33
|
+
headerExpanded: {
|
|
34
|
+
paddingBottom: theme.spacing(0.5),
|
|
35
|
+
},
|
|
36
|
+
summary: {
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
columnGap: theme.spacing(1),
|
|
39
|
+
display: 'flex',
|
|
40
|
+
padding: theme.spacing(0, 2, 1.5),
|
|
41
|
+
},
|
|
42
|
+
summaryIcon: {
|
|
43
|
+
color: theme.palette.success.main,
|
|
44
|
+
},
|
|
45
|
+
// TODO [sc-162475]: 0.625rem (10px) is below the recommended minimum font size for accessibility — address in followup
|
|
46
|
+
summaryText: {
|
|
47
|
+
color: theme.palette.grey[700],
|
|
48
|
+
fontSize: '0.625rem',
|
|
49
|
+
lineHeight: 1.2,
|
|
50
|
+
overflow: 'hidden',
|
|
51
|
+
textOverflow: 'ellipsis',
|
|
52
|
+
whiteSpace: 'nowrap',
|
|
53
|
+
},
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
export { useExpandableModifierGroupStyles };
|
|
57
|
+
//# sourceMappingURL=ExpandableModifierGroup.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpandableModifierGroup.styles.js","sources":["../../../../src/components/ExpandableModifierGroup/ExpandableModifierGroup.styles.ts"],"sourcesContent":["import { makeStyles, Theme } from '@material-ui/core'\n\nexport const useExpandableModifierGroupStyles = makeStyles<Theme>((theme) => ({\n root: {\n backgroundColor: theme.palette.grey[100],\n borderRadius: '8px',\n },\n header: {\n alignItems: 'center',\n background: 'none',\n border: 'none',\n borderRadius: '8px',\n cursor: 'pointer',\n display: 'flex',\n justifyContent: 'space-between',\n padding: theme.spacing(1.5, 2),\n width: '100%',\n },\n name: {\n color: theme.palette.grey[700],\n fontSize: '0.75rem',\n fontWeight: 600,\n letterSpacing: '0.08em',\n textTransform: 'uppercase',\n },\n chevron: {\n color: theme.palette.info.main,\n transition: 'transform 0.2s ease',\n },\n chevronExpanded: {\n transform: 'rotate(90deg)',\n },\n headerExpanded: {\n paddingBottom: theme.spacing(0.5),\n },\n summary: {\n alignItems: 'center',\n columnGap: theme.spacing(1),\n display: 'flex',\n padding: theme.spacing(0, 2, 1.5),\n },\n summaryIcon: {\n color: theme.palette.success.main,\n },\n // TODO [sc-162475]: 0.625rem (10px) is below the recommended minimum font size for accessibility — address in followup\n summaryText: {\n color: theme.palette.grey[700],\n fontSize: '0.625rem',\n lineHeight: 1.2,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n },\n}))\n"],"names":[],"mappings":";;AAEa,MAAA,gCAAgC,GAAG,UAAU,CAAQ,CAAC,KAAK,MAAM;AAC5E,IAAA,IAAI,EAAE;QACJ,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;AACxC,QAAA,YAAY,EAAE,KAAK;AACpB,KAAA;AACD,IAAA,MAAM,EAAE;AACN,QAAA,UAAU,EAAE,QAAQ;AACpB,QAAA,UAAU,EAAE,MAAM;AAClB,QAAA,MAAM,EAAE,MAAM;AACd,QAAA,YAAY,EAAE,KAAK;AACnB,QAAA,MAAM,EAAE,SAAS;AACjB,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,cAAc,EAAE,eAAe;QAC/B,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAC9B,QAAA,KAAK,EAAE,MAAM;AACd,KAAA;AACD,IAAA,IAAI,EAAE;QACJ,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;AAC9B,QAAA,QAAQ,EAAE,SAAS;AACnB,QAAA,UAAU,EAAE,GAAG;AACf,QAAA,aAAa,EAAE,QAAQ;AACvB,QAAA,aAAa,EAAE,WAAW;AAC3B,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;AAC9B,QAAA,UAAU,EAAE,qBAAqB;AAClC,KAAA;AACD,IAAA,eAAe,EAAE;AACf,QAAA,SAAS,EAAE,eAAe;AAC3B,KAAA;AACD,IAAA,cAAc,EAAE;AACd,QAAA,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;AAClC,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,UAAU,EAAE,QAAQ;AACpB,QAAA,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3B,QAAA,OAAO,EAAE,MAAM;QACf,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC;AAClC,KAAA;AACD,IAAA,WAAW,EAAE;AACX,QAAA,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI;AAClC,KAAA;;AAED,IAAA,WAAW,EAAE;QACX,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;AAC9B,QAAA,QAAQ,EAAE,UAAU;AACpB,QAAA,UAAU,EAAE,GAAG;AACf,QAAA,QAAQ,EAAE,QAAQ;AAClB,QAAA,YAAY,EAAE,UAAU;AACxB,QAAA,UAAU,EAAE,QAAQ;AACrB,KAAA;AACF,CAAA,CAAC;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ExpandableModifierGroupProps {
|
|
3
|
+
/** The name of the modifier group, displayed as an uppercase header */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Content to render inside the expanded body */
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/** Whether the group starts expanded. Defaults to true */
|
|
8
|
+
defaultExpanded?: boolean;
|
|
9
|
+
/** Summary of currently selected options, shown below the header when collapsed */
|
|
10
|
+
selectedSummary?: string;
|
|
11
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const ItemTagGroup: (props: PropsWithChildren<HTMLAttributes<HTMLElement>>) =>
|
|
1
|
+
import { HTMLAttributes, PropsWithChildren } from 'react';
|
|
2
|
+
export declare const ItemTagGroup: (props: PropsWithChildren<HTMLAttributes<HTMLElement>>) => JSX.Element;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { MenuItemCardProps } from './MenuItemCardProps';
|
|
3
|
-
export declare const MenuItemCardImg: (props: Pick<MenuItemCardProps, "image">) =>
|
|
2
|
+
export declare const MenuItemCardImg: (props: Pick<MenuItemCardProps, "image">) => JSX.Element | null;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { MenuItemCardProps } from './MenuItemCardProps';
|
|
3
|
-
export declare const MenuItemCardPrice: (props: Pick<MenuItemCardProps, "price" | "available">) =>
|
|
2
|
+
export declare const MenuItemCardPrice: (props: Pick<MenuItemCardProps, "price" | "available">) => JSX.Element;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { MenuItemCardProps } from './MenuItemCardProps';
|
|
3
|
-
export declare const MenuItemCardReactions: (props: Pick<MenuItemCardProps, "likeCount" | "reviewCount">) =>
|
|
2
|
+
export declare const MenuItemCardReactions: (props: Pick<MenuItemCardProps, "likeCount" | "reviewCount">) => JSX.Element;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { MenuItemCardProps } from './MenuItemCardProps';
|
|
3
|
-
export declare const MenuItemCardTags: (props: Pick<MenuItemCardProps, "itemTags">) =>
|
|
2
|
+
export declare const MenuItemCardTags: (props: Pick<MenuItemCardProps, "itemTags">) => JSX.Element;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { ModifierGroupsType } from '../DishCheckoutCard/DishCheckoutCardProps';
|
|
3
2
|
export declare const MenuItemModifiersList: ({ modifierGroups, specialInstructions, }: {
|
|
4
3
|
modifierGroups: ModifierGroupsType[];
|
|
5
4
|
specialInstructions: string | null;
|
|
6
|
-
}) =>
|
|
5
|
+
}) => JSX.Element;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { ModifierGroupsType } from '../DishCheckoutCard/DishCheckoutCardProps';
|
|
3
|
-
export declare const ModifierGroup: (group: ModifierGroupsType, isNested: boolean) =>
|
|
2
|
+
export declare const ModifierGroup: (group: ModifierGroupsType, isNested: boolean) => JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const useDishModifierCardStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<string>;
|
|
2
|
+
export declare const useRadioModifierFormStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<string>;
|
|
3
|
+
export declare const useCheckboxModifierFormStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<string>;
|
|
4
|
+
export declare const useLabelStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<string>;
|
|
5
|
+
export declare const useOptionsStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<string>;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { makeStyles } from '@material-ui/core';
|
|
2
|
+
|
|
3
|
+
const useDishModifierCardStyles = makeStyles((theme) => ({
|
|
4
|
+
root: {
|
|
5
|
+
display: 'flex',
|
|
6
|
+
flexDirection: 'column',
|
|
7
|
+
padding: theme.spacing(2.5),
|
|
8
|
+
color: `${theme.palette.grey[900]} !important`,
|
|
9
|
+
},
|
|
10
|
+
card: {
|
|
11
|
+
borderRadius: '8px',
|
|
12
|
+
border: '1px solid var(--surfaces-card-stroke, #E0E0E0)',
|
|
13
|
+
},
|
|
14
|
+
error: {
|
|
15
|
+
color: theme.palette.error.main,
|
|
16
|
+
},
|
|
17
|
+
helperText: {
|
|
18
|
+
color: theme.palette.grey[700],
|
|
19
|
+
},
|
|
20
|
+
optionalStatusTag: {
|
|
21
|
+
'& > div': {
|
|
22
|
+
backgroundColor: theme.palette.grey[300],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
name: {
|
|
26
|
+
fontSize: '1.125rem',
|
|
27
|
+
fontWeight: theme.typography.fontWeightBold,
|
|
28
|
+
marginBottom: theme.spacing(2),
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
31
|
+
const useRadioModifierFormStyles = makeStyles((theme) => ({
|
|
32
|
+
radioGroup: {
|
|
33
|
+
gap: theme.spacing(2),
|
|
34
|
+
},
|
|
35
|
+
label: {
|
|
36
|
+
alignItems: 'center',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
justifyContent: 'space-between',
|
|
39
|
+
width: '100%',
|
|
40
|
+
},
|
|
41
|
+
radio: {
|
|
42
|
+
fontSize: '1rem',
|
|
43
|
+
padding: 'unset',
|
|
44
|
+
marginRight: theme.spacing(-0.25),
|
|
45
|
+
'&.Mui-checked': {
|
|
46
|
+
color: theme.palette.info.main,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
hideRadio: {
|
|
50
|
+
display: 'none',
|
|
51
|
+
},
|
|
52
|
+
root: {
|
|
53
|
+
justifyContent: 'space-between',
|
|
54
|
+
margin: 0,
|
|
55
|
+
width: '100%',
|
|
56
|
+
'& > :last-child': {
|
|
57
|
+
flex: 1,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
}));
|
|
61
|
+
const useCheckboxModifierFormStyles = makeStyles((theme) => ({
|
|
62
|
+
formGroup: {
|
|
63
|
+
gap: theme.spacing(2),
|
|
64
|
+
},
|
|
65
|
+
label: {
|
|
66
|
+
alignItems: 'center',
|
|
67
|
+
display: 'flex',
|
|
68
|
+
justifyContent: 'space-between',
|
|
69
|
+
width: '100%',
|
|
70
|
+
},
|
|
71
|
+
checkbox: {
|
|
72
|
+
color: theme.palette.grey[700],
|
|
73
|
+
fontSize: '1rem',
|
|
74
|
+
marginRight: theme.spacing(-0.25),
|
|
75
|
+
padding: 'unset',
|
|
76
|
+
'&.Mui-checked': {
|
|
77
|
+
color: theme.palette.info.main,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
hideCheckbox: {
|
|
81
|
+
display: 'none',
|
|
82
|
+
},
|
|
83
|
+
root: {
|
|
84
|
+
margin: 0,
|
|
85
|
+
width: '100%',
|
|
86
|
+
'& > :last-child': {
|
|
87
|
+
flex: 1,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
}));
|
|
91
|
+
const useLabelStyles = makeStyles((theme) => ({
|
|
92
|
+
label: {
|
|
93
|
+
margin: theme.spacing(0.5, 0),
|
|
94
|
+
},
|
|
95
|
+
selectedLabel: {
|
|
96
|
+
margin: theme.spacing(0.5, 0),
|
|
97
|
+
},
|
|
98
|
+
disabled: {
|
|
99
|
+
color: theme.palette.grey[500],
|
|
100
|
+
},
|
|
101
|
+
price: {
|
|
102
|
+
color: theme.palette.grey[700],
|
|
103
|
+
},
|
|
104
|
+
selectedSummary: {
|
|
105
|
+
color: theme.palette.grey[700],
|
|
106
|
+
},
|
|
107
|
+
selectedSummaryInlineRow: {
|
|
108
|
+
alignItems: 'center',
|
|
109
|
+
color: theme.palette.grey[700],
|
|
110
|
+
columnGap: theme.spacing(1),
|
|
111
|
+
display: 'flex',
|
|
112
|
+
justifyContent: 'space-between',
|
|
113
|
+
marginTop: theme.spacing(0.5),
|
|
114
|
+
minHeight: theme.spacing(2.5),
|
|
115
|
+
width: '100%',
|
|
116
|
+
},
|
|
117
|
+
selectedSummaryPrimary: {
|
|
118
|
+
alignItems: 'center',
|
|
119
|
+
columnGap: theme.spacing(1),
|
|
120
|
+
display: 'flex',
|
|
121
|
+
flex: 1,
|
|
122
|
+
minWidth: 0,
|
|
123
|
+
},
|
|
124
|
+
// TODO [sc-162475]: 0.625rem (10px) is below the recommended minimum font size for accessibility — address in followup
|
|
125
|
+
selectedSummaryPrimaryText: {
|
|
126
|
+
color: theme.palette.grey[700],
|
|
127
|
+
fontSize: '0.625rem',
|
|
128
|
+
fontWeight: theme.typography.fontWeightRegular,
|
|
129
|
+
lineHeight: 1.2,
|
|
130
|
+
overflow: 'hidden',
|
|
131
|
+
textOverflow: 'ellipsis',
|
|
132
|
+
whiteSpace: 'nowrap',
|
|
133
|
+
},
|
|
134
|
+
selectedSummaryIcon: {
|
|
135
|
+
color: theme.palette.success.main,
|
|
136
|
+
},
|
|
137
|
+
}));
|
|
138
|
+
const useOptionsStyles = makeStyles((theme) => ({
|
|
139
|
+
options: {
|
|
140
|
+
color: theme.palette.info.main,
|
|
141
|
+
marginBottom: theme.spacing(1.5),
|
|
142
|
+
minWidth: 'unset',
|
|
143
|
+
padding: 0,
|
|
144
|
+
},
|
|
145
|
+
inlineOptions: {
|
|
146
|
+
alignItems: 'center',
|
|
147
|
+
display: 'inline-flex',
|
|
148
|
+
justifyContent: 'center',
|
|
149
|
+
height: 'auto',
|
|
150
|
+
marginBottom: 0,
|
|
151
|
+
minHeight: 'unset',
|
|
152
|
+
paddingBottom: 0,
|
|
153
|
+
paddingLeft: '10px',
|
|
154
|
+
paddingRight: 0,
|
|
155
|
+
paddingTop: 0,
|
|
156
|
+
'& .MuiTypography-root': {
|
|
157
|
+
// TODO [sc-162475]: 0.625rem (10px) is below the recommended minimum font size for accessibility — address in followup
|
|
158
|
+
fontSize: '0.625rem',
|
|
159
|
+
lineHeight: 1.2,
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
}));
|
|
163
|
+
|
|
164
|
+
export { useCheckboxModifierFormStyles, useDishModifierCardStyles, useLabelStyles, useOptionsStyles, useRadioModifierFormStyles };
|
|
165
|
+
//# sourceMappingURL=DishModifierCard.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DishModifierCard.styles.js","sources":["../../../../src/components/NestedModsV2DishModifierCard/DishModifierCard.styles.ts"],"sourcesContent":["import { makeStyles, Theme } from '@material-ui/core'\n\nexport const useDishModifierCardStyles = makeStyles<Theme>((theme) => ({\n root: {\n display: 'flex',\n flexDirection: 'column',\n padding: theme.spacing(2.5),\n color: `${theme.palette.grey[900]} !important`,\n },\n card: {\n borderRadius: '8px',\n border: '1px solid var(--surfaces-card-stroke, #E0E0E0)',\n },\n error: {\n color: theme.palette.error.main,\n },\n helperText: {\n color: theme.palette.grey[700],\n },\n optionalStatusTag: {\n '& > div': {\n backgroundColor: theme.palette.grey[300],\n },\n },\n name: {\n fontSize: '1.125rem',\n fontWeight: theme.typography.fontWeightBold,\n marginBottom: theme.spacing(2),\n },\n}))\n\nexport const useRadioModifierFormStyles = makeStyles<Theme>((theme) => ({\n radioGroup: {\n gap: theme.spacing(2),\n },\n label: {\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'space-between',\n width: '100%',\n },\n radio: {\n fontSize: '1rem',\n padding: 'unset',\n marginRight: theme.spacing(-0.25),\n\n '&.Mui-checked': {\n color: theme.palette.info.main,\n },\n },\n hideRadio: {\n display: 'none',\n },\n root: {\n justifyContent: 'space-between',\n margin: 0,\n width: '100%',\n\n '& > :last-child': {\n flex: 1,\n },\n },\n}))\n\nexport const useCheckboxModifierFormStyles = makeStyles<Theme>((theme) => ({\n formGroup: {\n gap: theme.spacing(2),\n },\n label: {\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'space-between',\n width: '100%',\n },\n checkbox: {\n color: theme.palette.grey[700],\n fontSize: '1rem',\n marginRight: theme.spacing(-0.25),\n padding: 'unset',\n\n '&.Mui-checked': {\n color: theme.palette.info.main,\n },\n },\n hideCheckbox: {\n display: 'none',\n },\n root: {\n margin: 0,\n width: '100%',\n\n '& > :last-child': {\n flex: 1,\n },\n },\n}))\n\nexport const useLabelStyles = makeStyles<Theme>((theme) => ({\n label: {\n margin: theme.spacing(0.5, 0),\n },\n selectedLabel: {\n margin: theme.spacing(0.5, 0),\n },\n disabled: {\n color: theme.palette.grey[500],\n },\n price: {\n color: theme.palette.grey[700],\n },\n selectedSummary: {\n color: theme.palette.grey[700],\n },\n selectedSummaryInlineRow: {\n alignItems: 'center',\n color: theme.palette.grey[700],\n columnGap: theme.spacing(1),\n display: 'flex',\n justifyContent: 'space-between',\n marginTop: theme.spacing(0.5),\n minHeight: theme.spacing(2.5),\n width: '100%',\n },\n selectedSummaryPrimary: {\n alignItems: 'center',\n columnGap: theme.spacing(1),\n display: 'flex',\n flex: 1,\n minWidth: 0,\n },\n // TODO [sc-162475]: 0.625rem (10px) is below the recommended minimum font size for accessibility — address in followup\n selectedSummaryPrimaryText: {\n color: theme.palette.grey[700],\n fontSize: '0.625rem',\n fontWeight: theme.typography.fontWeightRegular,\n lineHeight: 1.2,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n },\n selectedSummaryIcon: {\n color: theme.palette.success.main,\n },\n}))\n\nexport const useOptionsStyles = makeStyles<Theme>((theme) => ({\n options: {\n color: theme.palette.info.main,\n marginBottom: theme.spacing(1.5),\n minWidth: 'unset',\n padding: 0,\n },\n inlineOptions: {\n alignItems: 'center',\n display: 'inline-flex',\n justifyContent: 'center',\n height: 'auto',\n marginBottom: 0,\n minHeight: 'unset',\n paddingBottom: 0,\n paddingLeft: '10px',\n paddingRight: 0,\n paddingTop: 0,\n '& .MuiTypography-root': {\n // TODO [sc-162475]: 0.625rem (10px) is below the recommended minimum font size for accessibility — address in followup\n fontSize: '0.625rem',\n lineHeight: 1.2,\n },\n },\n}))\n"],"names":[],"mappings":";;AAEa,MAAA,yBAAyB,GAAG,UAAU,CAAQ,CAAC,KAAK,MAAM;AACrE,IAAA,IAAI,EAAE;AACJ,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,aAAa,EAAE,QAAQ;AACvB,QAAA,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAC3B,KAAK,EAAE,CAAG,EAAA,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAa,WAAA,CAAA;AAC/C,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,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AA,UAAU,EAAE,GAAG;AACf,QAAA,QAAQ,EAAE,QAAQ;AAClB,QAAA,YAAY,EAAE,UAAU;AACxB,QAAA,UAAU,EAAE,QAAQ;AACrB,KAAA;AACD,IAAA,mBAAmB,EAAE;AACnB,QAAA,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI;AAClC,KAAA;AACF,CAAA,CAAC;AAEW,MAAA,gBAAgB,GAAG,UAAU,CAAQ,CAAC,KAAK,MAAM;AAC5D,IAAA,OAAO,EAAE;AACP,QAAA,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;AAC9B,QAAA,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;AAChC,QAAA,QAAQ,EAAE,OAAO;AACjB,QAAA,OAAO,EAAE,CAAC;AACX,KAAA;AACD,IAAA,aAAa,EAAE;AACb,QAAA,UAAU,EAAE,QAAQ;AACpB,QAAA,OAAO,EAAE,aAAa;AACtB,QAAA,cAAc,EAAE,QAAQ;AACxB,QAAA,MAAM,EAAE,MAAM;AACd,QAAA,YAAY,EAAE,CAAC;AACf,QAAA,SAAS,EAAE,OAAO;AAClB,QAAA,aAAa,EAAE,CAAC;AAChB,QAAA,WAAW,EAAE,MAAM;AACnB,QAAA,YAAY,EAAE,CAAC;AACf,QAAA,UAAU,EAAE,CAAC;AACb,QAAA,uBAAuB,EAAE;;AAEvB,YAAA,QAAQ,EAAE,UAAU;AACpB,YAAA,UAAU,EAAE,GAAG;AAChB,SAAA;AACF,KAAA;AACF,CAAA,CAAC;;;;"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export type ModifierValue = {
|
|
2
|
+
groupId: number;
|
|
3
|
+
modifierId: number;
|
|
4
|
+
parentModifierId?: number | null;
|
|
5
|
+
price: number;
|
|
6
|
+
quantity: number;
|
|
7
|
+
isRadio?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type Modifier = {
|
|
10
|
+
id: number;
|
|
11
|
+
hasModifiers: boolean;
|
|
12
|
+
name: string;
|
|
13
|
+
outOfStock: boolean;
|
|
14
|
+
price: number;
|
|
15
|
+
formattedPrice: string;
|
|
16
|
+
hidePrice?: boolean;
|
|
17
|
+
quantity: number;
|
|
18
|
+
parentModifierGroupId: number;
|
|
19
|
+
parentModifierGroupItemId?: number | null;
|
|
20
|
+
};
|
|
21
|
+
export type OnChangeValueType = ModifierValue;
|
|
22
|
+
export type ModifierControlsOptions = {
|
|
23
|
+
/** Applies selected modifier visual treatment used by nested mods V2 */
|
|
24
|
+
enableSelectedModifierStyles?: boolean;
|
|
25
|
+
/** Changes the action label to UPDATE when a modifier is selected */
|
|
26
|
+
showUpdateButton?: boolean;
|
|
27
|
+
/** Optional selected modifier summary text shown below selected modifier names */
|
|
28
|
+
selectedNestedSummaryByModifierId?: Record<number, string>;
|
|
29
|
+
/**
|
|
30
|
+
* Suppresses the inline OPTIONS / UPDATE action on every modifier row,
|
|
31
|
+
* regardless of selection state, AND prevents the built-in auto-trigger
|
|
32
|
+
* of `handleOptionsClick` when a modifier with `hasModifiers: true` is
|
|
33
|
+
* selected.
|
|
34
|
+
*/
|
|
35
|
+
hideNestedOptionsButton?: boolean;
|
|
36
|
+
};
|
|
37
|
+
export type NestedModsV2DishModifierCardProps = {
|
|
38
|
+
/** Aggregate price of the modifier and its nested children modifiers */
|
|
39
|
+
aggregatePrice: Record<number, string>;
|
|
40
|
+
/** Modifier options */
|
|
41
|
+
modifiers: Array<Modifier>;
|
|
42
|
+
/** The values of the modifier form */
|
|
43
|
+
value: Array<ModifierValue>;
|
|
44
|
+
/** Handles the change event */
|
|
45
|
+
onChange: (value: OnChangeValueType) => void;
|
|
46
|
+
/** Name of the modifier */
|
|
47
|
+
name: string;
|
|
48
|
+
/** Denotes the max amount of selections have been reached */
|
|
49
|
+
disableNewSelections?: boolean;
|
|
50
|
+
/** Denotes if modifier has an error */
|
|
51
|
+
error: boolean;
|
|
52
|
+
/** Denotes if modifier is required */
|
|
53
|
+
isRequired: boolean;
|
|
54
|
+
/** Denotes if modifier is out of stock */
|
|
55
|
+
isOutOfStock: boolean;
|
|
56
|
+
/** Selection type for modifier group */
|
|
57
|
+
type: 'singleSelect' | 'multipleSelect' | 'multipleQuantitySelect';
|
|
58
|
+
/** Renders the text of the dish modifiers */
|
|
59
|
+
messages: {
|
|
60
|
+
optionalText: string;
|
|
61
|
+
outOfStockText: string;
|
|
62
|
+
requiredText: string;
|
|
63
|
+
helperText: string;
|
|
64
|
+
};
|
|
65
|
+
/** Handles the dialog change for nested modifiers */
|
|
66
|
+
handleOptionsClick: (id: number) => void;
|
|
67
|
+
/** Used by parent modifier quantity tracking: parent modifier quantity denotes requiredSelectionCount and currentSelectionCount is the total quantity of the child modifier */
|
|
68
|
+
selectionQuantity: Record<number, {
|
|
69
|
+
requiredSelectionCount: number;
|
|
70
|
+
currentSelectionCount: number;
|
|
71
|
+
}>;
|
|
72
|
+
/** Optional feature-gated options for nested modifier controls */
|
|
73
|
+
modifierControlsOptions?: ModifierControlsOptions;
|
|
74
|
+
/** Removes the card border and border-radius, for use inside a container that provides its own card styling */
|
|
75
|
+
disableCardStyle?: boolean;
|
|
76
|
+
/** Hides the group name heading, useful when the name is already shown by a parent container */
|
|
77
|
+
hideName?: boolean;
|
|
78
|
+
};
|
|
79
|
+
export type ModifierOptionsControlProps = Pick<NestedModsV2DishModifierCardProps, 'value' | 'modifiers' | 'isOutOfStock' | 'isRequired' | 'onChange' | 'disableNewSelections' | 'type' | 'messages' | 'handleOptionsClick' | 'aggregatePrice' | 'selectionQuantity' | 'name' | 'modifierControlsOptions'>;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { FormControl, FormGroup, Box, Typography, FormControlLabel, Checkbox, RadioGroup, Radio } from '@material-ui/core';
|
|
2
|
+
import { Icon } from '@popmenu/common-ui';
|
|
3
|
+
import { CheckCircle, ChevronRight } from '@popmenu/web-icons';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import React__default from 'react';
|
|
6
|
+
import { Button } from '../Button/Button.js';
|
|
7
|
+
import { QuantityPicker } from '../QuantityPicker/QuantityPicker.js';
|
|
8
|
+
import { StatusTag } from '../StatusTag/StatusTag.js';
|
|
9
|
+
import { useCheckboxModifierFormStyles, useRadioModifierFormStyles, useLabelStyles, useOptionsStyles } from './DishModifierCard.styles.js';
|
|
10
|
+
|
|
11
|
+
const Label = (props) => {
|
|
12
|
+
const { name, price, disabled = false, hidePrice = false, isSelected = false, selectedSummary, enableSelectedModifierStyles = false, } = props;
|
|
13
|
+
const classes = useLabelStyles();
|
|
14
|
+
const numericPrice = price ? parseFloat(price.replace(/[^0-9.-]/g, '')) : NaN;
|
|
15
|
+
const shouldHidePrice = hidePrice || !price || numericPrice === 0 || isNaN(numericPrice);
|
|
16
|
+
const showSelectedSummary = Boolean(enableSelectedModifierStyles && isSelected && selectedSummary);
|
|
17
|
+
return (React__default.createElement(Box, { display: "flex", flexDirection: "column", className: classNames({ [classes.label]: !showSelectedSummary, [classes.selectedLabel]: showSelectedSummary }) },
|
|
18
|
+
React__default.createElement(Box, { display: "flex", alignItems: "center", gridGap: 8 },
|
|
19
|
+
React__default.createElement(Typography, { className: classNames({
|
|
20
|
+
[classes.disabled]: disabled,
|
|
21
|
+
}) }, name)),
|
|
22
|
+
!shouldHidePrice && (React__default.createElement(Typography, { className: classNames({ [classes.price]: !disabled }, { [classes.disabled]: disabled }) }, `+ ${price}`)),
|
|
23
|
+
showSelectedSummary && React__default.createElement(Typography, { className: classes.selectedSummary }, selectedSummary)));
|
|
24
|
+
};
|
|
25
|
+
const Options = (props) => {
|
|
26
|
+
const { handleOptionsClick, actionLabel, hidden = false, inline = false } = props;
|
|
27
|
+
const classes = useOptionsStyles();
|
|
28
|
+
const displayActionLabel = inline ? (actionLabel === 'UPDATE' ? 'Update' : 'Options') : actionLabel;
|
|
29
|
+
if (hidden)
|
|
30
|
+
return null;
|
|
31
|
+
return (React__default.createElement(Box, null,
|
|
32
|
+
React__default.createElement(Button, { variation: "none", className: classNames(classes.options, { [classes.inlineOptions]: inline }), onClick: handleOptionsClick },
|
|
33
|
+
React__default.createElement(Typography, { variant: "caption" }, displayActionLabel),
|
|
34
|
+
!inline && React__default.createElement(Icon, { icon: ChevronRight }))));
|
|
35
|
+
};
|
|
36
|
+
const getIsSelected = (modifierId, value) => value.some((modifierValue) => modifierValue.modifierId === modifierId && modifierValue.quantity > 0);
|
|
37
|
+
const getActionLabel = (isSelected, props) => props.modifierControlsOptions?.showUpdateButton && isSelected ? 'UPDATE' : 'OPTIONS';
|
|
38
|
+
const shouldHideNestedOptionsButton = (isSelected, props) => Boolean(props.modifierControlsOptions?.hideNestedOptionsButton ||
|
|
39
|
+
(props.modifierControlsOptions?.enableSelectedModifierStyles && !isSelected));
|
|
40
|
+
const shouldShowInlineAction = (isSelected, props) => Boolean(isSelected &&
|
|
41
|
+
props.modifierControlsOptions?.enableSelectedModifierStyles &&
|
|
42
|
+
!props.modifierControlsOptions?.hideNestedOptionsButton);
|
|
43
|
+
const getModifierActionState = (modifier, isSelected, props) => ({
|
|
44
|
+
isSelected,
|
|
45
|
+
shouldHideNestedOptions: shouldHideNestedOptionsButton(isSelected, props),
|
|
46
|
+
showInlineAction: shouldShowInlineAction(isSelected, props),
|
|
47
|
+
actionLabel: getActionLabel(isSelected, props),
|
|
48
|
+
selectedSummary: props.modifierControlsOptions?.selectedNestedSummaryByModifierId?.[modifier.id],
|
|
49
|
+
});
|
|
50
|
+
const NestedModifierActions = (props) => {
|
|
51
|
+
const { modifier, handleOptionsClick, state, renderRegularButton = true } = props;
|
|
52
|
+
const labelClasses = useLabelStyles();
|
|
53
|
+
if (!modifier.hasModifiers || modifier.outOfStock)
|
|
54
|
+
return null;
|
|
55
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
56
|
+
state.showInlineAction && state.selectedSummary && (React__default.createElement(Box, { className: labelClasses.selectedSummaryInlineRow },
|
|
57
|
+
React__default.createElement(Box, { className: labelClasses.selectedSummaryPrimary },
|
|
58
|
+
React__default.createElement(Icon, { icon: CheckCircle, size: "medium", className: labelClasses.selectedSummaryIcon }),
|
|
59
|
+
React__default.createElement(Typography, { variant: "caption", className: labelClasses.selectedSummaryPrimaryText }, state.selectedSummary)),
|
|
60
|
+
React__default.createElement(Options, { handleOptionsClick: () => handleOptionsClick(modifier.id), actionLabel: state.actionLabel, inline: true, hidden: state.shouldHideNestedOptions }))),
|
|
61
|
+
renderRegularButton && (React__default.createElement(Options, { handleOptionsClick: () => handleOptionsClick(modifier.id), actionLabel: state.actionLabel, hidden: state.shouldHideNestedOptions || (state.showInlineAction && Boolean(state.selectedSummary)) }))));
|
|
62
|
+
};
|
|
63
|
+
const SingleSelectModifierControl = (props) => {
|
|
64
|
+
const { modifiers, name, isOutOfStock, onChange, value, handleOptionsClick, aggregatePrice, isRequired } = props;
|
|
65
|
+
const radioClasses = useRadioModifierFormStyles();
|
|
66
|
+
const makeHandleChange = (modifier) => (e) => {
|
|
67
|
+
const isModifierInValue = Boolean(value.find((v) => v.modifierId === modifier.id));
|
|
68
|
+
if (!isModifierInValue && modifier.hasModifiers && !props.modifierControlsOptions?.hideNestedOptionsButton) {
|
|
69
|
+
handleOptionsClick(modifier.id);
|
|
70
|
+
}
|
|
71
|
+
onChange({
|
|
72
|
+
isRadio: true,
|
|
73
|
+
modifierId: Number(e.target.value),
|
|
74
|
+
groupId: modifier.parentModifierGroupId,
|
|
75
|
+
parentModifierId: modifier.parentModifierGroupItemId,
|
|
76
|
+
price: modifier.price || 0,
|
|
77
|
+
quantity: 1,
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
return (React__default.createElement(FormControl, { fullWidth: true },
|
|
81
|
+
React__default.createElement(RadioGroup, { className: radioClasses.radioGroup, "aria-label": name }, modifiers.map((modifier) => {
|
|
82
|
+
const modifierActionState = getModifierActionState(modifier, getIsSelected(modifier.id, value), props);
|
|
83
|
+
return (React__default.createElement(Box, { key: modifier.id },
|
|
84
|
+
React__default.createElement(FormControlLabel, { key: modifier.id, value: modifier.id, className: radioClasses.root, control: React__default.createElement(Radio, { checked: value[0]?.modifierId === modifier.id, className: classNames({
|
|
85
|
+
[radioClasses.hideRadio]: modifier.outOfStock,
|
|
86
|
+
[radioClasses.radio]: !modifier.outOfStock,
|
|
87
|
+
}), disabled: isOutOfStock || modifier.outOfStock, onChange: makeHandleChange(modifier), required: isRequired }), label: React__default.createElement(Box, { className: radioClasses.label },
|
|
88
|
+
React__default.createElement(Label, { name: modifier.name, price: aggregatePrice[modifier.id] || modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock, hidePrice: modifier.hidePrice, isSelected: modifierActionState.isSelected, enableSelectedModifierStyles: props.modifierControlsOptions?.enableSelectedModifierStyles, selectedSummary: modifierActionState.showInlineAction ? undefined : modifierActionState.selectedSummary }),
|
|
89
|
+
modifier.outOfStock && (React__default.createElement(Box, { minWidth: "90px", marginLeft: 2 },
|
|
90
|
+
React__default.createElement(StatusTag, { color: "warning", label: "Out of stock", variant: "outlined", size: "md" })))), labelPlacement: "start" }),
|
|
91
|
+
React__default.createElement(NestedModifierActions, { modifier: modifier, handleOptionsClick: handleOptionsClick, state: modifierActionState })));
|
|
92
|
+
}))));
|
|
93
|
+
};
|
|
94
|
+
const MultipleSelectControl = (props) => {
|
|
95
|
+
const { modifiers, value, isOutOfStock, onChange, disableNewSelections, handleOptionsClick, aggregatePrice } = props;
|
|
96
|
+
const classes = useCheckboxModifierFormStyles();
|
|
97
|
+
const makeHandleChange = (modifier) => () => {
|
|
98
|
+
const isModifierInValue = Boolean(value.find((v) => v.modifierId === modifier.id));
|
|
99
|
+
if (!isModifierInValue && modifier.hasModifiers && !props.modifierControlsOptions?.hideNestedOptionsButton) {
|
|
100
|
+
handleOptionsClick(modifier.id);
|
|
101
|
+
}
|
|
102
|
+
onChange({
|
|
103
|
+
isRadio: false,
|
|
104
|
+
modifierId: modifier.id,
|
|
105
|
+
groupId: modifier.parentModifierGroupId,
|
|
106
|
+
parentModifierId: modifier.parentModifierGroupItemId,
|
|
107
|
+
price: modifier.price || 0,
|
|
108
|
+
quantity: isModifierInValue ? 0 : 1,
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
return (React__default.createElement(FormControl, { fullWidth: true },
|
|
112
|
+
React__default.createElement(FormGroup, { className: classes.formGroup }, modifiers.map((modifier) => {
|
|
113
|
+
const modifierActionState = getModifierActionState(modifier, getIsSelected(modifier.id, value), props);
|
|
114
|
+
return (React__default.createElement(Box, { key: modifier.id },
|
|
115
|
+
React__default.createElement(FormControlLabel, { key: modifier.id, value: modifier.id, className: classes.root, checked: value.some((v) => v.modifierId === modifier.id), onChange: makeHandleChange(modifier), control: React__default.createElement(Checkbox, { className: classNames({ [classes.hideCheckbox]: modifier.outOfStock }, { [classes.checkbox]: !modifier.outOfStock }), disabled: isOutOfStock || modifier.outOfStock || (!modifier.quantity && disableNewSelections) }), label: React__default.createElement(Box, { className: classes.label },
|
|
116
|
+
React__default.createElement(Label, { name: modifier.name, price: aggregatePrice[modifier.id] || modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock, hidePrice: modifier.hidePrice, isSelected: modifierActionState.isSelected, enableSelectedModifierStyles: props.modifierControlsOptions?.enableSelectedModifierStyles, selectedSummary: modifierActionState.showInlineAction ? undefined : modifierActionState.selectedSummary }),
|
|
117
|
+
modifier.outOfStock && (React__default.createElement(Box, { minWidth: "90px", marginLeft: 2 },
|
|
118
|
+
React__default.createElement(StatusTag, { color: "warning", label: "Out of stock", variant: "outlined", size: "md" })))), labelPlacement: "start" }),
|
|
119
|
+
React__default.createElement(NestedModifierActions, { modifier: modifier, handleOptionsClick: handleOptionsClick, state: modifierActionState })));
|
|
120
|
+
}))));
|
|
121
|
+
};
|
|
122
|
+
const MultipleQuantitySelectControl = (props) => {
|
|
123
|
+
const { modifiers, isOutOfStock, onChange, disableNewSelections, handleOptionsClick, selectionQuantity, aggregatePrice, } = props;
|
|
124
|
+
const makeHandleChange = (modifier) => (_e, customEvent) => {
|
|
125
|
+
onChange({
|
|
126
|
+
isRadio: false,
|
|
127
|
+
modifierId: modifier.id,
|
|
128
|
+
groupId: modifier.parentModifierGroupId,
|
|
129
|
+
parentModifierId: modifier.parentModifierGroupItemId,
|
|
130
|
+
price: modifier.price || 0,
|
|
131
|
+
quantity: customEvent.quantity,
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
return (React__default.createElement(FormControl, { fullWidth: true },
|
|
135
|
+
React__default.createElement(FormGroup, null, modifiers.map((modifier) => {
|
|
136
|
+
const modifierActionState = getModifierActionState(modifier, modifier.quantity > 0, props);
|
|
137
|
+
return (React__default.createElement(Box, { key: modifier.id, style: { justifyContent: 'space-between', flexDirection: 'column' }, display: "flex" },
|
|
138
|
+
React__default.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%" },
|
|
139
|
+
React__default.createElement(Label, { name: modifier.name, price: aggregatePrice[modifier.id] || modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock, hidePrice: modifier.hidePrice, isSelected: modifierActionState.isSelected, enableSelectedModifierStyles: props.modifierControlsOptions?.enableSelectedModifierStyles, selectedSummary: modifierActionState.showInlineAction ? undefined : modifierActionState.selectedSummary }),
|
|
140
|
+
modifier.outOfStock && (React__default.createElement(Box, { minWidth: "90px", marginLeft: 2 },
|
|
141
|
+
React__default.createElement(StatusTag, { color: "warning", label: "Out of stock", variant: "outlined", size: "md" }))),
|
|
142
|
+
!modifier.outOfStock && (React__default.createElement(QuantityPicker, { incrementButtonTitle: `Add ${modifier.name}`, decrementButtonTitle: `Remove ${modifier.name}`, id: `${modifier.id}-quantity-picker`, variation: "modifierCount", value: modifier.quantity, disableIncrement: disableNewSelections, preventManualChange: true, onChange: makeHandleChange(modifier), disabled: isOutOfStock || modifier.outOfStock, name: modifier.name }))),
|
|
143
|
+
React__default.createElement(NestedModifierActions, { modifier: modifier, handleOptionsClick: handleOptionsClick, state: modifierActionState, renderRegularButton: false }),
|
|
144
|
+
React__default.createElement(Box, { display: "flex", alignItems: "flex-start", gridGap: 4 },
|
|
145
|
+
modifier.hasModifiers && !modifier.outOfStock && (React__default.createElement(Options, { handleOptionsClick: () => handleOptionsClick(modifier.id), actionLabel: modifierActionState.actionLabel, hidden: modifierActionState.shouldHideNestedOptions ||
|
|
146
|
+
(modifierActionState.showInlineAction && Boolean(modifierActionState.selectedSummary)) })),
|
|
147
|
+
selectionQuantity[modifier.id] &&
|
|
148
|
+
selectionQuantity[modifier.id].requiredSelectionCount > 0 &&
|
|
149
|
+
selectionQuantity[modifier.id].requiredSelectionCount !==
|
|
150
|
+
selectionQuantity[modifier.id].currentSelectionCount && (React__default.createElement(Typography, { variant: "caption", color: "error" },
|
|
151
|
+
selectionQuantity[modifier.id].currentSelectionCount,
|
|
152
|
+
"/",
|
|
153
|
+
selectionQuantity[modifier.id].requiredSelectionCount,
|
|
154
|
+
" selected")))));
|
|
155
|
+
}))));
|
|
156
|
+
};
|
|
157
|
+
const ModifierControls = (props) => {
|
|
158
|
+
switch (props.type) {
|
|
159
|
+
case 'singleSelect':
|
|
160
|
+
return React__default.createElement(SingleSelectModifierControl, { ...props });
|
|
161
|
+
case 'multipleSelect':
|
|
162
|
+
return React__default.createElement(MultipleSelectControl, { ...props });
|
|
163
|
+
case 'multipleQuantitySelect':
|
|
164
|
+
return React__default.createElement(MultipleQuantitySelectControl, { ...props });
|
|
165
|
+
default:
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export { ModifierControls };
|
|
171
|
+
//# sourceMappingURL=ModifierControls.js.map
|