@popmenu/ordering-ui 0.152.0 → 0.154.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/ExpandableModifierGroup/ExpandableModifierGroup.d.ts +6 -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/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 +3 -0
- package/build/cjs/components/NestedModsV2DishModifierCard/NestedModsV2DishModifierCard.d.ts +6 -0
- package/build/cjs/components/NestedModsV2DishModifierCard/index.d.ts +2 -0
- 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/ExpandableModifierGroup/ExpandableModifierGroup.d.ts +6 -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/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 +3 -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 +6 -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/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
package/build/cjs/index.js
CHANGED
|
@@ -687,7 +687,7 @@ const DishDetailsReview = React.forwardRef((props, ref) => {
|
|
|
687
687
|
});
|
|
688
688
|
DishDetailsReview.displayName = 'DishDetailsReview';
|
|
689
689
|
|
|
690
|
-
const useDishModifierCardStyles = core.makeStyles((theme) => ({
|
|
690
|
+
const useDishModifierCardStyles$1 = core.makeStyles((theme) => ({
|
|
691
691
|
root: {
|
|
692
692
|
borderRadius: '8px',
|
|
693
693
|
border: '1px solid var(--surfaces-card-stroke, #E0E0E0)',
|
|
@@ -707,7 +707,7 @@ const useDishModifierCardStyles = core.makeStyles((theme) => ({
|
|
|
707
707
|
marginBottom: theme.spacing(2),
|
|
708
708
|
},
|
|
709
709
|
}));
|
|
710
|
-
const useRadioModifierFormStyles = core.makeStyles((theme) => ({
|
|
710
|
+
const useRadioModifierFormStyles$1 = core.makeStyles((theme) => ({
|
|
711
711
|
radioGroup: {
|
|
712
712
|
gap: theme.spacing(1),
|
|
713
713
|
},
|
|
@@ -736,7 +736,7 @@ const useRadioModifierFormStyles = core.makeStyles((theme) => ({
|
|
|
736
736
|
},
|
|
737
737
|
},
|
|
738
738
|
}));
|
|
739
|
-
const useCheckboxModifierFormStyles = core.makeStyles((theme) => ({
|
|
739
|
+
const useCheckboxModifierFormStyles$1 = core.makeStyles((theme) => ({
|
|
740
740
|
formGroup: {
|
|
741
741
|
gap: theme.spacing(1),
|
|
742
742
|
},
|
|
@@ -765,7 +765,7 @@ const useCheckboxModifierFormStyles = core.makeStyles((theme) => ({
|
|
|
765
765
|
},
|
|
766
766
|
},
|
|
767
767
|
}));
|
|
768
|
-
const useLabelStyles = core.makeStyles((theme) => ({
|
|
768
|
+
const useLabelStyles$1 = core.makeStyles((theme) => ({
|
|
769
769
|
label: {
|
|
770
770
|
margin: theme.spacing(0.5, 0),
|
|
771
771
|
},
|
|
@@ -776,7 +776,7 @@ const useLabelStyles = core.makeStyles((theme) => ({
|
|
|
776
776
|
color: theme.palette.grey[700],
|
|
777
777
|
},
|
|
778
778
|
}));
|
|
779
|
-
const useOptionsStyles = core.makeStyles((theme) => ({
|
|
779
|
+
const useOptionsStyles$1 = core.makeStyles((theme) => ({
|
|
780
780
|
options: {
|
|
781
781
|
color: theme.palette.info.main,
|
|
782
782
|
marginBottom: theme.spacing(1.5),
|
|
@@ -960,9 +960,9 @@ const QuantityPicker = ({ id, value, onChange, disabled, preventManualChange, di
|
|
|
960
960
|
} }, liveRegionMessage)));
|
|
961
961
|
};
|
|
962
962
|
|
|
963
|
-
const Label = (props) => {
|
|
963
|
+
const Label$1 = (props) => {
|
|
964
964
|
const { name, price, disabled = false, hidePrice = false } = props;
|
|
965
|
-
const classes = useLabelStyles();
|
|
965
|
+
const classes = useLabelStyles$1();
|
|
966
966
|
const numericPrice = price ? parseFloat(price.replace(/[^0-9.-]/g, '')) : NaN;
|
|
967
967
|
const shouldHidePrice = hidePrice || !price || numericPrice === 0 || isNaN(numericPrice);
|
|
968
968
|
return (React.createElement(core.Box, { display: "flex", flexDirection: "column", className: classes.label },
|
|
@@ -970,17 +970,17 @@ const Label = (props) => {
|
|
|
970
970
|
React.createElement(core.Typography, { className: classNames({ [classes.disabled]: disabled }) }, name)),
|
|
971
971
|
!shouldHidePrice && (React.createElement(core.Typography, { className: classNames({ [classes.price]: !disabled }, { [classes.disabled]: disabled }) }, `+ ${price}`))));
|
|
972
972
|
};
|
|
973
|
-
const Options = (props) => {
|
|
973
|
+
const Options$1 = (props) => {
|
|
974
974
|
const { handleOptionsClick } = props;
|
|
975
|
-
const classes = useOptionsStyles();
|
|
975
|
+
const classes = useOptionsStyles$1();
|
|
976
976
|
return (React.createElement(core.Box, null,
|
|
977
977
|
React.createElement(Button, { variation: "none", className: classes.options, onClick: handleOptionsClick },
|
|
978
978
|
React.createElement(core.Typography, { variant: "caption" }, "OPTIONS"),
|
|
979
979
|
React.createElement(commonUi.Icon, { icon: webIcons.ChevronRight }))));
|
|
980
980
|
};
|
|
981
|
-
const SingleSelectModifierControl = (props) => {
|
|
981
|
+
const SingleSelectModifierControl$1 = (props) => {
|
|
982
982
|
const { modifiers, name, isOutOfStock, onChange, value, handleOptionsClick, aggregatePrice, isRequired } = props;
|
|
983
|
-
const radioClasses = useRadioModifierFormStyles();
|
|
983
|
+
const radioClasses = useRadioModifierFormStyles$1();
|
|
984
984
|
const makeHandleChange = (modifier) => (e) => {
|
|
985
985
|
const isModifierInValue = Boolean(value.find((v) => v.modifierId === modifier.id));
|
|
986
986
|
if (!isModifierInValue && modifier.hasModifiers) {
|
|
@@ -1001,14 +1001,14 @@ const SingleSelectModifierControl = (props) => {
|
|
|
1001
1001
|
[radioClasses.hideRadio]: modifier.outOfStock,
|
|
1002
1002
|
[radioClasses.radio]: !modifier.outOfStock,
|
|
1003
1003
|
}), disabled: isOutOfStock || modifier.outOfStock, onChange: makeHandleChange(modifier), required: isRequired }), label: React.createElement(core.Box, { className: radioClasses.label },
|
|
1004
|
-
React.createElement(Label, { name: modifier.name, price: aggregatePrice[modifier.id] || modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock, hidePrice: modifier.hidePrice }),
|
|
1004
|
+
React.createElement(Label$1, { name: modifier.name, price: aggregatePrice[modifier.id] || modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock, hidePrice: modifier.hidePrice }),
|
|
1005
1005
|
modifier.outOfStock && (React.createElement(core.Box, { minWidth: "90px", marginLeft: 2 },
|
|
1006
1006
|
React.createElement(StatusTag, { color: "warning", label: "Out of stock", variant: "outlined", size: "md" })))), labelPlacement: "start" }),
|
|
1007
|
-
modifier.hasModifiers && !modifier.outOfStock && (React.createElement(Options, { handleOptionsClick: () => handleOptionsClick(modifier.id) }))))))));
|
|
1007
|
+
modifier.hasModifiers && !modifier.outOfStock && (React.createElement(Options$1, { handleOptionsClick: () => handleOptionsClick(modifier.id) }))))))));
|
|
1008
1008
|
};
|
|
1009
|
-
const MultipleSelectControl = (props) => {
|
|
1009
|
+
const MultipleSelectControl$1 = (props) => {
|
|
1010
1010
|
const { modifiers, value, isOutOfStock, onChange, disableNewSelections, handleOptionsClick, aggregatePrice } = props;
|
|
1011
|
-
const classes = useCheckboxModifierFormStyles();
|
|
1011
|
+
const classes = useCheckboxModifierFormStyles$1();
|
|
1012
1012
|
const makeHandleChange = (modifier) => () => {
|
|
1013
1013
|
const isModifierInValue = Boolean(value.find((v) => v.modifierId === modifier.id));
|
|
1014
1014
|
if (!isModifierInValue && modifier.hasModifiers) {
|
|
@@ -1027,13 +1027,13 @@ const MultipleSelectControl = (props) => {
|
|
|
1027
1027
|
React.createElement(core.FormGroup, { className: classes.formGroup }, modifiers.map((modifier) => {
|
|
1028
1028
|
return (React.createElement(core.Box, { key: modifier.id },
|
|
1029
1029
|
React.createElement(core.FormControlLabel, { key: modifier.id, value: modifier.id, className: classes.root, checked: value.some((v) => v.modifierId === modifier.id), onChange: makeHandleChange(modifier), control: React.createElement(core.Checkbox, { className: classNames({ [classes.hideCheckbox]: modifier.outOfStock }, { [classes.checkbox]: !modifier.outOfStock }), disabled: isOutOfStock || modifier.outOfStock || (!modifier.quantity && disableNewSelections) }), label: React.createElement(core.Box, { className: classes.label },
|
|
1030
|
-
React.createElement(Label, { name: modifier.name, price: aggregatePrice[modifier.id] || modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock, hidePrice: modifier.hidePrice }),
|
|
1030
|
+
React.createElement(Label$1, { name: modifier.name, price: aggregatePrice[modifier.id] || modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock, hidePrice: modifier.hidePrice }),
|
|
1031
1031
|
modifier.outOfStock && (React.createElement(core.Box, { minWidth: "90px", marginLeft: 2 },
|
|
1032
1032
|
React.createElement(StatusTag, { color: "warning", label: "Out of stock", variant: "outlined", size: "md" })))), labelPlacement: "start" }),
|
|
1033
|
-
modifier.hasModifiers && !modifier.outOfStock && (React.createElement(Options, { handleOptionsClick: () => handleOptionsClick(modifier.id) }))));
|
|
1033
|
+
modifier.hasModifiers && !modifier.outOfStock && (React.createElement(Options$1, { handleOptionsClick: () => handleOptionsClick(modifier.id) }))));
|
|
1034
1034
|
}))));
|
|
1035
1035
|
};
|
|
1036
|
-
const MultipleQuantitySelectControl = (props) => {
|
|
1036
|
+
const MultipleQuantitySelectControl$1 = (props) => {
|
|
1037
1037
|
const { modifiers, isOutOfStock, onChange, disableNewSelections, handleOptionsClick, selectionQuantity } = props;
|
|
1038
1038
|
const makeHandleChange = (modifier) => (_e, customEvent) => {
|
|
1039
1039
|
onChange({
|
|
@@ -1048,12 +1048,12 @@ const MultipleQuantitySelectControl = (props) => {
|
|
|
1048
1048
|
return (React.createElement(core.FormControl, { fullWidth: true },
|
|
1049
1049
|
React.createElement(core.FormGroup, null, modifiers.map((modifier) => (React.createElement(core.Box, { key: modifier.id, style: { justifyContent: 'space-between', flexDirection: 'column' }, display: "flex" },
|
|
1050
1050
|
React.createElement(core.Box, { display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%" },
|
|
1051
|
-
React.createElement(Label, { name: modifier.name, price: modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock, hidePrice: modifier.hidePrice }),
|
|
1051
|
+
React.createElement(Label$1, { name: modifier.name, price: modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock, hidePrice: modifier.hidePrice }),
|
|
1052
1052
|
modifier.outOfStock && (React.createElement(core.Box, { minWidth: "90px", marginLeft: 2 },
|
|
1053
1053
|
React.createElement(StatusTag, { color: "warning", label: "Out of stock", variant: "outlined", size: "md" }))),
|
|
1054
1054
|
!modifier.outOfStock && (React.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 }))),
|
|
1055
1055
|
React.createElement(core.Box, { display: "flex", alignItems: "flex-start", gridGap: 4 },
|
|
1056
|
-
modifier.hasModifiers && !modifier.outOfStock && (React.createElement(Options, { handleOptionsClick: () => handleOptionsClick(modifier.id) })),
|
|
1056
|
+
modifier.hasModifiers && !modifier.outOfStock && (React.createElement(Options$1, { handleOptionsClick: () => handleOptionsClick(modifier.id) })),
|
|
1057
1057
|
selectionQuantity[modifier.id] &&
|
|
1058
1058
|
selectionQuantity[modifier.id].requiredSelectionCount > 0 &&
|
|
1059
1059
|
selectionQuantity[modifier.id].requiredSelectionCount !==
|
|
@@ -1063,20 +1063,20 @@ const MultipleQuantitySelectControl = (props) => {
|
|
|
1063
1063
|
selectionQuantity[modifier.id].requiredSelectionCount,
|
|
1064
1064
|
" selected")))))))));
|
|
1065
1065
|
};
|
|
1066
|
-
const ModifierControls = (props) => {
|
|
1066
|
+
const ModifierControls$1 = (props) => {
|
|
1067
1067
|
switch (props.type) {
|
|
1068
1068
|
case 'singleSelect':
|
|
1069
|
-
return React.createElement(SingleSelectModifierControl, { ...props });
|
|
1069
|
+
return React.createElement(SingleSelectModifierControl$1, { ...props });
|
|
1070
1070
|
case 'multipleSelect':
|
|
1071
|
-
return React.createElement(MultipleSelectControl, { ...props });
|
|
1071
|
+
return React.createElement(MultipleSelectControl$1, { ...props });
|
|
1072
1072
|
case 'multipleQuantitySelect':
|
|
1073
|
-
return React.createElement(MultipleQuantitySelectControl, { ...props });
|
|
1073
|
+
return React.createElement(MultipleQuantitySelectControl$1, { ...props });
|
|
1074
1074
|
default:
|
|
1075
1075
|
return null;
|
|
1076
1076
|
}
|
|
1077
1077
|
};
|
|
1078
1078
|
|
|
1079
|
-
const getStatusTagProps = (props) => {
|
|
1079
|
+
const getStatusTagProps$1 = (props) => {
|
|
1080
1080
|
const { messages, error, isRequired, isOutOfStock } = props;
|
|
1081
1081
|
const { optionalText, outOfStockText, requiredText } = messages;
|
|
1082
1082
|
let color = 'default';
|
|
@@ -1102,14 +1102,14 @@ const getStatusTagProps = (props) => {
|
|
|
1102
1102
|
};
|
|
1103
1103
|
const DishModifierCard = (props) => {
|
|
1104
1104
|
const { aggregatePrice, name, disableNewSelections, modifiers, value, messages, onChange, type, error, isOutOfStock, isRequired, handleOptionsClick, selectionQuantity, } = props;
|
|
1105
|
-
const classes = useDishModifierCardStyles();
|
|
1105
|
+
const classes = useDishModifierCardStyles$1();
|
|
1106
1106
|
return (React.createElement(commonUi.Box, { className: classes.root },
|
|
1107
1107
|
React.createElement(commonUi.Box, { display: "flex", justifyContent: "space-between", width: "100%", alignItems: "center", height: "fit-content", marginBottom: 2 },
|
|
1108
|
-
React.createElement(StatusTag, { ...getStatusTagProps(props) }),
|
|
1108
|
+
React.createElement(StatusTag, { ...getStatusTagProps$1(props) }),
|
|
1109
1109
|
!isOutOfStock && (React.createElement(commonUi.Typography, { variant: "subtitle1", className: classNames({ [classes.error]: error, [classes.helperText]: !error }) }, messages.helperText))),
|
|
1110
1110
|
React.createElement(commonUi.Typography, { component: "h3", className: classes.name }, name),
|
|
1111
1111
|
React.createElement(commonUi.Box, null,
|
|
1112
|
-
React.createElement(ModifierControls, { name: name, value: value, modifiers: modifiers, isOutOfStock: isOutOfStock, isRequired: isRequired, onChange: onChange, disableNewSelections: disableNewSelections, type: type, messages: messages, handleOptionsClick: handleOptionsClick, aggregatePrice: aggregatePrice, selectionQuantity: selectionQuantity }))));
|
|
1112
|
+
React.createElement(ModifierControls$1, { name: name, value: value, modifiers: modifiers, isOutOfStock: isOutOfStock, isRequired: isRequired, onChange: onChange, disableNewSelections: disableNewSelections, type: type, messages: messages, handleOptionsClick: handleOptionsClick, aggregatePrice: aggregatePrice, selectionQuantity: selectionQuantity }))));
|
|
1113
1113
|
};
|
|
1114
1114
|
DishModifierCard.displayName = 'DishModifierCard';
|
|
1115
1115
|
|
|
@@ -1616,6 +1616,431 @@ function MenuBannerButton(props) {
|
|
|
1616
1616
|
React.createElement(core.Link, { component: 'button', variant: 'body2', className: classes.button, ...props.ButtonProps }, props.buttonLabel)));
|
|
1617
1617
|
}
|
|
1618
1618
|
|
|
1619
|
+
const useExpandableModifierGroupStyles = core.makeStyles((theme) => ({
|
|
1620
|
+
root: {
|
|
1621
|
+
backgroundColor: theme.palette.grey[100],
|
|
1622
|
+
borderRadius: '8px',
|
|
1623
|
+
},
|
|
1624
|
+
header: {
|
|
1625
|
+
alignItems: 'center',
|
|
1626
|
+
background: 'none',
|
|
1627
|
+
border: 'none',
|
|
1628
|
+
borderRadius: '8px',
|
|
1629
|
+
cursor: 'pointer',
|
|
1630
|
+
display: 'flex',
|
|
1631
|
+
justifyContent: 'space-between',
|
|
1632
|
+
padding: theme.spacing(1.5, 2),
|
|
1633
|
+
width: '100%',
|
|
1634
|
+
},
|
|
1635
|
+
name: {
|
|
1636
|
+
color: theme.palette.grey[700],
|
|
1637
|
+
fontSize: '0.75rem',
|
|
1638
|
+
fontWeight: 600,
|
|
1639
|
+
letterSpacing: '0.08em',
|
|
1640
|
+
textTransform: 'uppercase',
|
|
1641
|
+
},
|
|
1642
|
+
chevron: {
|
|
1643
|
+
color: theme.palette.info.main,
|
|
1644
|
+
transition: 'transform 0.2s ease',
|
|
1645
|
+
},
|
|
1646
|
+
chevronExpanded: {
|
|
1647
|
+
transform: 'rotate(90deg)',
|
|
1648
|
+
},
|
|
1649
|
+
headerExpanded: {
|
|
1650
|
+
paddingBottom: theme.spacing(0.5),
|
|
1651
|
+
},
|
|
1652
|
+
summary: {
|
|
1653
|
+
alignItems: 'center',
|
|
1654
|
+
columnGap: theme.spacing(1),
|
|
1655
|
+
display: 'flex',
|
|
1656
|
+
padding: theme.spacing(0, 2, 1.5),
|
|
1657
|
+
},
|
|
1658
|
+
summaryIcon: {
|
|
1659
|
+
color: theme.palette.success.main,
|
|
1660
|
+
},
|
|
1661
|
+
// TODO [sc-162475]: 0.625rem (10px) is below the recommended minimum font size for accessibility — address in followup
|
|
1662
|
+
summaryText: {
|
|
1663
|
+
color: theme.palette.grey[700],
|
|
1664
|
+
fontSize: '0.625rem',
|
|
1665
|
+
lineHeight: 1.2,
|
|
1666
|
+
overflow: 'hidden',
|
|
1667
|
+
textOverflow: 'ellipsis',
|
|
1668
|
+
whiteSpace: 'nowrap',
|
|
1669
|
+
},
|
|
1670
|
+
}));
|
|
1671
|
+
|
|
1672
|
+
const ExpandableModifierGroup = ({ name, children, defaultExpanded = true, selectedSummary, }) => {
|
|
1673
|
+
const [expanded, setExpanded] = React.useState(defaultExpanded);
|
|
1674
|
+
const classes = useExpandableModifierGroupStyles();
|
|
1675
|
+
return (React.createElement("div", { className: classes.root },
|
|
1676
|
+
React.createElement("button", { className: classNames(classes.header, { [classes.headerExpanded]: expanded }), onClick: () => setExpanded((prev) => !prev), type: "button", "aria-expanded": expanded },
|
|
1677
|
+
React.createElement(core.Typography, { className: classes.name }, name),
|
|
1678
|
+
React.createElement(commonUi.Icon, { icon: webIcons.ChevronRight, className: classNames(classes.chevron, { [classes.chevronExpanded]: expanded }) })),
|
|
1679
|
+
!expanded && selectedSummary && (React.createElement("div", { className: classes.summary },
|
|
1680
|
+
React.createElement(commonUi.Icon, { icon: webIcons.CheckCircle, size: "medium", className: classes.summaryIcon }),
|
|
1681
|
+
React.createElement(core.Typography, { variant: "caption", className: classes.summaryText }, selectedSummary))),
|
|
1682
|
+
React.createElement("div", { hidden: !expanded }, children)));
|
|
1683
|
+
};
|
|
1684
|
+
ExpandableModifierGroup.displayName = 'ExpandableModifierGroup';
|
|
1685
|
+
|
|
1686
|
+
const useDishModifierCardStyles = core.makeStyles((theme) => ({
|
|
1687
|
+
root: {
|
|
1688
|
+
display: 'flex',
|
|
1689
|
+
flexDirection: 'column',
|
|
1690
|
+
padding: theme.spacing(2.5),
|
|
1691
|
+
color: `${theme.palette.grey[900]} !important`,
|
|
1692
|
+
},
|
|
1693
|
+
card: {
|
|
1694
|
+
borderRadius: '8px',
|
|
1695
|
+
border: '1px solid var(--surfaces-card-stroke, #E0E0E0)',
|
|
1696
|
+
},
|
|
1697
|
+
error: {
|
|
1698
|
+
color: theme.palette.error.main,
|
|
1699
|
+
},
|
|
1700
|
+
helperText: {
|
|
1701
|
+
color: theme.palette.grey[700],
|
|
1702
|
+
},
|
|
1703
|
+
optionalStatusTag: {
|
|
1704
|
+
'& > div': {
|
|
1705
|
+
backgroundColor: theme.palette.grey[300],
|
|
1706
|
+
},
|
|
1707
|
+
},
|
|
1708
|
+
name: {
|
|
1709
|
+
fontSize: '1.125rem',
|
|
1710
|
+
fontWeight: theme.typography.fontWeightBold,
|
|
1711
|
+
marginBottom: theme.spacing(2),
|
|
1712
|
+
},
|
|
1713
|
+
}));
|
|
1714
|
+
const useRadioModifierFormStyles = core.makeStyles((theme) => ({
|
|
1715
|
+
radioGroup: {
|
|
1716
|
+
gap: theme.spacing(2),
|
|
1717
|
+
},
|
|
1718
|
+
label: {
|
|
1719
|
+
alignItems: 'center',
|
|
1720
|
+
display: 'flex',
|
|
1721
|
+
justifyContent: 'space-between',
|
|
1722
|
+
width: '100%',
|
|
1723
|
+
},
|
|
1724
|
+
radio: {
|
|
1725
|
+
fontSize: '1rem',
|
|
1726
|
+
padding: 'unset',
|
|
1727
|
+
marginRight: theme.spacing(-0.25),
|
|
1728
|
+
'&.Mui-checked': {
|
|
1729
|
+
color: theme.palette.info.main,
|
|
1730
|
+
},
|
|
1731
|
+
},
|
|
1732
|
+
hideRadio: {
|
|
1733
|
+
display: 'none',
|
|
1734
|
+
},
|
|
1735
|
+
root: {
|
|
1736
|
+
justifyContent: 'space-between',
|
|
1737
|
+
margin: 0,
|
|
1738
|
+
width: '100%',
|
|
1739
|
+
'& > :last-child': {
|
|
1740
|
+
flex: 1,
|
|
1741
|
+
},
|
|
1742
|
+
},
|
|
1743
|
+
}));
|
|
1744
|
+
const useCheckboxModifierFormStyles = core.makeStyles((theme) => ({
|
|
1745
|
+
formGroup: {
|
|
1746
|
+
gap: theme.spacing(2),
|
|
1747
|
+
},
|
|
1748
|
+
label: {
|
|
1749
|
+
alignItems: 'center',
|
|
1750
|
+
display: 'flex',
|
|
1751
|
+
justifyContent: 'space-between',
|
|
1752
|
+
width: '100%',
|
|
1753
|
+
},
|
|
1754
|
+
checkbox: {
|
|
1755
|
+
color: theme.palette.grey[700],
|
|
1756
|
+
fontSize: '1rem',
|
|
1757
|
+
marginRight: theme.spacing(-0.25),
|
|
1758
|
+
padding: 'unset',
|
|
1759
|
+
'&.Mui-checked': {
|
|
1760
|
+
color: theme.palette.info.main,
|
|
1761
|
+
},
|
|
1762
|
+
},
|
|
1763
|
+
hideCheckbox: {
|
|
1764
|
+
display: 'none',
|
|
1765
|
+
},
|
|
1766
|
+
root: {
|
|
1767
|
+
margin: 0,
|
|
1768
|
+
width: '100%',
|
|
1769
|
+
'& > :last-child': {
|
|
1770
|
+
flex: 1,
|
|
1771
|
+
},
|
|
1772
|
+
},
|
|
1773
|
+
}));
|
|
1774
|
+
const useLabelStyles = core.makeStyles((theme) => ({
|
|
1775
|
+
label: {
|
|
1776
|
+
margin: theme.spacing(0.5, 0),
|
|
1777
|
+
},
|
|
1778
|
+
selectedLabel: {
|
|
1779
|
+
margin: theme.spacing(0.5, 0),
|
|
1780
|
+
},
|
|
1781
|
+
disabled: {
|
|
1782
|
+
color: theme.palette.grey[500],
|
|
1783
|
+
},
|
|
1784
|
+
price: {
|
|
1785
|
+
color: theme.palette.grey[700],
|
|
1786
|
+
},
|
|
1787
|
+
selectedSummary: {
|
|
1788
|
+
color: theme.palette.grey[700],
|
|
1789
|
+
},
|
|
1790
|
+
selectedSummaryInlineRow: {
|
|
1791
|
+
alignItems: 'center',
|
|
1792
|
+
color: theme.palette.grey[700],
|
|
1793
|
+
columnGap: theme.spacing(1),
|
|
1794
|
+
display: 'flex',
|
|
1795
|
+
justifyContent: 'space-between',
|
|
1796
|
+
marginTop: theme.spacing(0.5),
|
|
1797
|
+
minHeight: theme.spacing(2.5),
|
|
1798
|
+
width: '100%',
|
|
1799
|
+
},
|
|
1800
|
+
selectedSummaryPrimary: {
|
|
1801
|
+
alignItems: 'center',
|
|
1802
|
+
columnGap: theme.spacing(1),
|
|
1803
|
+
display: 'flex',
|
|
1804
|
+
flex: 1,
|
|
1805
|
+
minWidth: 0,
|
|
1806
|
+
},
|
|
1807
|
+
// TODO [sc-162475]: 0.625rem (10px) is below the recommended minimum font size for accessibility — address in followup
|
|
1808
|
+
selectedSummaryPrimaryText: {
|
|
1809
|
+
color: theme.palette.grey[700],
|
|
1810
|
+
fontSize: '0.625rem',
|
|
1811
|
+
fontWeight: theme.typography.fontWeightRegular,
|
|
1812
|
+
lineHeight: 1.2,
|
|
1813
|
+
overflow: 'hidden',
|
|
1814
|
+
textOverflow: 'ellipsis',
|
|
1815
|
+
whiteSpace: 'nowrap',
|
|
1816
|
+
},
|
|
1817
|
+
selectedSummaryIcon: {
|
|
1818
|
+
color: theme.palette.success.main,
|
|
1819
|
+
},
|
|
1820
|
+
}));
|
|
1821
|
+
const useOptionsStyles = core.makeStyles((theme) => ({
|
|
1822
|
+
options: {
|
|
1823
|
+
color: theme.palette.info.main,
|
|
1824
|
+
marginBottom: theme.spacing(1.5),
|
|
1825
|
+
minWidth: 'unset',
|
|
1826
|
+
padding: 0,
|
|
1827
|
+
},
|
|
1828
|
+
inlineOptions: {
|
|
1829
|
+
alignItems: 'center',
|
|
1830
|
+
display: 'inline-flex',
|
|
1831
|
+
justifyContent: 'center',
|
|
1832
|
+
height: 'auto',
|
|
1833
|
+
marginBottom: 0,
|
|
1834
|
+
minHeight: 'unset',
|
|
1835
|
+
paddingBottom: 0,
|
|
1836
|
+
paddingLeft: '10px',
|
|
1837
|
+
paddingRight: 0,
|
|
1838
|
+
paddingTop: 0,
|
|
1839
|
+
'& .MuiTypography-root': {
|
|
1840
|
+
// TODO [sc-162475]: 0.625rem (10px) is below the recommended minimum font size for accessibility — address in followup
|
|
1841
|
+
fontSize: '0.625rem',
|
|
1842
|
+
lineHeight: 1.2,
|
|
1843
|
+
},
|
|
1844
|
+
},
|
|
1845
|
+
}));
|
|
1846
|
+
|
|
1847
|
+
const Label = (props) => {
|
|
1848
|
+
const { name, price, disabled = false, hidePrice = false, isSelected = false, selectedSummary, enableSelectedModifierStyles = false, } = props;
|
|
1849
|
+
const classes = useLabelStyles();
|
|
1850
|
+
const numericPrice = price ? parseFloat(price.replace(/[^0-9.-]/g, '')) : NaN;
|
|
1851
|
+
const shouldHidePrice = hidePrice || !price || numericPrice === 0 || isNaN(numericPrice);
|
|
1852
|
+
const showSelectedSummary = Boolean(enableSelectedModifierStyles && isSelected && selectedSummary);
|
|
1853
|
+
return (React.createElement(core.Box, { display: "flex", flexDirection: "column", className: classNames({ [classes.label]: !showSelectedSummary, [classes.selectedLabel]: showSelectedSummary }) },
|
|
1854
|
+
React.createElement(core.Box, { display: "flex", alignItems: "center", gridGap: 8 },
|
|
1855
|
+
React.createElement(core.Typography, { className: classNames({
|
|
1856
|
+
[classes.disabled]: disabled,
|
|
1857
|
+
}) }, name)),
|
|
1858
|
+
!shouldHidePrice && (React.createElement(core.Typography, { className: classNames({ [classes.price]: !disabled }, { [classes.disabled]: disabled }) }, `+ ${price}`)),
|
|
1859
|
+
showSelectedSummary && React.createElement(core.Typography, { className: classes.selectedSummary }, selectedSummary)));
|
|
1860
|
+
};
|
|
1861
|
+
const Options = (props) => {
|
|
1862
|
+
const { handleOptionsClick, actionLabel, hidden = false, inline = false } = props;
|
|
1863
|
+
const classes = useOptionsStyles();
|
|
1864
|
+
const displayActionLabel = inline ? (actionLabel === 'UPDATE' ? 'Update' : 'Options') : actionLabel;
|
|
1865
|
+
if (hidden)
|
|
1866
|
+
return null;
|
|
1867
|
+
return (React.createElement(core.Box, null,
|
|
1868
|
+
React.createElement(Button, { variation: "none", className: classNames(classes.options, { [classes.inlineOptions]: inline }), onClick: handleOptionsClick },
|
|
1869
|
+
React.createElement(core.Typography, { variant: "caption" }, displayActionLabel),
|
|
1870
|
+
!inline && React.createElement(commonUi.Icon, { icon: webIcons.ChevronRight }))));
|
|
1871
|
+
};
|
|
1872
|
+
const getIsSelected = (modifierId, value) => value.some((modifierValue) => modifierValue.modifierId === modifierId && modifierValue.quantity > 0);
|
|
1873
|
+
const getActionLabel = (isSelected, props) => props.modifierControlsOptions?.showUpdateButton && isSelected ? 'UPDATE' : 'OPTIONS';
|
|
1874
|
+
const shouldHideNestedOptionsButton = (isSelected, props) => Boolean(props.modifierControlsOptions?.hideNestedOptionsButton ||
|
|
1875
|
+
(props.modifierControlsOptions?.enableSelectedModifierStyles && !isSelected));
|
|
1876
|
+
const shouldShowInlineAction = (isSelected, props) => Boolean(isSelected &&
|
|
1877
|
+
props.modifierControlsOptions?.enableSelectedModifierStyles &&
|
|
1878
|
+
!props.modifierControlsOptions?.hideNestedOptionsButton);
|
|
1879
|
+
const getModifierActionState = (modifier, isSelected, props) => ({
|
|
1880
|
+
isSelected,
|
|
1881
|
+
shouldHideNestedOptions: shouldHideNestedOptionsButton(isSelected, props),
|
|
1882
|
+
showInlineAction: shouldShowInlineAction(isSelected, props),
|
|
1883
|
+
actionLabel: getActionLabel(isSelected, props),
|
|
1884
|
+
selectedSummary: props.modifierControlsOptions?.selectedNestedSummaryByModifierId?.[modifier.id],
|
|
1885
|
+
});
|
|
1886
|
+
const NestedModifierActions = (props) => {
|
|
1887
|
+
const { modifier, handleOptionsClick, state, renderRegularButton = true } = props;
|
|
1888
|
+
const labelClasses = useLabelStyles();
|
|
1889
|
+
if (!modifier.hasModifiers || modifier.outOfStock)
|
|
1890
|
+
return null;
|
|
1891
|
+
return (React.createElement(React.Fragment, null,
|
|
1892
|
+
state.showInlineAction && state.selectedSummary && (React.createElement(core.Box, { className: labelClasses.selectedSummaryInlineRow },
|
|
1893
|
+
React.createElement(core.Box, { className: labelClasses.selectedSummaryPrimary },
|
|
1894
|
+
React.createElement(commonUi.Icon, { icon: webIcons.CheckCircle, size: "medium", className: labelClasses.selectedSummaryIcon }),
|
|
1895
|
+
React.createElement(core.Typography, { variant: "caption", className: labelClasses.selectedSummaryPrimaryText }, state.selectedSummary)),
|
|
1896
|
+
React.createElement(Options, { handleOptionsClick: () => handleOptionsClick(modifier.id), actionLabel: state.actionLabel, inline: true, hidden: state.shouldHideNestedOptions }))),
|
|
1897
|
+
renderRegularButton && (React.createElement(Options, { handleOptionsClick: () => handleOptionsClick(modifier.id), actionLabel: state.actionLabel, hidden: state.shouldHideNestedOptions || (state.showInlineAction && Boolean(state.selectedSummary)) }))));
|
|
1898
|
+
};
|
|
1899
|
+
const SingleSelectModifierControl = (props) => {
|
|
1900
|
+
const { modifiers, name, isOutOfStock, onChange, value, handleOptionsClick, aggregatePrice, isRequired } = props;
|
|
1901
|
+
const radioClasses = useRadioModifierFormStyles();
|
|
1902
|
+
const makeHandleChange = (modifier) => (e) => {
|
|
1903
|
+
const isModifierInValue = Boolean(value.find((v) => v.modifierId === modifier.id));
|
|
1904
|
+
if (!isModifierInValue && modifier.hasModifiers && !props.modifierControlsOptions?.hideNestedOptionsButton) {
|
|
1905
|
+
handleOptionsClick(modifier.id);
|
|
1906
|
+
}
|
|
1907
|
+
onChange({
|
|
1908
|
+
isRadio: true,
|
|
1909
|
+
modifierId: Number(e.target.value),
|
|
1910
|
+
groupId: modifier.parentModifierGroupId,
|
|
1911
|
+
parentModifierId: modifier.parentModifierGroupItemId,
|
|
1912
|
+
price: modifier.price || 0,
|
|
1913
|
+
quantity: 1,
|
|
1914
|
+
});
|
|
1915
|
+
};
|
|
1916
|
+
return (React.createElement(core.FormControl, { fullWidth: true },
|
|
1917
|
+
React.createElement(core.RadioGroup, { className: radioClasses.radioGroup, "aria-label": name }, modifiers.map((modifier) => {
|
|
1918
|
+
const modifierActionState = getModifierActionState(modifier, getIsSelected(modifier.id, value), props);
|
|
1919
|
+
return (React.createElement(core.Box, { key: modifier.id },
|
|
1920
|
+
React.createElement(core.FormControlLabel, { key: modifier.id, value: modifier.id, className: radioClasses.root, control: React.createElement(core.Radio, { checked: value[0]?.modifierId === modifier.id, className: classNames({
|
|
1921
|
+
[radioClasses.hideRadio]: modifier.outOfStock,
|
|
1922
|
+
[radioClasses.radio]: !modifier.outOfStock,
|
|
1923
|
+
}), disabled: isOutOfStock || modifier.outOfStock, onChange: makeHandleChange(modifier), required: isRequired }), label: React.createElement(core.Box, { className: radioClasses.label },
|
|
1924
|
+
React.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 }),
|
|
1925
|
+
modifier.outOfStock && (React.createElement(core.Box, { minWidth: "90px", marginLeft: 2 },
|
|
1926
|
+
React.createElement(StatusTag, { color: "warning", label: "Out of stock", variant: "outlined", size: "md" })))), labelPlacement: "start" }),
|
|
1927
|
+
React.createElement(NestedModifierActions, { modifier: modifier, handleOptionsClick: handleOptionsClick, state: modifierActionState })));
|
|
1928
|
+
}))));
|
|
1929
|
+
};
|
|
1930
|
+
const MultipleSelectControl = (props) => {
|
|
1931
|
+
const { modifiers, value, isOutOfStock, onChange, disableNewSelections, handleOptionsClick, aggregatePrice } = props;
|
|
1932
|
+
const classes = useCheckboxModifierFormStyles();
|
|
1933
|
+
const makeHandleChange = (modifier) => () => {
|
|
1934
|
+
const isModifierInValue = Boolean(value.find((v) => v.modifierId === modifier.id));
|
|
1935
|
+
if (!isModifierInValue && modifier.hasModifiers && !props.modifierControlsOptions?.hideNestedOptionsButton) {
|
|
1936
|
+
handleOptionsClick(modifier.id);
|
|
1937
|
+
}
|
|
1938
|
+
onChange({
|
|
1939
|
+
isRadio: false,
|
|
1940
|
+
modifierId: modifier.id,
|
|
1941
|
+
groupId: modifier.parentModifierGroupId,
|
|
1942
|
+
parentModifierId: modifier.parentModifierGroupItemId,
|
|
1943
|
+
price: modifier.price || 0,
|
|
1944
|
+
quantity: isModifierInValue ? 0 : 1,
|
|
1945
|
+
});
|
|
1946
|
+
};
|
|
1947
|
+
return (React.createElement(core.FormControl, { fullWidth: true },
|
|
1948
|
+
React.createElement(core.FormGroup, { className: classes.formGroup }, modifiers.map((modifier) => {
|
|
1949
|
+
const modifierActionState = getModifierActionState(modifier, getIsSelected(modifier.id, value), props);
|
|
1950
|
+
return (React.createElement(core.Box, { key: modifier.id },
|
|
1951
|
+
React.createElement(core.FormControlLabel, { key: modifier.id, value: modifier.id, className: classes.root, checked: value.some((v) => v.modifierId === modifier.id), onChange: makeHandleChange(modifier), control: React.createElement(core.Checkbox, { className: classNames({ [classes.hideCheckbox]: modifier.outOfStock }, { [classes.checkbox]: !modifier.outOfStock }), disabled: isOutOfStock || modifier.outOfStock || (!modifier.quantity && disableNewSelections) }), label: React.createElement(core.Box, { className: classes.label },
|
|
1952
|
+
React.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 }),
|
|
1953
|
+
modifier.outOfStock && (React.createElement(core.Box, { minWidth: "90px", marginLeft: 2 },
|
|
1954
|
+
React.createElement(StatusTag, { color: "warning", label: "Out of stock", variant: "outlined", size: "md" })))), labelPlacement: "start" }),
|
|
1955
|
+
React.createElement(NestedModifierActions, { modifier: modifier, handleOptionsClick: handleOptionsClick, state: modifierActionState })));
|
|
1956
|
+
}))));
|
|
1957
|
+
};
|
|
1958
|
+
const MultipleQuantitySelectControl = (props) => {
|
|
1959
|
+
const { modifiers, isOutOfStock, onChange, disableNewSelections, handleOptionsClick, selectionQuantity, aggregatePrice, } = props;
|
|
1960
|
+
const makeHandleChange = (modifier) => (_e, customEvent) => {
|
|
1961
|
+
onChange({
|
|
1962
|
+
isRadio: false,
|
|
1963
|
+
modifierId: modifier.id,
|
|
1964
|
+
groupId: modifier.parentModifierGroupId,
|
|
1965
|
+
parentModifierId: modifier.parentModifierGroupItemId,
|
|
1966
|
+
price: modifier.price || 0,
|
|
1967
|
+
quantity: customEvent.quantity,
|
|
1968
|
+
});
|
|
1969
|
+
};
|
|
1970
|
+
return (React.createElement(core.FormControl, { fullWidth: true },
|
|
1971
|
+
React.createElement(core.FormGroup, null, modifiers.map((modifier) => {
|
|
1972
|
+
const modifierActionState = getModifierActionState(modifier, modifier.quantity > 0, props);
|
|
1973
|
+
return (React.createElement(core.Box, { key: modifier.id, style: { justifyContent: 'space-between', flexDirection: 'column' }, display: "flex" },
|
|
1974
|
+
React.createElement(core.Box, { display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%" },
|
|
1975
|
+
React.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 }),
|
|
1976
|
+
modifier.outOfStock && (React.createElement(core.Box, { minWidth: "90px", marginLeft: 2 },
|
|
1977
|
+
React.createElement(StatusTag, { color: "warning", label: "Out of stock", variant: "outlined", size: "md" }))),
|
|
1978
|
+
!modifier.outOfStock && (React.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 }))),
|
|
1979
|
+
React.createElement(NestedModifierActions, { modifier: modifier, handleOptionsClick: handleOptionsClick, state: modifierActionState, renderRegularButton: false }),
|
|
1980
|
+
React.createElement(core.Box, { display: "flex", alignItems: "flex-start", gridGap: 4 },
|
|
1981
|
+
modifier.hasModifiers && !modifier.outOfStock && (React.createElement(Options, { handleOptionsClick: () => handleOptionsClick(modifier.id), actionLabel: modifierActionState.actionLabel, hidden: modifierActionState.shouldHideNestedOptions ||
|
|
1982
|
+
(modifierActionState.showInlineAction && Boolean(modifierActionState.selectedSummary)) })),
|
|
1983
|
+
selectionQuantity[modifier.id] &&
|
|
1984
|
+
selectionQuantity[modifier.id].requiredSelectionCount > 0 &&
|
|
1985
|
+
selectionQuantity[modifier.id].requiredSelectionCount !==
|
|
1986
|
+
selectionQuantity[modifier.id].currentSelectionCount && (React.createElement(core.Typography, { variant: "caption", color: "error" },
|
|
1987
|
+
selectionQuantity[modifier.id].currentSelectionCount,
|
|
1988
|
+
"/",
|
|
1989
|
+
selectionQuantity[modifier.id].requiredSelectionCount,
|
|
1990
|
+
" selected")))));
|
|
1991
|
+
}))));
|
|
1992
|
+
};
|
|
1993
|
+
const ModifierControls = (props) => {
|
|
1994
|
+
switch (props.type) {
|
|
1995
|
+
case 'singleSelect':
|
|
1996
|
+
return React.createElement(SingleSelectModifierControl, { ...props });
|
|
1997
|
+
case 'multipleSelect':
|
|
1998
|
+
return React.createElement(MultipleSelectControl, { ...props });
|
|
1999
|
+
case 'multipleQuantitySelect':
|
|
2000
|
+
return React.createElement(MultipleQuantitySelectControl, { ...props });
|
|
2001
|
+
default:
|
|
2002
|
+
return null;
|
|
2003
|
+
}
|
|
2004
|
+
};
|
|
2005
|
+
|
|
2006
|
+
const getStatusTagProps = (props) => {
|
|
2007
|
+
const { messages, error, isRequired, isOutOfStock } = props;
|
|
2008
|
+
const { optionalText, outOfStockText, requiredText } = messages;
|
|
2009
|
+
let color = 'default';
|
|
2010
|
+
switch (true) {
|
|
2011
|
+
case error:
|
|
2012
|
+
color = 'error';
|
|
2013
|
+
break;
|
|
2014
|
+
case isOutOfStock:
|
|
2015
|
+
color = 'warning';
|
|
2016
|
+
break;
|
|
2017
|
+
}
|
|
2018
|
+
let label = optionalText;
|
|
2019
|
+
switch (true) {
|
|
2020
|
+
case isOutOfStock:
|
|
2021
|
+
label = outOfStockText;
|
|
2022
|
+
break;
|
|
2023
|
+
case isRequired:
|
|
2024
|
+
label = requiredText;
|
|
2025
|
+
break;
|
|
2026
|
+
}
|
|
2027
|
+
const variant = isRequired || isOutOfStock ? 'outlined' : 'filled';
|
|
2028
|
+
return { color, label, variant };
|
|
2029
|
+
};
|
|
2030
|
+
const NestedModsV2DishModifierCard = (props) => {
|
|
2031
|
+
const { aggregatePrice, name, disableNewSelections, modifiers, value, messages, onChange, type, error, isOutOfStock, isRequired, handleOptionsClick, selectionQuantity, modifierControlsOptions, disableCardStyle = false, hideName = false, } = props;
|
|
2032
|
+
const classes = useDishModifierCardStyles();
|
|
2033
|
+
return (React.createElement(commonUi.Box, { className: classNames(classes.root, { [classes.card]: !disableCardStyle }) },
|
|
2034
|
+
React.createElement(commonUi.Box, { display: "flex", justifyContent: "space-between", width: "100%", alignItems: "center", height: "fit-content", marginBottom: 2 },
|
|
2035
|
+
React.createElement(commonUi.Box, { className: classNames({ [classes.optionalStatusTag]: !isRequired && !isOutOfStock }) },
|
|
2036
|
+
React.createElement(StatusTag, { ...getStatusTagProps(props) })),
|
|
2037
|
+
!isOutOfStock && (React.createElement(commonUi.Typography, { variant: "subtitle1", className: classNames({ [classes.error]: error, [classes.helperText]: !error }) }, messages.helperText))),
|
|
2038
|
+
!hideName && (React.createElement(commonUi.Typography, { component: "h3", className: classes.name }, name)),
|
|
2039
|
+
React.createElement(commonUi.Box, null,
|
|
2040
|
+
React.createElement(ModifierControls, { name: name, value: value, modifiers: modifiers, isOutOfStock: isOutOfStock, isRequired: isRequired, onChange: onChange, disableNewSelections: disableNewSelections, type: type, messages: messages, handleOptionsClick: handleOptionsClick, aggregatePrice: aggregatePrice, selectionQuantity: selectionQuantity, modifierControlsOptions: modifierControlsOptions }))));
|
|
2041
|
+
};
|
|
2042
|
+
NestedModsV2DishModifierCard.displayName = 'NestedModsV2DishModifierCard';
|
|
2043
|
+
|
|
1619
2044
|
const palette = {
|
|
1620
2045
|
primary: {
|
|
1621
2046
|
main: '#0A202F',
|
|
@@ -1895,6 +2320,7 @@ exports.DialogTitle = DialogTitle;
|
|
|
1895
2320
|
exports.DishCheckoutCard = DishCheckoutCard;
|
|
1896
2321
|
exports.DishDetailsReview = DishDetailsReview;
|
|
1897
2322
|
exports.DishModifierCard = DishModifierCard;
|
|
2323
|
+
exports.ExpandableModifierGroup = ExpandableModifierGroup;
|
|
1898
2324
|
exports.ItemTag = ItemTag;
|
|
1899
2325
|
exports.ItemTagGroup = ItemTagGroup;
|
|
1900
2326
|
exports.LocationCard = LocationCard;
|
|
@@ -1908,6 +2334,7 @@ exports.MenuSection = MenuSection;
|
|
|
1908
2334
|
exports.MenuSectionGroup = MenuSectionGroup;
|
|
1909
2335
|
exports.MenuTab = MenuTab;
|
|
1910
2336
|
exports.MenuTabGroup = MenuTabGroup;
|
|
2337
|
+
exports.NestedModsV2DishModifierCard = NestedModsV2DishModifierCard;
|
|
1911
2338
|
exports.OrderingAppContext = OrderingAppContext;
|
|
1912
2339
|
exports.OrderingAppContextProvider = OrderingAppContextProvider;
|
|
1913
2340
|
exports.PageSection = PageSection;
|