@popmenu/ordering-ui 0.83.1 → 0.84.1
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/components/DishCheckoutCard/DishCheckoutCardProps.d.ts +5 -3
- package/build/components/DishModifierCard/DishModifierCard.styles.d.ts +1 -0
- package/build/components/DishModifierCard/DishModifierCardProps.d.ts +1 -0
- package/build/components/PageSection/PageSection.d.ts +4 -0
- package/build/components/PageSection/index.d.ts +1 -0
- package/build/components/index.d.ts +1 -0
- package/build/index.es.js +54 -55
- package/build/index.es.js.map +1 -1
- package/build/index.js +53 -53
- package/build/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
export interface DishCheckoutCardProps {
|
|
2
2
|
/** Modifiers of the dish in tuple format */
|
|
3
|
-
modifiers?:
|
|
3
|
+
modifiers?: [string, string][];
|
|
4
4
|
/** Id of the dish */
|
|
5
5
|
id: number;
|
|
6
|
+
/** disables all interactive elements in the card, like "edit" or "delete" */
|
|
7
|
+
disabled?: boolean;
|
|
6
8
|
/** Name of the dish */
|
|
7
9
|
name: string;
|
|
8
10
|
/** Quantity of dish selected */
|
|
9
11
|
quantity: number;
|
|
10
12
|
/** Price of description should be formatted in the correct currency before passing as a prop */
|
|
11
|
-
price: string;
|
|
13
|
+
price: number | string;
|
|
12
14
|
/** Callback for edit button */
|
|
13
15
|
onEdit: () => void;
|
|
14
16
|
/** Callback for delete button */
|
|
@@ -16,5 +18,5 @@ export interface DishCheckoutCardProps {
|
|
|
16
18
|
/** Callback that runs when the select value is changed. Expects two arguments, the id of the selected dish and the new value that is being changed from the dropdown. Callback should update the dish */
|
|
17
19
|
onChange: (id: number, value: number | string) => void;
|
|
18
20
|
/** Special instructions text */
|
|
19
|
-
specialInstructions?: string |
|
|
21
|
+
specialInstructions?: string | null;
|
|
20
22
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const useDishModifierCardStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<string>;
|
|
2
2
|
export declare const useRadioModifierFormStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<string>;
|
|
3
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>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PageSection } from './PageSection';
|
|
@@ -20,3 +20,4 @@ export { SelectedMenuFiltersList, SelectedMenuFiltersListProps } from './Selecte
|
|
|
20
20
|
export { MenuSectionGroup } from './MenuSectionGroup';
|
|
21
21
|
export { MenuSection, MenuSectionProps } from './MenuSection';
|
|
22
22
|
export { MenuItemGroup } from './MenuItemGroup';
|
|
23
|
+
export { PageSection } from './PageSection';
|
package/build/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Button as Button$2, makeStyles as makeStyles$1, Box, Typography as Typography$1, Link as Link$1, Paper as Paper$1, Avatar as Avatar$1, Card, CardActionArea, FormControl, Select, InputAdornment, MenuItem as MenuItem$1, FormControlLabel as FormControlLabel$1, Checkbox as Checkbox$1, Radio as Radio$1, Menu, TextField, Tabs, Chip } from '@material-ui/core';
|
|
2
2
|
export * from '@material-ui/core';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import React__default, { forwardRef, createElement,
|
|
4
|
+
import React__default, { forwardRef, createElement, createContext, useContext, useState } from 'react';
|
|
5
5
|
import { makeStyles, useTheme, lighten } from '@material-ui/core/styles';
|
|
6
6
|
import '@material-ui/lab/Alert';
|
|
7
7
|
import '@material-ui/core/AppBar';
|
|
@@ -1245,8 +1245,7 @@ var useDishCheckoutCardStyles = makeStyles(function (theme) { return ({
|
|
|
1245
1245
|
gridGap: theme.spacing(2),
|
|
1246
1246
|
border: '1px',
|
|
1247
1247
|
},
|
|
1248
|
-
|
|
1249
|
-
height: theme.spacing(2.5),
|
|
1248
|
+
deleteButton: {
|
|
1250
1249
|
color: theme.palette.info.main,
|
|
1251
1250
|
},
|
|
1252
1251
|
editButton: {
|
|
@@ -1283,10 +1282,26 @@ var useDishCheckoutCardStyles = makeStyles(function (theme) { return ({
|
|
|
1283
1282
|
},
|
|
1284
1283
|
}); });
|
|
1285
1284
|
|
|
1285
|
+
var OrderingAppContext = createContext(null);
|
|
1286
|
+
var useOrderingAppContext = function () {
|
|
1287
|
+
var context = useContext(OrderingAppContext);
|
|
1288
|
+
if (!context) {
|
|
1289
|
+
throw new Error('useOrderingAppContext has to be used within <OrderingAppContext.Provider>');
|
|
1290
|
+
}
|
|
1291
|
+
return context;
|
|
1292
|
+
};
|
|
1293
|
+
var OrderingAppContextProvider = function (props) {
|
|
1294
|
+
var context = useState(props.defaultContext);
|
|
1295
|
+
return React__default.createElement(OrderingAppContext.Provider, { value: context }, props.children);
|
|
1296
|
+
};
|
|
1297
|
+
|
|
1286
1298
|
var DishCheckoutCard = function (props) {
|
|
1287
|
-
var
|
|
1299
|
+
var _a;
|
|
1300
|
+
var id = props.id, name = props.name, quantity = props.quantity, modifiers = props.modifiers, onDelete = props.onDelete, onEdit = props.onEdit, onChange = props.onChange, price = props.price, specialInstructions = props.specialInstructions, disabled = props.disabled;
|
|
1288
1301
|
var classes = useDishCheckoutCardStyles(props);
|
|
1289
|
-
var
|
|
1302
|
+
var appContext = useOrderingAppContext()[0];
|
|
1303
|
+
var _b = useState(false), open = _b[0], setOpen = _b[1];
|
|
1304
|
+
var formattedPrice = typeof price === 'number' ? "" + ((_a = appContext.currencySymbol) !== null && _a !== void 0 ? _a : '') + price.toFixed(2) : price;
|
|
1290
1305
|
return (React__default.createElement(Box, { className: classes.root },
|
|
1291
1306
|
React__default.createElement(Box, { display: "flex", justifyContent: "space-between", gridGap: 3 },
|
|
1292
1307
|
React__default.createElement(Box, null,
|
|
@@ -1300,13 +1315,13 @@ var DishCheckoutCard = function (props) {
|
|
|
1300
1315
|
"\"",
|
|
1301
1316
|
specialInstructions,
|
|
1302
1317
|
"\"")),
|
|
1303
|
-
React__default.createElement(Box, { display: "flex", gridGap: 1, height: "100%" },
|
|
1304
|
-
React__default.createElement(Button$1, { className: classes.editButton, variant: "text", onClick: onEdit }, "Edit"),
|
|
1305
|
-
React__default.createElement(IconButton, { onClick: onDelete },
|
|
1306
|
-
React__default.createElement(Icon, { icon: SvgTrash,
|
|
1318
|
+
React__default.createElement(Box, { display: "flex", gridGap: 1, height: "100%", alignItems: "center" },
|
|
1319
|
+
React__default.createElement(Button$1, { disabled: disabled, className: classes.editButton, variant: "text", onClick: onEdit }, "Edit"),
|
|
1320
|
+
React__default.createElement(IconButton, { disabled: disabled, onClick: onDelete, classes: { root: classes.deleteButton } },
|
|
1321
|
+
React__default.createElement(Icon, { icon: SvgTrash, size: "large" })))),
|
|
1307
1322
|
React__default.createElement(Box, { display: "flex", gridGap: 16, alignItems: "center" },
|
|
1308
1323
|
React__default.createElement(FormControl, { variant: "outlined", hiddenLabel: true },
|
|
1309
|
-
React__default.createElement(Select, { open: open, value: quantity, labelId: "select-label-" + id, onClick: function () { return setOpen(!open); }, disableUnderline: true, onChange: function (event) { return onChange(id, event.target.value); }, fullWidth: true, startAdornment: React__default.createElement(InputAdornment, { position: "start" },
|
|
1324
|
+
React__default.createElement(Select, { disabled: disabled, open: open, value: quantity, labelId: "select-label-" + id, onClick: function () { return setOpen(!open); }, disableUnderline: true, onChange: function (event) { return onChange(id, event.target.value); }, fullWidth: true, startAdornment: React__default.createElement(InputAdornment, { position: "start" },
|
|
1310
1325
|
React__default.createElement(Icon, { icon: open ? SvgChevronUp : SvgChevronDown, size: "large" })), inputProps: { shrink: false }, MenuProps: {
|
|
1311
1326
|
disablePortal: true,
|
|
1312
1327
|
anchorOrigin: {
|
|
@@ -1320,7 +1335,7 @@ var DishCheckoutCard = function (props) {
|
|
|
1320
1335
|
getContentAnchorEl: null,
|
|
1321
1336
|
classes: { paper: classes.selectPaper },
|
|
1322
1337
|
}, className: classes.select }, Array.from({ length: 99 }, function (_, index) { return (React__default.createElement(MenuItem$1, { key: index + 1, value: index + 1 }, index + 1)); }))),
|
|
1323
|
-
React__default.createElement(Typography, { className: classes.price },
|
|
1338
|
+
React__default.createElement(Typography, { className: classes.price }, formattedPrice))));
|
|
1324
1339
|
};
|
|
1325
1340
|
|
|
1326
1341
|
var DishDetailsReview = forwardRef(function (props) {
|
|
@@ -1361,14 +1376,6 @@ var useDishModifierCardStyles = makeStyles(function (theme) { return ({
|
|
|
1361
1376
|
},
|
|
1362
1377
|
}); });
|
|
1363
1378
|
var useRadioModifierFormStyles = makeStyles(function (theme) { return ({
|
|
1364
|
-
root: {
|
|
1365
|
-
'& .MuiFormControlLabel-label': {
|
|
1366
|
-
margin: theme.spacing(0.5, 0),
|
|
1367
|
-
'& div p:nth-child(2)': {
|
|
1368
|
-
color: theme.palette.grey[700],
|
|
1369
|
-
},
|
|
1370
|
-
},
|
|
1371
|
-
},
|
|
1372
1379
|
radio: {
|
|
1373
1380
|
fontSize: theme.spacing(2),
|
|
1374
1381
|
padding: 'unset',
|
|
@@ -1379,14 +1386,6 @@ var useRadioModifierFormStyles = makeStyles(function (theme) { return ({
|
|
|
1379
1386
|
},
|
|
1380
1387
|
}); });
|
|
1381
1388
|
var useCheckboxModifierFormStyles = makeStyles(function (theme) { return ({
|
|
1382
|
-
root: {
|
|
1383
|
-
'& .MuiFormControlLabel-label': {
|
|
1384
|
-
margin: theme.spacing(0.5, 0),
|
|
1385
|
-
},
|
|
1386
|
-
'&:not(.Mui-disabled) div p:nth-child(2)': {
|
|
1387
|
-
color: theme.palette.grey[700],
|
|
1388
|
-
},
|
|
1389
|
-
},
|
|
1390
1389
|
radio: {
|
|
1391
1390
|
color: '#616161',
|
|
1392
1391
|
fontSize: theme.spacing(2),
|
|
@@ -1396,6 +1395,14 @@ var useCheckboxModifierFormStyles = makeStyles(function (theme) { return ({
|
|
|
1396
1395
|
color: theme.palette.info.main,
|
|
1397
1396
|
},
|
|
1398
1397
|
},
|
|
1398
|
+
}); });
|
|
1399
|
+
var useLabelStyles = makeStyles(function (theme) { return ({
|
|
1400
|
+
label: {
|
|
1401
|
+
margin: theme.spacing(0.5, 0),
|
|
1402
|
+
},
|
|
1403
|
+
price: {
|
|
1404
|
+
color: theme.palette.grey[700],
|
|
1405
|
+
},
|
|
1399
1406
|
}); });
|
|
1400
1407
|
|
|
1401
1408
|
var useStatusTagStyles = makeStyles(function (theme) { return ({
|
|
@@ -1499,29 +1506,17 @@ StatusTag.defaultProps = {
|
|
|
1499
1506
|
};
|
|
1500
1507
|
StatusTag.displayName = 'StatusTag';
|
|
1501
1508
|
|
|
1502
|
-
var OrderingAppContext = createContext(null);
|
|
1503
|
-
var useOrderingAppContext = function () {
|
|
1504
|
-
var context = useContext(OrderingAppContext);
|
|
1505
|
-
if (!context) {
|
|
1506
|
-
throw new Error('useOrderingAppContext has to be used within <OrderingAppContext.Provider>');
|
|
1507
|
-
}
|
|
1508
|
-
return context;
|
|
1509
|
-
};
|
|
1510
|
-
var OrderingAppContextProvider = function (props) {
|
|
1511
|
-
var context = useState(props.defaultContext);
|
|
1512
|
-
return React__default.createElement(OrderingAppContext.Provider, { value: context }, props.children);
|
|
1513
|
-
};
|
|
1514
|
-
|
|
1515
1509
|
var Label = function (props) {
|
|
1516
|
-
var name = props.name, price = props.price;
|
|
1517
|
-
|
|
1510
|
+
var name = props.name, price = props.price, disabled = props.disabled;
|
|
1511
|
+
var classes = useLabelStyles();
|
|
1512
|
+
return (React__default.createElement(Box, { display: "flex", flexDirection: "column", className: classes.label },
|
|
1518
1513
|
React__default.createElement(Typography$1, null, name),
|
|
1519
|
-
price && React__default.createElement(Typography$1,
|
|
1514
|
+
price && React__default.createElement(Typography$1, { className: !disabled ? classes.price : '' },
|
|
1520
1515
|
"+ ",
|
|
1521
1516
|
price)));
|
|
1522
1517
|
};
|
|
1523
1518
|
var CheckboxGroup = function (props) {
|
|
1524
|
-
var value = props.value, modifiers = props.modifiers, onChange = props.onChange, disableNewSelections = props.disableNewSelections;
|
|
1519
|
+
var value = props.value, modifiers = props.modifiers, onChange = props.onChange, disableNewSelections = props.disableNewSelections, isOutOfStock = props.isOutOfStock;
|
|
1525
1520
|
var classes = useCheckboxModifierFormStyles();
|
|
1526
1521
|
var appContext = useOrderingAppContext()[0];
|
|
1527
1522
|
var handleChange = function (event) {
|
|
@@ -1537,13 +1532,13 @@ var CheckboxGroup = function (props) {
|
|
|
1537
1532
|
};
|
|
1538
1533
|
return (React__default.createElement(Box, { display: "flex", flexDirection: "column" }, modifiers.map(function (modifier, index) {
|
|
1539
1534
|
var targetValue = value === null || value === void 0 ? void 0 : value.find(function (v) { return v.id == modifier.id; });
|
|
1540
|
-
return (React__default.createElement(FormControlLabel$1, { key: index, value: modifier.id, control: React__default.createElement(Checkbox$1, { className: classes.radio, disabled: !targetValue && disableNewSelections }), label: React__default.createElement(Label, { name: modifier.name, price: modifier.price
|
|
1535
|
+
return (React__default.createElement(FormControlLabel$1, { key: index, value: modifier.id, control: React__default.createElement(Checkbox$1, { className: classes.radio, disabled: (!targetValue && disableNewSelections) || isOutOfStock }), label: React__default.createElement(Label, { name: modifier.name, price: modifier.price
|
|
1541
1536
|
? "" + (appContext && appContext.currencySymbol) + Number(modifier.price).toFixed(2)
|
|
1542
|
-
: null }), className: classes.root, checked: !!targetValue, onChange: handleChange }));
|
|
1537
|
+
: null, disabled: isOutOfStock }), className: classes.root, checked: !!targetValue, onChange: handleChange }));
|
|
1543
1538
|
})));
|
|
1544
1539
|
};
|
|
1545
1540
|
var RadioGroup = function (props) {
|
|
1546
|
-
var value = props.value, modifiers = props.modifiers, onChange = props.onChange;
|
|
1541
|
+
var value = props.value, modifiers = props.modifiers, onChange = props.onChange, isOutOfStock = props.isOutOfStock;
|
|
1547
1542
|
var classes = useRadioModifierFormStyles();
|
|
1548
1543
|
var appContext = useOrderingAppContext()[0];
|
|
1549
1544
|
var handleChange = function (event) {
|
|
@@ -1557,16 +1552,16 @@ var RadioGroup = function (props) {
|
|
|
1557
1552
|
},
|
|
1558
1553
|
]);
|
|
1559
1554
|
};
|
|
1560
|
-
return (React__default.createElement(MuiRadioGroup, { name: "selectedModifiers", value: value ? value[0].id : '', onChange: handleChange }, modifiers.map(function (modifier, index) { return (React__default.createElement(FormControlLabel$1, { key: index, value: modifier.id, control: React__default.createElement(Radio$1, { className: classes.radio }), label: React__default.createElement(Label, { name: modifier.name, price: modifier.price ? "" + (appContext && appContext.currencySymbol) + Number(modifier.price).toFixed(2) : null
|
|
1555
|
+
return (React__default.createElement(MuiRadioGroup, { name: "selectedModifiers", value: value ? value[0].id : '', onChange: handleChange }, modifiers.map(function (modifier, index) { return (React__default.createElement(FormControlLabel$1, { key: index, value: modifier.id, control: React__default.createElement(Radio$1, { className: classes.radio, disabled: isOutOfStock }), label: React__default.createElement(Label, { name: modifier.name, price: modifier.price ? "" + (appContext && appContext.currencySymbol) + Number(modifier.price).toFixed(2) : null, disabled: isOutOfStock }) })); })));
|
|
1561
1556
|
};
|
|
1562
1557
|
|
|
1563
1558
|
var ModifierOptionsControl = function (props) {
|
|
1564
|
-
var type = props.type, modifiers = props.modifiers, value = props.value, onChange = props.onChange, disableNewSelections = props.disableNewSelections;
|
|
1559
|
+
var type = props.type, modifiers = props.modifiers, value = props.value, onChange = props.onChange, disableNewSelections = props.disableNewSelections, isOutOfStock = props.isOutOfStock;
|
|
1565
1560
|
switch (type) {
|
|
1566
1561
|
case 'singleSelect':
|
|
1567
|
-
return React__default.createElement(RadioGroup, { modifiers: modifiers, value: value, onChange: onChange });
|
|
1562
|
+
return React__default.createElement(RadioGroup, { modifiers: modifiers, value: value, onChange: onChange, isOutOfStock: isOutOfStock });
|
|
1568
1563
|
case 'multipleSelect':
|
|
1569
|
-
return (React__default.createElement(CheckboxGroup, { modifiers: modifiers, value: value, onChange: onChange, disableNewSelections: disableNewSelections }));
|
|
1564
|
+
return (React__default.createElement(CheckboxGroup, { modifiers: modifiers, value: value, onChange: onChange, disableNewSelections: disableNewSelections, isOutOfStock: isOutOfStock }));
|
|
1570
1565
|
default:
|
|
1571
1566
|
return null;
|
|
1572
1567
|
}
|
|
@@ -1585,10 +1580,12 @@ var DishModifierCard = function (props) {
|
|
|
1585
1580
|
}
|
|
1586
1581
|
var label = optionalText;
|
|
1587
1582
|
switch (true) {
|
|
1588
|
-
case isRequired:
|
|
1589
|
-
label = requiredText;
|
|
1590
1583
|
case isOutOfStock:
|
|
1591
1584
|
label = outOfStockText;
|
|
1585
|
+
break;
|
|
1586
|
+
case isRequired:
|
|
1587
|
+
label = requiredText;
|
|
1588
|
+
break;
|
|
1592
1589
|
}
|
|
1593
1590
|
return (React__default.createElement(Box, { className: classes.root },
|
|
1594
1591
|
React__default.createElement(Box, { display: "flex", justifyContent: "space-between", width: "100%", alignItems: "center", height: "fit-content" },
|
|
@@ -1599,7 +1596,7 @@ var DishModifierCard = function (props) {
|
|
|
1599
1596
|
React__default.createElement(Typography, { variant: "subtitle1", className: error ? classes.error : undefined }, helperText)),
|
|
1600
1597
|
React__default.createElement(Box, null,
|
|
1601
1598
|
React__default.createElement(FormControl, null,
|
|
1602
|
-
React__default.createElement(ModifierOptionsControl, { type: type, modifiers: modifiers, value: value, onChange: onChange, disableNewSelections: disableNewSelections })))));
|
|
1599
|
+
React__default.createElement(ModifierOptionsControl, { type: type, modifiers: modifiers, value: value, onChange: onChange, disableNewSelections: disableNewSelections, isOutOfStock: isOutOfStock })))));
|
|
1603
1600
|
};
|
|
1604
1601
|
DishModifierCard.displayName = 'DishModifierCard';
|
|
1605
1602
|
|
|
@@ -1974,6 +1971,8 @@ var MenuItemGroup = forwardRef(function (props, ref) {
|
|
|
1974
1971
|
});
|
|
1975
1972
|
MenuItemGroup.displayName = 'MenuItemGroup';
|
|
1976
1973
|
|
|
1974
|
+
var PageSection = function (props) { return (React__default.createElement(Box, { p: 4, borderBottom: "1px solid #E0E0E0" }, props.children)); };
|
|
1975
|
+
|
|
1977
1976
|
var palette = {
|
|
1978
1977
|
primary: {
|
|
1979
1978
|
light: '#7B7FA3',
|
|
@@ -2088,5 +2087,5 @@ var orderingTheme = {
|
|
|
2088
2087
|
props: props,
|
|
2089
2088
|
};
|
|
2090
2089
|
|
|
2091
|
-
export { Button$1 as Button, DishCheckoutCard, DishDetailsReview, DishModifierCard, ItemTag, ItemTagGroup, LocationCard, MenuDropdown, MenuFilter, MenuItem, MenuItemGroup, MenuSection, MenuSectionGroup, OrderingAppContext, OrderingAppContextProvider, QuantityPicker, ReactionCounter, ReactionCounterGroup, SelectableChip, SelectableChipGroup, SelectedMenuFiltersList, StatusTag, orderingTheme, useOrderingAppContext };
|
|
2090
|
+
export { Button$1 as Button, DishCheckoutCard, DishDetailsReview, DishModifierCard, ItemTag, ItemTagGroup, LocationCard, MenuDropdown, MenuFilter, MenuItem, MenuItemGroup, MenuSection, MenuSectionGroup, OrderingAppContext, OrderingAppContextProvider, PageSection, QuantityPicker, ReactionCounter, ReactionCounterGroup, SelectableChip, SelectableChipGroup, SelectedMenuFiltersList, StatusTag, orderingTheme, useOrderingAppContext };
|
|
2092
2091
|
//# sourceMappingURL=index.es.js.map
|