@popmenu/ordering-ui 0.89.1 → 0.91.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/components/DishCheckoutCard/DishCheckoutCardProps.d.ts +2 -0
- package/build/components/DishModifierCard/DishModifierCardProps.d.ts +18 -15
- package/build/components/DishModifierCard/ModifierControls.d.ts +3 -0
- package/build/components/MenuDropdown/MenuDropdownProps.d.ts +1 -0
- package/build/components/QuantityPicker/QuantityPicker.styles.d.ts +4 -1
- package/build/components/QuantityPicker/QuantityPickerProps.d.ts +10 -4
- package/build/index.es.js +211 -141
- package/build/index.es.js.map +1 -1
- package/build/index.js +207 -140
- package/build/index.js.map +1 -1
- package/package.json +2 -2
- package/build/components/DishModifierCard/ModifierOptionsControl.d.ts +0 -3
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
declare type ModifierValue = {
|
|
2
|
-
|
|
3
|
-
price?: number;
|
|
4
|
-
quantity?: number;
|
|
1
|
+
export declare type ModifierValue = Pick<Modifier, 'id' | 'price'> & {
|
|
2
|
+
quantity: number;
|
|
5
3
|
};
|
|
6
|
-
declare type Modifier = {
|
|
4
|
+
export declare type Modifier = {
|
|
7
5
|
id: number;
|
|
8
6
|
name: string;
|
|
9
7
|
outOfStock: boolean;
|
|
10
|
-
price
|
|
8
|
+
price: number;
|
|
9
|
+
formattedPrice: string;
|
|
10
|
+
quantity: number;
|
|
11
11
|
};
|
|
12
|
-
declare type OnChange = (value: Array<ModifierValue>, checked?: boolean) => void;
|
|
13
12
|
interface Base {
|
|
14
13
|
/** Modifier options */
|
|
15
14
|
modifiers: Array<Modifier>;
|
|
16
15
|
/** The values of the modifier form */
|
|
17
|
-
value: Array<ModifierValue
|
|
16
|
+
value: Array<ModifierValue>;
|
|
18
17
|
/** Handles the change event */
|
|
19
|
-
onChange:
|
|
18
|
+
onChange: (value: Array<ModifierValue>) => void;
|
|
20
19
|
isOutOfStock: boolean;
|
|
21
20
|
}
|
|
22
|
-
export declare type DishModifierCardProps =
|
|
21
|
+
export declare type DishModifierCardProps = {
|
|
22
|
+
/** Modifier options */
|
|
23
|
+
modifiers: Array<Modifier>;
|
|
24
|
+
/** The values of the modifier form */
|
|
25
|
+
value: Array<ModifierValue>;
|
|
26
|
+
/** Handles the change event */
|
|
27
|
+
onChange: (value: Array<ModifierValue>) => void;
|
|
23
28
|
/** Name of the modifier */
|
|
24
29
|
name: string;
|
|
25
30
|
/** Denotes the max amount of selections have been reached */
|
|
@@ -30,7 +35,8 @@ export declare type DishModifierCardProps = Base & {
|
|
|
30
35
|
isRequired: boolean;
|
|
31
36
|
/** Denotes if modifier is out of stock */
|
|
32
37
|
isOutOfStock: boolean;
|
|
33
|
-
type
|
|
38
|
+
/** Selection type for modifier group */
|
|
39
|
+
type: 'singleSelect' | 'multipleSelect' | 'multipleQuantitySelect';
|
|
34
40
|
/** Renders the text of the dish modifiers */
|
|
35
41
|
messages: {
|
|
36
42
|
optionalText: string;
|
|
@@ -43,8 +49,5 @@ export declare type RadioModifierFormProps = Base;
|
|
|
43
49
|
export declare type CheckboxModifierFormProps = Base & {
|
|
44
50
|
disableNewSelections?: boolean;
|
|
45
51
|
};
|
|
46
|
-
export declare type ModifierOptionsControlProps =
|
|
47
|
-
disableNewSelections?: boolean;
|
|
48
|
-
type: 'singleSelect' | 'multipleSelect';
|
|
49
|
-
};
|
|
52
|
+
export declare type ModifierOptionsControlProps = Pick<DishModifierCardProps, 'value' | 'modifiers' | 'isOutOfStock' | 'onChange' | 'disableNewSelections' | 'type' | 'messages'>;
|
|
50
53
|
export {};
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { QuantityPickerProps } from './QuantityPickerProps';
|
|
1
2
|
export declare const useQuantityPickerStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<"root">;
|
|
2
|
-
export declare const useQuantityInputStyles: (props
|
|
3
|
+
export declare const useQuantityInputStyles: (props: QuantityPickerProps) => import("@material-ui/styles").ClassNameMap<string>;
|
|
4
|
+
export declare const useStartAdornmentStyles: (props: QuantityPickerProps) => import("@material-ui/styles").ClassNameMap<string>;
|
|
5
|
+
export declare const useEndAdornmentStyles: (props: QuantityPickerProps) => import("@material-ui/styles").ClassNameMap<string>;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import React, { ChangeEvent } from 'react';
|
|
1
2
|
export declare type QuantityChangeEvent = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
3
|
+
quantity: number;
|
|
4
|
+
reason: string;
|
|
5
5
|
};
|
|
6
6
|
export interface QuantityPickerProps {
|
|
7
7
|
/** Callback for when the quantity is increased or decreased for the parent form */
|
|
8
|
-
onChange: (event:
|
|
8
|
+
onChange: (event: ChangeEvent<HTMLInputElement> | React.MouseEvent<HTMLButtonElement, MouseEvent>, customEvent: QuantityChangeEvent) => void;
|
|
9
9
|
/** the quantity represented by the picker */
|
|
10
10
|
value: number;
|
|
11
11
|
/** determines if picker is active */
|
|
12
12
|
disabled?: boolean;
|
|
13
|
+
/** limits the quantity picker from increasing the value */
|
|
14
|
+
disableIncrement?: boolean;
|
|
15
|
+
/** prevents a uer from typing a new value, forcing them to use the increment/decrement buttons */
|
|
16
|
+
preventManualChange?: boolean;
|
|
17
|
+
/** indicates how the quantity picker will be used and changes styles accordingly */
|
|
18
|
+
variation: 'itemCount' | 'modifierCount';
|
|
13
19
|
}
|
package/build/index.es.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Button as Button$
|
|
1
|
+
import { Button as Button$1, 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, TextField, RadioGroup, FormControlLabel as FormControlLabel$1, Radio as Radio$2, FormGroup, Checkbox as Checkbox$2, Menu, Tabs, Chip, DialogTitle as DialogTitle$1, IconButton as IconButton$1, withStyles, Switch as Switch$2 } from '@material-ui/core';
|
|
2
2
|
export * from '@material-ui/core';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import React__default, { forwardRef, createElement, createContext, useContext, useState } from 'react';
|
|
5
|
-
import { makeStyles,
|
|
5
|
+
import { makeStyles, lighten } from '@material-ui/core/styles';
|
|
6
6
|
import '@material-ui/lab/Alert';
|
|
7
7
|
import '@material-ui/core/AppBar';
|
|
8
8
|
import MuiAvatar from '@material-ui/core/Avatar';
|
|
9
9
|
import '@material-ui/core/Badge';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
10
|
+
import '@material-ui/core/Button';
|
|
11
|
+
import '@material-ui/core/CircularProgress';
|
|
12
12
|
import '@material-ui/core/ButtonGroup';
|
|
13
13
|
import Card$1 from '@material-ui/core/Card';
|
|
14
14
|
import CardActionArea$1 from '@material-ui/core/CardActionArea';
|
|
@@ -48,7 +48,6 @@ import MuiToggleButton from '@material-ui/lab/ToggleButton';
|
|
|
48
48
|
import MuiToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup';
|
|
49
49
|
import MuiTooltip from '@material-ui/core/Tooltip';
|
|
50
50
|
import { Skeleton } from '@material-ui/lab';
|
|
51
|
-
import MuiRadioGroup from '@material-ui/core/RadioGroup';
|
|
52
51
|
|
|
53
52
|
/*! *****************************************************************************
|
|
54
53
|
Copyright (c) Microsoft Corporation.
|
|
@@ -86,9 +85,19 @@ function __rest$1(s, e) {
|
|
|
86
85
|
t[p[i]] = s[p[i]];
|
|
87
86
|
}
|
|
88
87
|
return t;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function __spreadArray(to, from, pack) {
|
|
91
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
92
|
+
if (ar || !(i in from)) {
|
|
93
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
94
|
+
ar[i] = from[i];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return to.concat(ar || from);
|
|
89
98
|
}
|
|
90
99
|
|
|
91
|
-
var Button
|
|
100
|
+
var Button = forwardRef(function (props, ref) {
|
|
92
101
|
var _a = props.variation, variation = _a === void 0 ? 'primary' : _a, muiProps = __rest$1(props, ["variation"]);
|
|
93
102
|
var variationProps = {};
|
|
94
103
|
switch (variation) {
|
|
@@ -101,9 +110,9 @@ var Button$1 = forwardRef(function (props, ref) {
|
|
|
101
110
|
variationProps.color = 'primary';
|
|
102
111
|
break;
|
|
103
112
|
}
|
|
104
|
-
return React__default.createElement(Button$
|
|
113
|
+
return React__default.createElement(Button$1, __assign$1({}, variationProps, muiProps, { ref: ref }));
|
|
105
114
|
});
|
|
106
|
-
Button
|
|
115
|
+
Button.displayName = 'Button';
|
|
107
116
|
|
|
108
117
|
var useDishCardStyles = makeStyles(function (theme) {
|
|
109
118
|
var _a, _b;
|
|
@@ -431,6 +440,24 @@ function SvgTag(props) {
|
|
|
431
440
|
})));
|
|
432
441
|
}
|
|
433
442
|
|
|
443
|
+
var _path$K;
|
|
444
|
+
|
|
445
|
+
function _extends$1I() { _extends$1I = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1I.apply(this, arguments); }
|
|
446
|
+
|
|
447
|
+
function SvgWarning(props) {
|
|
448
|
+
return /*#__PURE__*/React.createElement("svg", _extends$1I({
|
|
449
|
+
viewBox: "0 0 16 16",
|
|
450
|
+
fill: "none",
|
|
451
|
+
strokeLinecap: "round",
|
|
452
|
+
strokeLinejoin: "round",
|
|
453
|
+
width: "1em",
|
|
454
|
+
height: "1em"
|
|
455
|
+
}, props), _path$K || (_path$K = /*#__PURE__*/React.createElement("path", {
|
|
456
|
+
d: "M6.86 2.573L1.213 12a1.334 1.334 0 001.14 2h11.294a1.332 1.332 0 001.14-2L9.14 2.573a1.333 1.333 0 00-2.28 0v0zM8 6v2.667m0 2.667h.007",
|
|
457
|
+
stroke: "currentColor"
|
|
458
|
+
})));
|
|
459
|
+
}
|
|
460
|
+
|
|
434
461
|
var _path$z;
|
|
435
462
|
|
|
436
463
|
function _extends$1o() { _extends$1o = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1o.apply(this, arguments); }
|
|
@@ -746,7 +773,7 @@ makeStyles(function (theme) { return ({
|
|
|
746
773
|
},
|
|
747
774
|
}); });
|
|
748
775
|
|
|
749
|
-
|
|
776
|
+
makeStyles(function () { return ({
|
|
750
777
|
root: {
|
|
751
778
|
minWidth: 'unset',
|
|
752
779
|
},
|
|
@@ -758,19 +785,6 @@ var useButtonStyles = makeStyles(function () { return ({
|
|
|
758
785
|
},
|
|
759
786
|
}); });
|
|
760
787
|
|
|
761
|
-
var Button = forwardRef(function (props, ref) {
|
|
762
|
-
props.textTransform; var loading = props.loading, classesOverride = props.classes, className = props.className, muiProps = __rest(props, ["textTransform", "loading", "classes", "className"]);
|
|
763
|
-
props.classes; var styleProps = __rest(props, ["classes"]);
|
|
764
|
-
var classes = useButtonStyles(styleProps);
|
|
765
|
-
var typography = useTheme().typography;
|
|
766
|
-
var loadingIndicator = {
|
|
767
|
-
startIcon: React__default.createElement(CircularProgress, { color: "inherit", size: typography.button.fontSize }),
|
|
768
|
-
disabled: true,
|
|
769
|
-
};
|
|
770
|
-
return (React__default.createElement(MuiButton, __assign({ ref: ref, classes: __assign(__assign({}, classes), classesOverride), className: classNames$1([className, 'pm-button']) }, muiProps, (loading && loadingIndicator))));
|
|
771
|
-
});
|
|
772
|
-
Button.displayName = 'Button';
|
|
773
|
-
|
|
774
788
|
var Checkbox$1 = forwardRef(function (props, ref) {
|
|
775
789
|
var label = props.label, disabled = props.disabled, LabelProps = props.LabelProps, muiProps = __rest(props, ["label", "disabled", "LabelProps"]);
|
|
776
790
|
var control = React__default.createElement(MuiCheckbox, __assign({ disabled: label ? undefined : disabled }, muiProps));
|
|
@@ -925,12 +939,12 @@ var useTypographyStyles = makeStyles(function (theme) {
|
|
|
925
939
|
});
|
|
926
940
|
});
|
|
927
941
|
|
|
928
|
-
var Typography =
|
|
929
|
-
props.weight; props.color; var restProps = __rest(props, ["weight", "color"]);
|
|
942
|
+
var Typography = function (props) {
|
|
943
|
+
props.weight; props.color; var TypographyRef = props.TypographyRef, restProps = __rest(props, ["weight", "color", "TypographyRef"]);
|
|
930
944
|
var classes = useTypographyStyles(__assign({}, props));
|
|
931
945
|
var variantMapping = { subtitle1: 'p' };
|
|
932
|
-
return React__default.createElement(Typography$1, __assign({
|
|
933
|
-
}
|
|
946
|
+
return React__default.createElement(Typography$1, __assign({ classes: classes, variantMapping: variantMapping, ref: TypographyRef }, restProps));
|
|
947
|
+
};
|
|
934
948
|
Typography.displayName = 'Typography';
|
|
935
949
|
Typography.defaultProps = defaultTypographyProps;
|
|
936
950
|
|
|
@@ -1457,6 +1471,11 @@ var useDishCheckoutCardStyles = makeStyles(function (theme) { return ({
|
|
|
1457
1471
|
selectPaper: {
|
|
1458
1472
|
maxHeight: theme.spacing(37),
|
|
1459
1473
|
},
|
|
1474
|
+
warning: {
|
|
1475
|
+
color: theme.palette.error.main,
|
|
1476
|
+
display: 'flex',
|
|
1477
|
+
gridGap: theme.spacing(0.825),
|
|
1478
|
+
},
|
|
1460
1479
|
}); });
|
|
1461
1480
|
|
|
1462
1481
|
var OrderingAppContext = createContext(null);
|
|
@@ -1474,7 +1493,7 @@ var OrderingAppContextProvider = function (props) {
|
|
|
1474
1493
|
|
|
1475
1494
|
var DishCheckoutCard = function (props) {
|
|
1476
1495
|
var _a;
|
|
1477
|
-
var id = props.id, name = props.name, quantity = props.quantity, modifiers = props.modifiers, onDelete = props.onDelete, onEdit = props.onEdit, onQuantityChange = props.onQuantityChange, price = props.price, specialInstructions = props.specialInstructions, disabled = props.disabled;
|
|
1496
|
+
var id = props.id, name = props.name, quantity = props.quantity, modifiers = props.modifiers, onDelete = props.onDelete, onEdit = props.onEdit, onQuantityChange = props.onQuantityChange, price = props.price, specialInstructions = props.specialInstructions, disabled = props.disabled, warningMessage = props.warningMessage;
|
|
1478
1497
|
var classes = useDishCheckoutCardStyles(props);
|
|
1479
1498
|
var appContext = useOrderingAppContext()[0];
|
|
1480
1499
|
var _b = useState(false), open = _b[0], setOpen = _b[1];
|
|
@@ -1496,7 +1515,7 @@ var DishCheckoutCard = function (props) {
|
|
|
1496
1515
|
specialInstructions,
|
|
1497
1516
|
"\"")),
|
|
1498
1517
|
React__default.createElement(Box, { display: "flex", gridGap: 1, height: "100%", alignItems: "center" },
|
|
1499
|
-
React__default.createElement(Button
|
|
1518
|
+
React__default.createElement(Button, { disabled: disabled, className: classes.editButton, variant: "text", onClick: onEdit }, "Edit"),
|
|
1500
1519
|
React__default.createElement(IconButton, { disabled: disabled, onClick: onDelete, classes: { root: classes.deleteButton } },
|
|
1501
1520
|
React__default.createElement(Icon, { icon: SvgTrash, size: "large" })))),
|
|
1502
1521
|
React__default.createElement(Box, { display: "flex", gridGap: 16, alignItems: "center" },
|
|
@@ -1515,7 +1534,11 @@ var DishCheckoutCard = function (props) {
|
|
|
1515
1534
|
getContentAnchorEl: null,
|
|
1516
1535
|
classes: { paper: classes.selectPaper },
|
|
1517
1536
|
}, className: classes.select }, Array.from({ length: 99 }, function (_, index) { return (React__default.createElement(MenuItem$1, { key: index + 1, value: index + 1 }, index + 1)); }))),
|
|
1518
|
-
React__default.createElement(Typography, { className: classes.price }, formattedPrice))
|
|
1537
|
+
React__default.createElement(Typography, { className: classes.price }, formattedPrice)),
|
|
1538
|
+
warningMessage && (React__default.createElement(Box, { className: classes.warning },
|
|
1539
|
+
React__default.createElement(Box, { paddingTop: 0.25 },
|
|
1540
|
+
React__default.createElement(Icon, { icon: SvgWarning, size: "medium" })),
|
|
1541
|
+
React__default.createElement(Typography, { variant: "body2" }, warningMessage)))));
|
|
1519
1542
|
};
|
|
1520
1543
|
|
|
1521
1544
|
var DishDetailsReview = forwardRef(function (props) {
|
|
@@ -1581,98 +1604,190 @@ var useLabelStyles = makeStyles(function (theme) { return ({
|
|
|
1581
1604
|
},
|
|
1582
1605
|
}); });
|
|
1583
1606
|
|
|
1607
|
+
var useQuantityPickerStyles = makeStyles(function (theme) { return ({
|
|
1608
|
+
root: {
|
|
1609
|
+
height: theme.spacing(7),
|
|
1610
|
+
backgroundColor: 'none',
|
|
1611
|
+
},
|
|
1612
|
+
}); });
|
|
1613
|
+
var useQuantityInputStyles = makeStyles(function (theme) { return ({
|
|
1614
|
+
root: {
|
|
1615
|
+
height: '100%',
|
|
1616
|
+
width: 'min-content',
|
|
1617
|
+
borderRadius: theme.spacing(12.5),
|
|
1618
|
+
background: function (props) { return (props.variation === 'modifierCount' ? 'unset' : theme.palette.grey[100]); },
|
|
1619
|
+
},
|
|
1620
|
+
input: {
|
|
1621
|
+
'&::-webkit-clear-button, &::-webkit-outer-spin-button, &::-webkit-inner-spin-button': {
|
|
1622
|
+
display: 'none',
|
|
1623
|
+
},
|
|
1624
|
+
'-moz-appearance': 'textfield',
|
|
1625
|
+
fontWeight: 600,
|
|
1626
|
+
padding: 0,
|
|
1627
|
+
textAlign: 'center',
|
|
1628
|
+
zIndex: function (props) { return (props.value === 0 && props.variation === 'modifierCount' ? -1 : 1); },
|
|
1629
|
+
backgroundColor: function (props) { return (props.variation === 'modifierCount' ? theme.palette.grey[100] : 'unset'); },
|
|
1630
|
+
alignSelf: function (props) { return (props.variation === 'modifierCount' ? 'stretch' : 'unset'); },
|
|
1631
|
+
height: function (props) { return (props.variation === 'modifierCount' ? 'auto' : 'unset'); },
|
|
1632
|
+
minWidth: function (props) { return (props.variation === 'modifierCount' ? theme.spacing(5) : theme.spacing(2.75)); },
|
|
1633
|
+
borderRadius: function (props) { return (props.variation === 'modifierCount' ? theme.spacing(1) : 'unset'); },
|
|
1634
|
+
margin: function (props) { return (props.variation === 'modifierCount' ? theme.spacing(0.5, 0) : 0); },
|
|
1635
|
+
},
|
|
1636
|
+
}); });
|
|
1637
|
+
var useStartAdornmentStyles = makeStyles(function (theme) { return ({
|
|
1638
|
+
root: {
|
|
1639
|
+
color: theme.palette.text.primary,
|
|
1640
|
+
zIndex: function (props) { return (props.value === 0 && props.variation === 'modifierCount' ? -1 : 1); },
|
|
1641
|
+
},
|
|
1642
|
+
}); });
|
|
1643
|
+
var useEndAdornmentStyles = makeStyles(function (theme) { return ({
|
|
1644
|
+
root: {
|
|
1645
|
+
color: theme.palette.text.primary,
|
|
1646
|
+
},
|
|
1647
|
+
}); });
|
|
1648
|
+
|
|
1649
|
+
var QuantityPicker = function (props) {
|
|
1650
|
+
var value = props.value, onChange = props.onChange, disabled = props.disabled, disableIncrement = props.disableIncrement, preventManualChange = props.preventManualChange, variation = props.variation;
|
|
1651
|
+
var fieldClasses = useQuantityPickerStyles();
|
|
1652
|
+
var inputClasses = useQuantityInputStyles(props);
|
|
1653
|
+
var startAdornmentClasses = useStartAdornmentStyles(props);
|
|
1654
|
+
var endAdornmentClasses = useEndAdornmentStyles(props);
|
|
1655
|
+
var onIncrement = function (event) {
|
|
1656
|
+
onChange(event, { quantity: value + 1, reason: 'increment' });
|
|
1657
|
+
};
|
|
1658
|
+
var onDecrement = function (event) {
|
|
1659
|
+
onChange(event, { quantity: value - 1, reason: 'decrement' });
|
|
1660
|
+
};
|
|
1661
|
+
var handleChange = function (event) {
|
|
1662
|
+
if (preventManualChange) {
|
|
1663
|
+
event.preventDefault();
|
|
1664
|
+
}
|
|
1665
|
+
if (!preventManualChange) {
|
|
1666
|
+
onChange(event, { quantity: parseInt(event.target.value), reason: 'change' });
|
|
1667
|
+
}
|
|
1668
|
+
};
|
|
1669
|
+
return (React__default.createElement(TextField, { classes: fieldClasses, type: "number", variant: variation === 'itemCount' ? 'filled' : 'standard', defaultValue: value, value: value, disabled: disabled, onChange: handleChange, InputProps: {
|
|
1670
|
+
classes: inputClasses,
|
|
1671
|
+
disableUnderline: true,
|
|
1672
|
+
endAdornment: (React__default.createElement(IconButton, { className: endAdornmentClasses.root, color: "default", tabIndex: -1, onClick: onIncrement, disabled: disabled || disableIncrement },
|
|
1673
|
+
React__default.createElement(Icon, { icon: SvgPlusCircle }))),
|
|
1674
|
+
startAdornment: (React__default.createElement(IconButton, { className: startAdornmentClasses.root, color: "default", tabIndex: -1, onClick: onDecrement, disabled: disabled || value <= 0 },
|
|
1675
|
+
React__default.createElement(Icon, { icon: SvgMinusCircle }))),
|
|
1676
|
+
} }));
|
|
1677
|
+
};
|
|
1678
|
+
|
|
1584
1679
|
var Label = function (props) {
|
|
1585
|
-
var name = props.name, price = props.price,
|
|
1680
|
+
var name = props.name, price = props.price, outOfStock = props.outOfStock, messages = props.messages;
|
|
1586
1681
|
var classes = useLabelStyles();
|
|
1587
1682
|
return (React__default.createElement(Box, { display: "flex", flexDirection: "column", className: classes.label },
|
|
1588
1683
|
React__default.createElement(Box, { display: "flex", alignItems: "center", gridGap: 8 },
|
|
1589
1684
|
React__default.createElement(Typography$1, null, name),
|
|
1590
|
-
|
|
1591
|
-
price && React__default.createElement(Typography$1,
|
|
1685
|
+
outOfStock && (React__default.createElement(Typography$1, { variant: "caption", className: classes.outOfStock }, messages.outOfStockText))),
|
|
1686
|
+
price && React__default.createElement(Typography$1, null,
|
|
1592
1687
|
"+ ",
|
|
1593
1688
|
price)));
|
|
1594
1689
|
};
|
|
1595
|
-
var
|
|
1596
|
-
var
|
|
1597
|
-
var
|
|
1598
|
-
var
|
|
1599
|
-
var handleChange = function (event) {
|
|
1600
|
-
var _a;
|
|
1601
|
-
var price = (_a = modifiers.find(function (modifier) { return modifier.id === parseInt(event.target.value); })) === null || _a === void 0 ? void 0 : _a.price;
|
|
1690
|
+
var SingleSelectModifierControl = function (props) {
|
|
1691
|
+
var modifiers = props.modifiers, isOutOfStock = props.isOutOfStock, onChange = props.onChange, value = props.value, messages = props.messages;
|
|
1692
|
+
var radioClasses = useRadioModifierFormStyles();
|
|
1693
|
+
var makeHandleChange = function (modifier) { return function (e) {
|
|
1602
1694
|
onChange([
|
|
1603
1695
|
{
|
|
1604
|
-
id:
|
|
1605
|
-
price:
|
|
1606
|
-
quantity: 1,
|
|
1607
|
-
},
|
|
1608
|
-
], event.target.checked);
|
|
1609
|
-
};
|
|
1610
|
-
return (React__default.createElement(Box, { display: "flex", flexDirection: "column" }, modifiers.map(function (modifier, index) {
|
|
1611
|
-
var targetValue = value === null || value === void 0 ? void 0 : value.find(function (v) { return v.id == modifier.id; });
|
|
1612
|
-
return (React__default.createElement(FormControlLabel$1, { key: index, value: modifier.id, control: React__default.createElement(Checkbox$2, { className: classes.radio, disabled: (!targetValue && disableNewSelections) || isOutOfStock || modifier.outOfStock }), label: React__default.createElement(Label, { name: modifier.name, price: modifier.price
|
|
1613
|
-
? "" + (appContext && appContext.currencySymbol) + Number(modifier.price).toFixed(2)
|
|
1614
|
-
: null, disabled: isOutOfStock || modifier.outOfStock, isOutOfStock: isOutOfStock }), className: classes.root, checked: !!targetValue, onChange: handleChange }));
|
|
1615
|
-
})));
|
|
1616
|
-
};
|
|
1617
|
-
var RadioGroup = function (props) {
|
|
1618
|
-
var value = props.value, modifiers = props.modifiers, onChange = props.onChange, isOutOfStock = props.isOutOfStock;
|
|
1619
|
-
var classes = useRadioModifierFormStyles();
|
|
1620
|
-
var appContext = useOrderingAppContext()[0];
|
|
1621
|
-
var handleChange = function (event) {
|
|
1622
|
-
var _a;
|
|
1623
|
-
var price = (_a = modifiers.find(function (modifier) { return modifier.id === parseInt(event.target.value); })) === null || _a === void 0 ? void 0 : _a.price;
|
|
1624
|
-
onChange([
|
|
1625
|
-
{
|
|
1626
|
-
id: parseInt(event.target.value),
|
|
1627
|
-
price: (price && parseInt(price)) || 0,
|
|
1696
|
+
id: Number(e.target.value),
|
|
1697
|
+
price: modifier.price,
|
|
1628
1698
|
quantity: 1,
|
|
1629
1699
|
},
|
|
1630
1700
|
]);
|
|
1631
|
-
};
|
|
1632
|
-
return (React__default.createElement(
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1701
|
+
}; };
|
|
1702
|
+
return (React__default.createElement(FormControl, { fullWidth: true },
|
|
1703
|
+
React__default.createElement(RadioGroup, null, modifiers.map(function (modifier) {
|
|
1704
|
+
var _a;
|
|
1705
|
+
return (React__default.createElement(FormControlLabel$1, { key: modifier.id, value: modifier.id, control: React__default.createElement(Radio$2, { checked: ((_a = value[0]) === null || _a === void 0 ? void 0 : _a.id) === modifier.id, className: radioClasses.radio, disabled: isOutOfStock || modifier.outOfStock, onChange: makeHandleChange(modifier) }), label: React__default.createElement(Label, { messages: messages, name: modifier.name, price: modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock, outOfStock: isOutOfStock }) }));
|
|
1706
|
+
}))));
|
|
1707
|
+
};
|
|
1708
|
+
var MultipleSelectControl = function (props) {
|
|
1709
|
+
var modifiers = props.modifiers, value = props.value, isOutOfStock = props.isOutOfStock, onChange = props.onChange, messages = props.messages, disableNewSelections = props.disableNewSelections;
|
|
1710
|
+
var classes = useCheckboxModifierFormStyles();
|
|
1711
|
+
var makeHandleChange = function (modifier) { return function () {
|
|
1712
|
+
var isModifierInValue = Boolean(value.find(function (v) { return v.id === modifier.id; }));
|
|
1713
|
+
if (isModifierInValue) {
|
|
1714
|
+
onChange(value.filter(function (v) { return v.id !== modifier.id; }));
|
|
1715
|
+
}
|
|
1716
|
+
else {
|
|
1717
|
+
onChange(__spreadArray(__spreadArray([], value), [{ id: modifier.id, price: modifier.price || 0, quantity: 1 }]));
|
|
1718
|
+
}
|
|
1719
|
+
}; };
|
|
1720
|
+
return (React__default.createElement(FormControl, { fullWidth: true },
|
|
1721
|
+
React__default.createElement(FormGroup, null, modifiers.map(function (modifier) { return (React__default.createElement(FormControlLabel$1, { key: modifier.id, value: modifier.id, className: classes.root, checked: value.some(function (v) { return v.id === modifier.id; }), onChange: makeHandleChange(modifier), control: React__default.createElement(Checkbox$2, { className: classes.radio, disabled: isOutOfStock || modifier.outOfStock || (!modifier.quantity && disableNewSelections) }), label: React__default.createElement(Label, { messages: messages, name: modifier.name, price: modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock, outOfStock: isOutOfStock }) })); }))));
|
|
1722
|
+
};
|
|
1723
|
+
var MultipleQuantitySelectControl = function (props) {
|
|
1724
|
+
var modifiers = props.modifiers, value = props.value, isOutOfStock = props.isOutOfStock, onChange = props.onChange, messages = props.messages, disableNewSelections = props.disableNewSelections;
|
|
1725
|
+
var makeHandleChange = function (modifier) { return function (_e, customEvent) {
|
|
1726
|
+
var isModifierInValue = Boolean(value.find(function (v) { return v.id === modifier.id; }));
|
|
1727
|
+
var isQuantityZero = customEvent.quantity === 0;
|
|
1728
|
+
var shouldRemoveModifierFromValue = isModifierInValue && isQuantityZero;
|
|
1729
|
+
var shouldAddModifierToValue = !isModifierInValue && !isQuantityZero;
|
|
1730
|
+
var shouldUpdateModifierInValue = isModifierInValue && !isQuantityZero;
|
|
1731
|
+
if (shouldRemoveModifierFromValue) {
|
|
1732
|
+
onChange(value.filter(function (v) { return v.id !== modifier.id; }));
|
|
1733
|
+
}
|
|
1734
|
+
if (shouldAddModifierToValue) {
|
|
1735
|
+
onChange(__spreadArray(__spreadArray([], value), [{ id: modifier.id, price: modifier.price, quantity: customEvent.quantity }]));
|
|
1736
|
+
}
|
|
1737
|
+
if (shouldUpdateModifierInValue) {
|
|
1738
|
+
onChange(value.map(function (val) { return (val.id === modifier.id ? __assign$1(__assign$1({}, val), { quantity: customEvent.quantity }) : val); }));
|
|
1739
|
+
}
|
|
1740
|
+
}; };
|
|
1741
|
+
return (React__default.createElement(FormControl, { fullWidth: true },
|
|
1742
|
+
React__default.createElement(FormGroup, null, modifiers.map(function (modifier) { return (React__default.createElement(Box, { key: modifier.id, style: { justifyContent: 'space-between' }, display: "flex" },
|
|
1743
|
+
React__default.createElement(Label, { messages: messages, name: modifier.name, price: modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock, outOfStock: isOutOfStock }),
|
|
1744
|
+
React__default.createElement(QuantityPicker, { variation: "modifierCount", value: modifier.quantity, disableIncrement: disableNewSelections, preventManualChange: true, onChange: makeHandleChange(modifier) }))); }))));
|
|
1745
|
+
};
|
|
1746
|
+
var ModifierControls = function (props) {
|
|
1747
|
+
switch (props.type) {
|
|
1638
1748
|
case 'singleSelect':
|
|
1639
|
-
return React__default.createElement(
|
|
1749
|
+
return React__default.createElement(SingleSelectModifierControl, __assign$1({}, props));
|
|
1640
1750
|
case 'multipleSelect':
|
|
1641
|
-
return
|
|
1751
|
+
return React__default.createElement(MultipleSelectControl, __assign$1({}, props));
|
|
1752
|
+
case 'multipleQuantitySelect':
|
|
1753
|
+
return React__default.createElement(MultipleQuantitySelectControl, __assign$1({}, props));
|
|
1642
1754
|
default:
|
|
1643
1755
|
return null;
|
|
1644
1756
|
}
|
|
1645
1757
|
};
|
|
1646
1758
|
|
|
1647
|
-
var
|
|
1648
|
-
var
|
|
1649
|
-
var optionalText = messages.optionalText, outOfStockText = messages.outOfStockText, requiredText = messages.requiredText
|
|
1650
|
-
var isFullyOutOfStock = isOutOfStock || !modifiers.some(function (modifier) { return !modifier.outOfStock; });
|
|
1651
|
-
var classes = useDishModifierCardStyles();
|
|
1759
|
+
var getStatusTagProps = function (props) {
|
|
1760
|
+
var messages = props.messages, error = props.error, isRequired = props.isRequired, isOutOfStock = props.isOutOfStock;
|
|
1761
|
+
var optionalText = messages.optionalText, outOfStockText = messages.outOfStockText, requiredText = messages.requiredText;
|
|
1652
1762
|
var color = 'default';
|
|
1653
1763
|
switch (true) {
|
|
1654
1764
|
case error:
|
|
1655
1765
|
color = 'error';
|
|
1656
|
-
case
|
|
1766
|
+
case isOutOfStock:
|
|
1657
1767
|
color = 'warning';
|
|
1658
1768
|
}
|
|
1659
1769
|
var label = optionalText;
|
|
1660
1770
|
switch (true) {
|
|
1661
|
-
case
|
|
1771
|
+
case isOutOfStock:
|
|
1662
1772
|
label = outOfStockText;
|
|
1663
1773
|
break;
|
|
1664
1774
|
case isRequired:
|
|
1665
1775
|
label = requiredText;
|
|
1666
1776
|
break;
|
|
1667
1777
|
}
|
|
1778
|
+
var variant = isRequired || isOutOfStock ? 'outlined' : 'filled';
|
|
1779
|
+
return { color: color, label: label, variant: variant };
|
|
1780
|
+
};
|
|
1781
|
+
var DishModifierCard = function (props) {
|
|
1782
|
+
var name = props.name, disableNewSelections = props.disableNewSelections, modifiers = props.modifiers, value = props.value, messages = props.messages, onChange = props.onChange, type = props.type, error = props.error, isOutOfStock = props.isOutOfStock;
|
|
1783
|
+
var classes = useDishModifierCardStyles();
|
|
1668
1784
|
return (React__default.createElement(Box, { className: classes.root },
|
|
1669
1785
|
React__default.createElement(Box, { display: "flex", justifyContent: "space-between", width: "100%", alignItems: "center", height: "fit-content", marginBottom: 2 },
|
|
1670
|
-
React__default.createElement(StatusTag, {
|
|
1671
|
-
!
|
|
1786
|
+
React__default.createElement(StatusTag, __assign$1({}, getStatusTagProps(props))),
|
|
1787
|
+
!isOutOfStock && (React__default.createElement(Typography, { variant: "subtitle1", className: error ? classes.error : undefined }, messages.helperText))),
|
|
1672
1788
|
React__default.createElement(Typography, { className: classes.name }, name),
|
|
1673
1789
|
React__default.createElement(Box, null,
|
|
1674
|
-
React__default.createElement(
|
|
1675
|
-
React__default.createElement(ModifierOptionsControl, { type: type, modifiers: modifiers, value: value, onChange: onChange, disableNewSelections: disableNewSelections, isOutOfStock: isFullyOutOfStock })))));
|
|
1790
|
+
React__default.createElement(ModifierControls, { value: value, modifiers: modifiers, isOutOfStock: isOutOfStock, onChange: onChange, disableNewSelections: disableNewSelections, type: type, messages: messages }))));
|
|
1676
1791
|
};
|
|
1677
1792
|
DishModifierCard.displayName = 'DishModifierCard';
|
|
1678
1793
|
|
|
@@ -1792,6 +1907,11 @@ var useMenuDropdownStyles = makeStyles(function (theme) {
|
|
|
1792
1907
|
alignSelf: 'start',
|
|
1793
1908
|
},
|
|
1794
1909
|
_a),
|
|
1910
|
+
menuItem: {
|
|
1911
|
+
alignItems: 'center',
|
|
1912
|
+
display: 'flex',
|
|
1913
|
+
gridGap: theme.spacing(1),
|
|
1914
|
+
},
|
|
1795
1915
|
select: {
|
|
1796
1916
|
'& .MuiSelect-root': {
|
|
1797
1917
|
color: '#212121',
|
|
@@ -1799,6 +1919,9 @@ var useMenuDropdownStyles = makeStyles(function (theme) {
|
|
|
1799
1919
|
zIndex: 10,
|
|
1800
1920
|
},
|
|
1801
1921
|
},
|
|
1922
|
+
unavailable: {
|
|
1923
|
+
color: theme.palette.grey[700],
|
|
1924
|
+
},
|
|
1802
1925
|
});
|
|
1803
1926
|
});
|
|
1804
1927
|
|
|
@@ -1820,7 +1943,9 @@ var MenuDropdown = function (props) {
|
|
|
1820
1943
|
horizontal: 'left',
|
|
1821
1944
|
},
|
|
1822
1945
|
getContentAnchorEl: null,
|
|
1823
|
-
}, className: classes.select }, menuOptions.map(function (option, index) { return (React__default.createElement(MenuItem$1, { key: index, value: option.id
|
|
1946
|
+
}, className: classes.select, renderValue: function (selected) { var _a; return (_a = menuOptions.find(function (menuOption) { return menuOption.id === selected; })) === null || _a === void 0 ? void 0 : _a.name; } }, menuOptions.map(function (option, index) { return (React__default.createElement(MenuItem$1, { key: index, value: option.id, className: classNames(classes.menuItem, option.isUnavailable ? classes.unavailable : '') },
|
|
1947
|
+
option.name,
|
|
1948
|
+
option.isUnavailable && React__default.createElement(Icon, { icon: SvgClock, size: "large" }))); }))));
|
|
1824
1949
|
};
|
|
1825
1950
|
|
|
1826
1951
|
var useMenuFilterStyles = makeStyles(function (theme) { return ({
|
|
@@ -1869,7 +1994,7 @@ var MenuFilter = function (props) {
|
|
|
1869
1994
|
setAnchorEl(null);
|
|
1870
1995
|
};
|
|
1871
1996
|
return (React__default.createElement(React__default.Fragment, null,
|
|
1872
|
-
React__default.createElement(Button$
|
|
1997
|
+
React__default.createElement(Button$1, { id: triggerId, "aria-controls": popoverId, "aria-haspopup": "true", "aria-expanded": open, onClick: handleTriggerClick, size: "small", startIcon: React__default.createElement(SvgLeafIcon, null), classes: { label: classes.triggerLabel } }, triggerLabel),
|
|
1873
1998
|
React__default.createElement(Menu, { id: popoverId, anchorEl: anchorEl, open: open, onClose: handleClose },
|
|
1874
1999
|
availableFilters.map(function (option, index) {
|
|
1875
2000
|
return (React__default.createElement(MenuItem$1, { key: index, value: option.id, onClick: function (event) { return handleChange(option, event); } },
|
|
@@ -1882,61 +2007,6 @@ var MenuFilter = function (props) {
|
|
|
1882
2007
|
React__default.createElement(Typography, { variant: "body1", color: "grey.500" }, noOptionsLabel)))))));
|
|
1883
2008
|
};
|
|
1884
2009
|
|
|
1885
|
-
var useQuantityPickerStyles = makeStyles(function (theme) { return ({
|
|
1886
|
-
root: {
|
|
1887
|
-
height: theme.spacing(7),
|
|
1888
|
-
},
|
|
1889
|
-
}); });
|
|
1890
|
-
var useQuantityInputStyles = makeStyles(function (theme) { return ({
|
|
1891
|
-
root: {
|
|
1892
|
-
height: '100%',
|
|
1893
|
-
width: 'min-content',
|
|
1894
|
-
borderRadius: theme.spacing(12.5),
|
|
1895
|
-
background: theme.palette.grey[100],
|
|
1896
|
-
},
|
|
1897
|
-
input: {
|
|
1898
|
-
'&::-webkit-clear-button, &::-webkit-outer-spin-button, &::-webkit-inner-spin-button': {
|
|
1899
|
-
display: 'none',
|
|
1900
|
-
},
|
|
1901
|
-
'-moz-appearance': 'textfield',
|
|
1902
|
-
fontWeight: 600,
|
|
1903
|
-
minWidth: theme.spacing(2.75),
|
|
1904
|
-
padding: 0,
|
|
1905
|
-
textAlign: 'center',
|
|
1906
|
-
position: 'relative',
|
|
1907
|
-
left: 1,
|
|
1908
|
-
},
|
|
1909
|
-
adornedStart: {
|
|
1910
|
-
padding: theme.spacing(0.25),
|
|
1911
|
-
},
|
|
1912
|
-
adornedEnd: {
|
|
1913
|
-
padding: theme.spacing(0.5),
|
|
1914
|
-
},
|
|
1915
|
-
}); });
|
|
1916
|
-
|
|
1917
|
-
var QuantityPicker = function (props) {
|
|
1918
|
-
var value = props.value, onChange = props.onChange, disabled = props.disabled;
|
|
1919
|
-
var fieldClasses = useQuantityPickerStyles();
|
|
1920
|
-
var inputClasses = useQuantityInputStyles();
|
|
1921
|
-
var onIncrement = function () {
|
|
1922
|
-
onChange({ target: { value: value + 1 } }, 'increment');
|
|
1923
|
-
};
|
|
1924
|
-
var onDecrement = function () {
|
|
1925
|
-
onChange({ target: { value: value - 1 } }, 'decrement');
|
|
1926
|
-
};
|
|
1927
|
-
var handleChange = function (event) {
|
|
1928
|
-
onChange({ target: { value: parseInt(event.target.value) } }, 'change');
|
|
1929
|
-
};
|
|
1930
|
-
return (React__default.createElement(TextField, { classes: __assign$1({}, fieldClasses), variant: "filled", type: "number", defaultValue: value, value: value, disabled: disabled, onChange: handleChange, InputProps: {
|
|
1931
|
-
classes: __assign$1({}, inputClasses),
|
|
1932
|
-
disableUnderline: true,
|
|
1933
|
-
endAdornment: (React__default.createElement(IconButton, { color: "default", tabIndex: -1, onClick: onIncrement, disabled: disabled },
|
|
1934
|
-
React__default.createElement(Icon, { icon: SvgPlusCircle }))),
|
|
1935
|
-
startAdornment: (React__default.createElement(IconButton, { color: "default", tabIndex: -1, onClick: onDecrement, disabled: disabled },
|
|
1936
|
-
React__default.createElement(Icon, { icon: SvgMinusCircle }))),
|
|
1937
|
-
} }));
|
|
1938
|
-
};
|
|
1939
|
-
|
|
1940
2010
|
var useSelectableChipStyles = makeStyles(function (theme) { return ({
|
|
1941
2011
|
root: {
|
|
1942
2012
|
border: '2px solid',
|
|
@@ -2294,5 +2364,5 @@ var orderingTheme = {
|
|
|
2294
2364
|
props: props,
|
|
2295
2365
|
};
|
|
2296
2366
|
|
|
2297
|
-
export { Button
|
|
2367
|
+
export { Button, Checkbox, DialogSection, DialogTitle, DishCheckoutCard, DishDetailsReview, DishModifierCard, ItemTag, ItemTagGroup, LocationCard, MenuDropdown, MenuFilter, MenuItem, MenuItemGroup, MenuSection, MenuSectionGroup, OrderingAppContext, OrderingAppContextProvider, PageSection, QuantityPicker, Radio, ReactionCounter, ReactionCounterGroup, SelectableChip, SelectableChipGroup, SelectedMenuFiltersList, StatusTag, Switch, orderingTheme, useOrderingAppContext };
|
|
2298
2368
|
//# sourceMappingURL=index.es.js.map
|