@popmenu/ordering-ui 0.118.0 → 0.120.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.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export interface DishCheckoutCardProps {
|
|
2
2
|
/** Adds a border to the bottom of the card */
|
|
3
3
|
borderBottom?: boolean;
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/** Modifier group object of the dish */
|
|
5
|
+
modifierGroups?: ModifierGroupsType[];
|
|
6
6
|
/** Id of the dish */
|
|
7
7
|
id: number;
|
|
8
8
|
/** Dish image information */
|
|
@@ -29,3 +29,13 @@ export interface DishCheckoutCardProps {
|
|
|
29
29
|
/** If item is in cart but is not unavailable */
|
|
30
30
|
warningMessage?: string;
|
|
31
31
|
}
|
|
32
|
+
export declare type ModifierGroupsType = {
|
|
33
|
+
id: number;
|
|
34
|
+
menuItemModifierGroupName?: string | null;
|
|
35
|
+
selectedModifiers: ModifiersType[];
|
|
36
|
+
};
|
|
37
|
+
export declare type ModifiersType = {
|
|
38
|
+
id: number;
|
|
39
|
+
modifierName?: string | null;
|
|
40
|
+
selectedModifierGroups?: ModifierGroupsType[];
|
|
41
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useMenuItemStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<"cardActionArea" | "card" | "cardTitle" | "cardDescription">;
|
|
1
|
+
export declare const useMenuItemStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<"cardActionArea" | "card" | "cardTitle" | "cardDescription" | "outOfStockTag">;
|
package/build/index.es.js
CHANGED
|
@@ -150,7 +150,7 @@ var useMenuItemStyles = makeStyles(function (theme) {
|
|
|
150
150
|
fontWeight: 400,
|
|
151
151
|
fontSize: 14,
|
|
152
152
|
lineHeight: '20px',
|
|
153
|
-
|
|
153
|
+
margin: theme.spacing(0.5, 0, 1, 0),
|
|
154
154
|
color: theme.palette.grey[800],
|
|
155
155
|
'-webkit-line-clamp': 2,
|
|
156
156
|
display: '-webkit-box',
|
|
@@ -158,6 +158,12 @@ var useMenuItemStyles = makeStyles(function (theme) {
|
|
|
158
158
|
textOverflow: 'ellipsis',
|
|
159
159
|
overflow: 'hidden',
|
|
160
160
|
},
|
|
161
|
+
outOfStockTag: {
|
|
162
|
+
minWidth: '90px',
|
|
163
|
+
marginLeft: theme.spacing(1),
|
|
164
|
+
display: 'inline-block',
|
|
165
|
+
verticalAlign: 'bottom',
|
|
166
|
+
},
|
|
161
167
|
});
|
|
162
168
|
});
|
|
163
169
|
|
|
@@ -1503,8 +1509,9 @@ var MenuItem = forwardRef(function (props, ref) {
|
|
|
1503
1509
|
React__default.createElement(MenuItemInfo, null,
|
|
1504
1510
|
isFeatured && React__default.createElement(StatusTag, { color: "highlight", label: "Featured", variant: "filled", size: "sm" }),
|
|
1505
1511
|
React__default.createElement(Box, { display: "flex", gridGap: 8, alignItems: "center" },
|
|
1506
|
-
React__default.createElement(Typography$1, { component: "h3", className: classes.cardTitle },
|
|
1507
|
-
|
|
1512
|
+
React__default.createElement(Typography$1, { component: "h3", className: classes.cardTitle },
|
|
1513
|
+
loading ? React__default.createElement(Skeleton, null) : title,
|
|
1514
|
+
React__default.createElement("span", { className: classes.outOfStockTag }, isOutOfStock && React__default.createElement(StatusTag, { color: "warning", label: "Out of stock", variant: "outlined", size: "sm" })))),
|
|
1508
1515
|
React__default.createElement(Typography$1, { className: classes.cardDescription, paragraph: true }, loading ? React__default.createElement(Skeleton, null) : description),
|
|
1509
1516
|
loading ? (React__default.createElement(Skeleton, null,
|
|
1510
1517
|
React__default.createElement(MenuItemReactions, { likeCount: likeCount, reviewCount: reviewCount }))) : (React__default.createElement(MenuItemReactions, { likeCount: likeCount, reviewCount: reviewCount })),
|
|
@@ -1585,6 +1592,10 @@ var useDishCheckoutCardStyles = makeStyles(function (theme) { return ({
|
|
|
1585
1592
|
selectPaper: {
|
|
1586
1593
|
maxHeight: theme.spacing(37),
|
|
1587
1594
|
},
|
|
1595
|
+
ul: {
|
|
1596
|
+
margin: 0,
|
|
1597
|
+
paddingLeft: theme.spacing(3),
|
|
1598
|
+
},
|
|
1588
1599
|
warning: {
|
|
1589
1600
|
color: theme.palette.error.main,
|
|
1590
1601
|
display: 'flex',
|
|
@@ -1607,7 +1618,7 @@ var OrderingAppContextProvider = function (props) {
|
|
|
1607
1618
|
|
|
1608
1619
|
var DishCheckoutCard = function (props) {
|
|
1609
1620
|
var _a;
|
|
1610
|
-
var id = props.id, name = props.name, quantity = props.quantity,
|
|
1621
|
+
var id = props.id, name = props.name, quantity = props.quantity, modifierGroups = props.modifierGroups, onDelete = props.onDelete, onEdit = props.onEdit, onQuantityChange = props.onQuantityChange, price = props.price, specialInstructions = props.specialInstructions, disabled = props.disabled, warningMessage = props.warningMessage, _b = props.image, image = _b === void 0 ? {} : _b;
|
|
1611
1622
|
var src = image.src, alt = image.alt;
|
|
1612
1623
|
var classes = useDishCheckoutCardStyles(props);
|
|
1613
1624
|
var appContext = useOrderingAppContext()[0];
|
|
@@ -1619,16 +1630,41 @@ var DishCheckoutCard = function (props) {
|
|
|
1619
1630
|
var labelString = function (label) {
|
|
1620
1631
|
return label.replace(/[^a-zA-Z\s]/g, '').toLowerCase();
|
|
1621
1632
|
};
|
|
1633
|
+
var formatModifiers = function (groups, nested) {
|
|
1634
|
+
if (nested === void 0) { nested = false; }
|
|
1635
|
+
return groups.map(function (group) {
|
|
1636
|
+
// Get all selected modifiers for this group
|
|
1637
|
+
var modifiers = group.selectedModifiers.map(function (modifier) { return modifier.modifierName; }).join(', ');
|
|
1638
|
+
// Render nested groups recursively
|
|
1639
|
+
var nestedGroups = group.selectedModifiers.flatMap(function (modifier) {
|
|
1640
|
+
var _a;
|
|
1641
|
+
return (modifier === null || modifier === void 0 ? void 0 : modifier.selectedModifierGroups) && ((_a = modifier === null || modifier === void 0 ? void 0 : modifier.selectedModifierGroups) === null || _a === void 0 ? void 0 : _a.length) > 0
|
|
1642
|
+
? formatModifiers(modifier.selectedModifierGroups, true)
|
|
1643
|
+
: [];
|
|
1644
|
+
});
|
|
1645
|
+
// For top-level groups, we render without the list
|
|
1646
|
+
if (!nested) {
|
|
1647
|
+
return (React__default.createElement(Typography, { key: group.id, variant: "body2" },
|
|
1648
|
+
group.menuItemModifierGroupName,
|
|
1649
|
+
": ",
|
|
1650
|
+
modifiers,
|
|
1651
|
+
(nestedGroups === null || nestedGroups === void 0 ? void 0 : nestedGroups.length) > 0 && React__default.createElement("ul", { className: classes.ul }, nestedGroups)));
|
|
1652
|
+
}
|
|
1653
|
+
// For nested groups, we use list items
|
|
1654
|
+
return (React__default.createElement("li", { key: group.id, className: classes.li },
|
|
1655
|
+
React__default.createElement(Typography, { variant: "body2" },
|
|
1656
|
+
group.menuItemModifierGroupName,
|
|
1657
|
+
": ",
|
|
1658
|
+
modifiers,
|
|
1659
|
+
nestedGroups && nestedGroups.length > 0 && React__default.createElement("ul", { className: classes.ul }, nestedGroups))));
|
|
1660
|
+
});
|
|
1661
|
+
};
|
|
1622
1662
|
return (React__default.createElement(Box, { className: classes.root },
|
|
1623
1663
|
React__default.createElement(Box, { display: "flex", gridGap: 3 },
|
|
1624
1664
|
src && alt && React__default.createElement("img", { src: src, alt: alt, className: classes.img }),
|
|
1625
1665
|
React__default.createElement(Box, { flexGrow: 1 },
|
|
1626
1666
|
React__default.createElement(Typography, { variant: "h2", className: classes.name }, name),
|
|
1627
|
-
|
|
1628
|
-
modifiers.map(function (modifier, i) { return (React__default.createElement(Typography, { key: i, variant: "body2" },
|
|
1629
|
-
modifier[0],
|
|
1630
|
-
": ",
|
|
1631
|
-
modifier[1])); }),
|
|
1667
|
+
modifierGroups && formatModifiers(modifierGroups),
|
|
1632
1668
|
specialInstructions && React__default.createElement(Typography, { variant: "body2" },
|
|
1633
1669
|
"\"",
|
|
1634
1670
|
specialInstructions,
|
|
@@ -1959,8 +1995,10 @@ var getStatusTagProps = function (props) {
|
|
|
1959
1995
|
switch (true) {
|
|
1960
1996
|
case error:
|
|
1961
1997
|
color = 'error';
|
|
1998
|
+
break;
|
|
1962
1999
|
case isOutOfStock:
|
|
1963
2000
|
color = 'warning';
|
|
2001
|
+
break;
|
|
1964
2002
|
}
|
|
1965
2003
|
var label = optionalText;
|
|
1966
2004
|
switch (true) {
|