@popmenu/ordering-ui 0.116.0 → 0.117.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.
@@ -8,7 +8,7 @@ export interface DishCheckoutCardProps {
8
8
  /** Dish image information */
9
9
  image: {
10
10
  alt?: string;
11
- src?: string;
11
+ src?: string | null;
12
12
  };
13
13
  /** disables all interactive elements in the card, like "edit" or "delete" */
14
14
  disabled?: boolean;
@@ -57,10 +57,15 @@ export declare type DishModifierCardProps = {
57
57
  };
58
58
  /** Handles the dialog change for nested modifiers */
59
59
  handleOptionsClick: (id: number) => void;
60
+ /** Used by parent modifier quantity tracking: parent modifier quantity denotes requiredSelectionCount and currentSelectionCount is the total quantity of the child modifier */
61
+ selectionQuantity: Record<number, {
62
+ requiredSelectionCount: number;
63
+ currentSelectionCount: number;
64
+ }>;
60
65
  };
61
66
  export declare type RadioModifierFormProps = Base;
62
67
  export declare type CheckboxModifierFormProps = Base & {
63
68
  disableNewSelections?: boolean;
64
69
  };
65
- export declare type ModifierOptionsControlProps = Pick<DishModifierCardProps, 'value' | 'modifiers' | 'isOutOfStock' | 'onChange' | 'disableNewSelections' | 'type' | 'messages' | 'handleOptionsClick' | 'aggregatePrice'>;
70
+ export declare type ModifierOptionsControlProps = Pick<DishModifierCardProps, 'value' | 'modifiers' | 'isOutOfStock' | 'onChange' | 'disableNewSelections' | 'type' | 'messages' | 'handleOptionsClick' | 'aggregatePrice' | 'selectionQuantity'>;
66
71
  export {};
package/build/index.es.js CHANGED
@@ -1549,6 +1549,7 @@ var useDishCheckoutCardStyles = makeStyles(function (theme) { return ({
1549
1549
  height: theme.spacing(7),
1550
1550
  marginRight: theme.spacing(1),
1551
1551
  overflow: 'hidden',
1552
+ width: theme.spacing(7),
1552
1553
  },
1553
1554
  name: {
1554
1555
  fontSize: 16,
@@ -1909,7 +1910,7 @@ var MultipleSelectControl = function (props) {
1909
1910
  }))));
1910
1911
  };
1911
1912
  var MultipleQuantitySelectControl = function (props) {
1912
- var modifiers = props.modifiers, isOutOfStock = props.isOutOfStock, onChange = props.onChange, disableNewSelections = props.disableNewSelections;
1913
+ var modifiers = props.modifiers, isOutOfStock = props.isOutOfStock, onChange = props.onChange, disableNewSelections = props.disableNewSelections, handleOptionsClick = props.handleOptionsClick, selectionQuantity = props.selectionQuantity;
1913
1914
  var makeHandleChange = function (modifier) { return function (_e, customEvent) {
1914
1915
  onChange({
1915
1916
  isRadio: false,
@@ -1921,12 +1922,22 @@ var MultipleQuantitySelectControl = function (props) {
1921
1922
  });
1922
1923
  }; };
1923
1924
  return (React__default.createElement(FormControl, { fullWidth: true },
1924
- React__default.createElement(FormGroup, null, modifiers.map(function (modifier) { return (React__default.createElement(Box, { key: modifier.id, style: { justifyContent: 'space-between', alignItems: 'center' }, display: "flex" },
1925
+ React__default.createElement(FormGroup, null, modifiers.map(function (modifier) { return (React__default.createElement(Box, { key: modifier.id, style: { justifyContent: 'space-between', flexDirection: 'column' }, display: "flex" },
1925
1926
  React__default.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%" },
1926
1927
  React__default.createElement(Label, { name: modifier.name, price: modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock }),
1927
1928
  modifier.outOfStock && (React__default.createElement(Box, { minWidth: "90px", marginLeft: 2 },
1928
1929
  React__default.createElement(StatusTag, { color: "warning", label: "Out of stock", variant: "outlined", size: "md" }))),
1929
- !modifier.outOfStock && (React__default.createElement(QuantityPicker, { variation: "modifierCount", value: modifier.quantity, disableIncrement: disableNewSelections, preventManualChange: true, onChange: makeHandleChange(modifier), disabled: isOutOfStock || modifier.outOfStock }))))); }))));
1930
+ !modifier.outOfStock && (React__default.createElement(QuantityPicker, { variation: "modifierCount", value: modifier.quantity, disableIncrement: disableNewSelections, preventManualChange: true, onChange: makeHandleChange(modifier), disabled: isOutOfStock || modifier.outOfStock }))),
1931
+ React__default.createElement(Box, { display: "flex", alignItems: "flex-start", gridGap: 4 },
1932
+ modifier.hasModifiers && !modifier.outOfStock && (React__default.createElement(Options, { handleOptionsClick: function () { return handleOptionsClick(modifier.id); } })),
1933
+ selectionQuantity[modifier.id] &&
1934
+ selectionQuantity[modifier.id].requiredSelectionCount > 0 &&
1935
+ selectionQuantity[modifier.id].requiredSelectionCount !==
1936
+ selectionQuantity[modifier.id].currentSelectionCount && (React__default.createElement(Typography$1, { variant: "caption", color: "error" },
1937
+ selectionQuantity[modifier.id].currentSelectionCount,
1938
+ "/",
1939
+ selectionQuantity[modifier.id].requiredSelectionCount,
1940
+ " selected"))))); }))));
1930
1941
  };
1931
1942
  var ModifierControls = function (props) {
1932
1943
  switch (props.type) {
@@ -1964,7 +1975,7 @@ var getStatusTagProps = function (props) {
1964
1975
  return { color: color, label: label, variant: variant };
1965
1976
  };
1966
1977
  var DishModifierCard = function (props) {
1967
- var aggregatePrice = props.aggregatePrice, 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;
1978
+ var aggregatePrice = props.aggregatePrice, 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, selectionQuantity = props.selectionQuantity;
1968
1979
  var classes = useDishModifierCardStyles();
1969
1980
  return (React__default.createElement(Box, { className: classes.root },
1970
1981
  React__default.createElement(Box, { display: "flex", justifyContent: "space-between", width: "100%", alignItems: "center", height: "fit-content", marginBottom: 2 },
@@ -1972,7 +1983,7 @@ var DishModifierCard = function (props) {
1972
1983
  !isOutOfStock && (React__default.createElement(Typography, { variant: "subtitle1", className: error ? classes.error : undefined }, messages.helperText))),
1973
1984
  React__default.createElement(Typography, { className: classes.name }, name),
1974
1985
  React__default.createElement(Box, null,
1975
- React__default.createElement(ModifierControls, { value: value, modifiers: modifiers, isOutOfStock: isOutOfStock, onChange: onChange, disableNewSelections: disableNewSelections, type: type, messages: messages, handleOptionsClick: handleOptionsClick, aggregatePrice: aggregatePrice }))));
1986
+ React__default.createElement(ModifierControls, { value: value, modifiers: modifiers, isOutOfStock: isOutOfStock, onChange: onChange, disableNewSelections: disableNewSelections, type: type, messages: messages, handleOptionsClick: handleOptionsClick, aggregatePrice: aggregatePrice, selectionQuantity: selectionQuantity }))));
1976
1987
  };
1977
1988
  DishModifierCard.displayName = 'DishModifierCard';
1978
1989