@popmenu/ordering-ui 0.102.0 → 0.103.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.
@@ -2,3 +2,4 @@ export declare const useDishModifierCardStyles: (props?: any) => import("@materi
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
4
  export declare const useLabelStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<string>;
5
+ export declare const useOptionsStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<string>;
@@ -3,6 +3,7 @@ export declare type ModifierValue = Pick<Modifier, 'id' | 'price'> & {
3
3
  };
4
4
  export declare type Modifier = {
5
5
  id: number;
6
+ hasModifiers: boolean;
6
7
  name: string;
7
8
  outOfStock: boolean;
8
9
  price: number;
@@ -44,10 +45,12 @@ export declare type DishModifierCardProps = {
44
45
  requiredText: string;
45
46
  helperText: string;
46
47
  };
48
+ /** Handles the dialog change for nested modifiers */
49
+ handleOptionsClick: (id: number) => void;
47
50
  };
48
51
  export declare type RadioModifierFormProps = Base;
49
52
  export declare type CheckboxModifierFormProps = Base & {
50
53
  disableNewSelections?: boolean;
51
54
  };
52
- export declare type ModifierOptionsControlProps = Pick<DishModifierCardProps, 'value' | 'modifiers' | 'isOutOfStock' | 'onChange' | 'disableNewSelections' | 'type' | 'messages'>;
55
+ export declare type ModifierOptionsControlProps = Pick<DishModifierCardProps, 'value' | 'modifiers' | 'isOutOfStock' | 'onChange' | 'disableNewSelections' | 'type' | 'messages' | 'handleOptionsClick'>;
53
56
  export {};
package/build/index.es.js CHANGED
@@ -228,6 +228,24 @@ function SvgChevronUp(props) {
228
228
  })));
229
229
  }
230
230
 
231
+ var _path$2m;
232
+
233
+ function _extends$5m() { _extends$5m = 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$5m.apply(this, arguments); }
234
+
235
+ function SvgChevronRight(props) {
236
+ return /*#__PURE__*/React.createElement("svg", _extends$5m({
237
+ viewBox: "0 0 16 16",
238
+ fill: "none",
239
+ strokeLinecap: "round",
240
+ strokeLinejoin: "round",
241
+ width: "1em",
242
+ height: "1em"
243
+ }, props), _path$2m || (_path$2m = /*#__PURE__*/React.createElement("path", {
244
+ d: "M6 12l4-4-4-4",
245
+ stroke: "currentColor"
246
+ })));
247
+ }
248
+
231
249
  var _path$27;
232
250
 
233
251
  function _extends$4K() { _extends$4K = 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$4K.apply(this, arguments); }
@@ -1669,6 +1687,11 @@ var useLabelStyles = makeStyles(function (theme) { return ({
1669
1687
  price: {
1670
1688
  color: theme.palette.grey[700],
1671
1689
  },
1690
+ }); });
1691
+ var useOptionsStyles = makeStyles(function (theme) { return ({
1692
+ options: {
1693
+ color: theme.palette.info.main,
1694
+ },
1672
1695
  }); });
1673
1696
 
1674
1697
  var useQuantityPickerStyles = makeStyles(function (theme) { return ({
@@ -1754,8 +1777,16 @@ var Label = function (props) {
1754
1777
  "+ ",
1755
1778
  price)));
1756
1779
  };
1780
+ var Options = function (props) {
1781
+ var handleOptionsClick = props.handleOptionsClick, modifierId = props.modifierId;
1782
+ var classes = useOptionsStyles();
1783
+ return (React__default.createElement(Box, { marginLeft: 3 },
1784
+ React__default.createElement(Button, { variation: "none", className: classes.options, onClick: function () { return handleOptionsClick(modifierId); } },
1785
+ React__default.createElement(Typography$1, { variant: "caption" }, "OPTIONS"),
1786
+ React__default.createElement(Icon, { icon: SvgChevronRight }))));
1787
+ };
1757
1788
  var SingleSelectModifierControl = function (props) {
1758
- var modifiers = props.modifiers, isOutOfStock = props.isOutOfStock, onChange = props.onChange, value = props.value, messages = props.messages;
1789
+ var modifiers = props.modifiers, isOutOfStock = props.isOutOfStock, onChange = props.onChange, value = props.value, messages = props.messages, handleOptionsClick = props.handleOptionsClick;
1759
1790
  var radioClasses = useRadioModifierFormStyles();
1760
1791
  var makeHandleChange = function (modifier) { return function (e) {
1761
1792
  onChange([
@@ -1769,11 +1800,13 @@ var SingleSelectModifierControl = function (props) {
1769
1800
  return (React__default.createElement(FormControl, { fullWidth: true },
1770
1801
  React__default.createElement(RadioGroup, null, modifiers.map(function (modifier) {
1771
1802
  var _a;
1772
- 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 }) }));
1803
+ return (React__default.createElement(Box, { key: modifier.id },
1804
+ 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 }) }),
1805
+ modifier.hasModifiers && React__default.createElement(Options, { handleOptionsClick: handleOptionsClick, modifierId: modifier.id })));
1773
1806
  }))));
1774
1807
  };
1775
1808
  var MultipleSelectControl = function (props) {
1776
- var modifiers = props.modifiers, value = props.value, isOutOfStock = props.isOutOfStock, onChange = props.onChange, messages = props.messages, disableNewSelections = props.disableNewSelections;
1809
+ var modifiers = props.modifiers, value = props.value, isOutOfStock = props.isOutOfStock, onChange = props.onChange, messages = props.messages, disableNewSelections = props.disableNewSelections, handleOptionsClick = props.handleOptionsClick;
1777
1810
  var classes = useCheckboxModifierFormStyles();
1778
1811
  var makeHandleChange = function (modifier) { return function () {
1779
1812
  var isModifierInValue = Boolean(value.find(function (v) { return v.id === modifier.id; }));
@@ -1785,7 +1818,11 @@ var MultipleSelectControl = function (props) {
1785
1818
  }
1786
1819
  }; };
1787
1820
  return (React__default.createElement(FormControl, { fullWidth: true },
1788
- 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 }) })); }))));
1821
+ React__default.createElement(FormGroup, null, modifiers.map(function (modifier) {
1822
+ return (React__default.createElement(Box, { key: modifier.id },
1823
+ 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 }) }),
1824
+ modifier.hasModifiers && React__default.createElement(Options, { handleOptionsClick: handleOptionsClick, modifierId: modifier.id })));
1825
+ }))));
1789
1826
  };
1790
1827
  var MultipleQuantitySelectControl = function (props) {
1791
1828
  var modifiers = props.modifiers, value = props.value, isOutOfStock = props.isOutOfStock, onChange = props.onChange, messages = props.messages, disableNewSelections = props.disableNewSelections;
@@ -1846,7 +1883,7 @@ var getStatusTagProps = function (props) {
1846
1883
  return { color: color, label: label, variant: variant };
1847
1884
  };
1848
1885
  var DishModifierCard = function (props) {
1849
- 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;
1886
+ 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, handleOptionsClick = props.handleOptionsClick;
1850
1887
  var classes = useDishModifierCardStyles();
1851
1888
  return (React__default.createElement(Box, { className: classes.root },
1852
1889
  React__default.createElement(Box, { display: "flex", justifyContent: "space-between", width: "100%", alignItems: "center", height: "fit-content", marginBottom: 2 },
@@ -1854,7 +1891,7 @@ var DishModifierCard = function (props) {
1854
1891
  !isOutOfStock && (React__default.createElement(Typography, { variant: "subtitle1", className: error ? classes.error : undefined }, messages.helperText))),
1855
1892
  React__default.createElement(Typography, { className: classes.name }, name),
1856
1893
  React__default.createElement(Box, null,
1857
- React__default.createElement(ModifierControls, { value: value, modifiers: modifiers, isOutOfStock: isOutOfStock, onChange: onChange, disableNewSelections: disableNewSelections, type: type, messages: messages }))));
1894
+ React__default.createElement(ModifierControls, { value: value, modifiers: modifiers, isOutOfStock: isOutOfStock, onChange: onChange, disableNewSelections: disableNewSelections, type: type, messages: messages, handleOptionsClick: handleOptionsClick }))));
1858
1895
  };
1859
1896
  DishModifierCard.displayName = 'DishModifierCard';
1860
1897