@popmenu/ordering-ui 0.113.2 → 0.113.5

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.
@@ -4,7 +4,7 @@ export declare type ModifierValue = {
4
4
  parentModifierId?: number | null;
5
5
  price: number;
6
6
  quantity: number;
7
- isRadio: boolean;
7
+ isRadio?: boolean;
8
8
  };
9
9
  export declare type Modifier = {
10
10
  id: number;
@@ -1,7 +1,5 @@
1
1
  import { HTMLAttributes, PropsWithChildren } from 'react';
2
2
  export interface ItemTagProps extends PropsWithChildren<HTMLAttributes<HTMLElement>> {
3
- /** Sets the border-color and text-color for an ItemTag. */
4
- color?: string;
5
3
  /** sets alt for Avatar component */
6
4
  alt?: string;
7
5
  }
@@ -1,2 +1 @@
1
- import { ItemTagProps } from './ItemTagProps';
2
- export declare const useItemtagStyles: (props: ItemTagProps) => import("@material-ui/styles").ClassNameMap<string>;
1
+ export declare const useItemTagStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<"root" | "text">;
@@ -6,9 +6,12 @@ export declare type MenuFilterOption = {
6
6
  name: string;
7
7
  };
8
8
  export declare type MenuFilterChangeHandler = (value: MenuFilterOption, event: React.MouseEvent<HTMLElement>) => void;
9
+ export declare type MenuFilterClearHandler = () => void;
9
10
  export interface MenuFilterProps {
10
11
  /** Callback for setting menu filters */
11
12
  onChange: MenuFilterChangeHandler;
13
+ /** Callback for setting menu filters */
14
+ onClear: MenuFilterClearHandler;
12
15
  /** options to set menu filter with */
13
16
  options: MenuFilterOption[];
14
17
  /** selected options to set menu filter with */
package/build/index.es.js CHANGED
@@ -456,24 +456,6 @@ function SvgPlusCircle(props) {
456
456
  })))));
457
457
  }
458
458
 
459
- var _path$1E;
460
-
461
- function _extends$3N() { _extends$3N = 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$3N.apply(this, arguments); }
462
-
463
- function SvgTag(props) {
464
- return /*#__PURE__*/React.createElement("svg", _extends$3N({
465
- viewBox: "0 0 16 16",
466
- fill: "none",
467
- strokeLinecap: "round",
468
- strokeLinejoin: "round",
469
- width: "1em",
470
- height: "1em"
471
- }, props), _path$1E || (_path$1E = /*#__PURE__*/React.createElement("path", {
472
- d: "M13.727 8.94l-4.78 4.78a1.334 1.334 0 01-1.887 0L1.333 8V1.333H8l5.727 5.727a1.333 1.333 0 010 1.88v0zm-9.06-4.273h.007",
473
- stroke: "currentColor"
474
- })));
475
- }
476
-
477
459
  var _path$1u;
478
460
 
479
461
  function _extends$3u() { _extends$3u = 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$3u.apply(this, arguments); }
@@ -1368,23 +1350,16 @@ var MenuItemPrice = function (props) {
1368
1350
  React__default.createElement(Typography$1, null, props.price)));
1369
1351
  };
1370
1352
 
1371
- var useItemtagStyles = makeStyles(function (theme) { return ({
1372
- root: function (_a) {
1373
- var _b, _c;
1374
- var _d = _a.color, color = _d === void 0 ? '' : _d;
1375
- var _e = color.split('.'), colorGroup = _e[0], colorVariant = _e[1];
1376
- return {
1377
- // @ts-expect-error - todo.
1378
- color: ((_b = theme.palette[colorGroup]) === null || _b === void 0 ? void 0 : _b[colorVariant]) || color,
1379
- // @ts-expect-error - todo.
1380
- borderColor: ((_c = theme.palette[colorGroup]) === null || _c === void 0 ? void 0 : _c[colorVariant]) || color,
1381
- border: '1.5px solid',
1382
- background: 'none',
1383
- height: '24px',
1384
- lineHeight: 1.5,
1385
- position: 'static',
1386
- width: '24px',
1387
- };
1353
+ var useItemTagStyles = makeStyles(function (theme) { return ({
1354
+ root: {
1355
+ color: theme.palette.text.primary,
1356
+ borderColor: theme.palette.text.primary,
1357
+ border: '1.5px solid',
1358
+ background: 'none',
1359
+ height: '24px',
1360
+ lineHeight: 1.5,
1361
+ position: 'static',
1362
+ width: '24px',
1388
1363
  },
1389
1364
  text: {
1390
1365
  lineHeight: 1.5,
@@ -1392,11 +1367,12 @@ var useItemtagStyles = makeStyles(function (theme) { return ({
1392
1367
  }); });
1393
1368
 
1394
1369
  var ItemTag = forwardRef(function (props, ref) {
1395
- var _a = props.color, color = _a === void 0 ? 'gray.dark' : _a, alt = props.alt, children = props.children;
1396
- var classes = useItemtagStyles({ color: color });
1370
+ var alt = props.alt, children = props.children;
1371
+ var classes = useItemTagStyles();
1397
1372
  return (React__default.createElement(Avatar$1, { ref: ref, alt: alt, classes: { root: classes.root } },
1398
1373
  React__default.createElement(Typography, { variant: "caption", className: classes.text }, children)));
1399
- });
1374
+ });
1375
+ ItemTag.displayName = 'ItemTag';
1400
1376
 
1401
1377
  var ItemTagGroup = function (props) {
1402
1378
  var children = props.children;
@@ -1703,6 +1679,11 @@ var useDishModifierCardStyles = makeStyles(function (theme) { return ({
1703
1679
  },
1704
1680
  }); });
1705
1681
  var useRadioModifierFormStyles = makeStyles(function (theme) { return ({
1682
+ label: {
1683
+ alignItems: 'center',
1684
+ display: 'flex',
1685
+ justifyContent: 'space-between',
1686
+ },
1706
1687
  radio: {
1707
1688
  fontSize: theme.spacing(2),
1708
1689
  padding: 'unset',
@@ -1711,14 +1692,25 @@ var useRadioModifierFormStyles = makeStyles(function (theme) { return ({
1711
1692
  color: theme.palette.info.main,
1712
1693
  },
1713
1694
  },
1695
+ hideRadio: {
1696
+ display: 'none',
1697
+ },
1714
1698
  root: {
1715
1699
  justifyContent: 'space-between',
1716
1700
  margin: 0,
1717
1701
  width: 'fill-available',
1702
+ '& > :last-child': {
1703
+ flex: 1,
1704
+ },
1718
1705
  },
1719
1706
  }); });
1720
1707
  var useCheckboxModifierFormStyles = makeStyles(function (theme) { return ({
1721
- radio: {
1708
+ label: {
1709
+ alignItems: 'center',
1710
+ display: 'flex',
1711
+ justifyContent: 'space-between',
1712
+ },
1713
+ checkbox: {
1722
1714
  color: '#616161',
1723
1715
  fontSize: theme.spacing(2),
1724
1716
  marginRight: theme.spacing(-0.25),
@@ -1727,18 +1719,23 @@ var useCheckboxModifierFormStyles = makeStyles(function (theme) { return ({
1727
1719
  color: theme.palette.info.main,
1728
1720
  },
1729
1721
  },
1722
+ hideCheckbox: {
1723
+ display: 'none',
1724
+ },
1730
1725
  root: {
1731
- justifyContent: 'space-between',
1732
1726
  margin: 0,
1733
1727
  width: 'fill-available',
1728
+ '& > :last-child': {
1729
+ flex: 1,
1730
+ },
1734
1731
  },
1735
1732
  }); });
1736
1733
  var useLabelStyles = makeStyles(function (theme) { return ({
1737
1734
  label: {
1738
1735
  margin: theme.spacing(0.5, 0),
1739
1736
  },
1740
- outOfStock: {
1741
- color: theme.palette.warning.dark,
1737
+ disabled: {
1738
+ color: theme.palette.grey[500],
1742
1739
  },
1743
1740
  price: {
1744
1741
  color: theme.palette.grey[700],
@@ -1823,15 +1820,15 @@ var QuantityPicker = function (props) {
1823
1820
  };
1824
1821
 
1825
1822
  var Label = function (props) {
1826
- var name = props.name, price = props.price, outOfStock = props.outOfStock, messages = props.messages;
1823
+ var _a, _b, _c;
1824
+ var name = props.name, price = props.price, _d = props.disabled, disabled = _d === void 0 ? false : _d;
1827
1825
  var classes = useLabelStyles();
1828
1826
  return (React__default.createElement(Box, { display: "flex", flexDirection: "column", className: classes.label },
1829
1827
  React__default.createElement(Box, { display: "flex", alignItems: "center", gridGap: 8 },
1830
- React__default.createElement(Typography$1, null, name),
1831
- outOfStock && (React__default.createElement(Typography$1, { variant: "caption", className: classes.outOfStock }, messages.outOfStockText))),
1832
- price && React__default.createElement(Typography$1, null,
1828
+ React__default.createElement(Typography$1, { className: classNames((_a = {}, _a[classes.disabled] = disabled, _a)) }, name)),
1829
+ price && (React__default.createElement(Typography$1, { className: classNames((_b = {}, _b[classes.price] = !disabled, _b), (_c = {}, _c[classes.disabled] = disabled, _c)) },
1833
1830
  "+ ",
1834
- price)));
1831
+ price))));
1835
1832
  };
1836
1833
  var Options = function (props) {
1837
1834
  var handleOptionsClick = props.handleOptionsClick, modifierId = props.modifierId;
@@ -1842,7 +1839,7 @@ var Options = function (props) {
1842
1839
  React__default.createElement(Icon, { icon: SvgChevronRight }))));
1843
1840
  };
1844
1841
  var SingleSelectModifierControl = function (props) {
1845
- var modifiers = props.modifiers, isOutOfStock = props.isOutOfStock, onChange = props.onChange, value = props.value, messages = props.messages, handleOptionsClick = props.handleOptionsClick;
1842
+ var modifiers = props.modifiers, isOutOfStock = props.isOutOfStock, onChange = props.onChange, value = props.value, handleOptionsClick = props.handleOptionsClick;
1846
1843
  var radioClasses = useRadioModifierFormStyles();
1847
1844
  var makeHandleChange = function (modifier) { return function (e) {
1848
1845
  onChange({
@@ -1856,14 +1853,18 @@ var SingleSelectModifierControl = function (props) {
1856
1853
  }; };
1857
1854
  return (React__default.createElement(FormControl, { fullWidth: true },
1858
1855
  React__default.createElement(RadioGroup, null, modifiers.map(function (modifier) {
1859
- var _a;
1856
+ var _a, _b;
1857
+ var _c;
1860
1858
  return (React__default.createElement(Box, { key: modifier.id },
1861
- React__default.createElement(FormControlLabel$1, { key: modifier.id, value: modifier.id, className: radioClasses.root, control: React__default.createElement(Radio$2, { checked: ((_a = value[0]) === null || _a === void 0 ? void 0 : _a.modifierId) === 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 }), labelPlacement: "start" }),
1859
+ React__default.createElement(FormControlLabel$1, { key: modifier.id, value: modifier.id, className: radioClasses.root, control: React__default.createElement(Radio$2, { checked: ((_c = value[0]) === null || _c === void 0 ? void 0 : _c.modifierId) === modifier.id, className: classNames((_a = {}, _a[radioClasses.hideRadio] = modifier.outOfStock, _a), (_b = {}, _b[radioClasses.radio] = !modifier.outOfStock, _b)), disabled: isOutOfStock || modifier.outOfStock, onChange: makeHandleChange(modifier) }), label: React__default.createElement(Box, { className: radioClasses.label },
1860
+ React__default.createElement(Label, { name: modifier.name, price: modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock }),
1861
+ modifier.outOfStock && (React__default.createElement(Box, { minWidth: "90px", marginLeft: 2 },
1862
+ React__default.createElement(StatusTag, { color: "warning", label: "Out of stock", variant: "outlined", size: "md" })))), labelPlacement: "start" }),
1862
1863
  modifier.hasModifiers && React__default.createElement(Options, { handleOptionsClick: handleOptionsClick, modifierId: modifier.id })));
1863
1864
  }))));
1864
1865
  };
1865
1866
  var MultipleSelectControl = function (props) {
1866
- var modifiers = props.modifiers, value = props.value, isOutOfStock = props.isOutOfStock, onChange = props.onChange, messages = props.messages, disableNewSelections = props.disableNewSelections, handleOptionsClick = props.handleOptionsClick;
1867
+ var modifiers = props.modifiers, value = props.value, isOutOfStock = props.isOutOfStock, onChange = props.onChange, disableNewSelections = props.disableNewSelections, handleOptionsClick = props.handleOptionsClick;
1867
1868
  var classes = useCheckboxModifierFormStyles();
1868
1869
  var makeHandleChange = function (modifier) { return function () {
1869
1870
  var isModifierInValue = Boolean(value.find(function (v) { return v.modifierId === modifier.id; }));
@@ -1878,13 +1879,17 @@ var MultipleSelectControl = function (props) {
1878
1879
  }; };
1879
1880
  return (React__default.createElement(FormControl, { fullWidth: true },
1880
1881
  React__default.createElement(FormGroup, null, modifiers.map(function (modifier) {
1882
+ var _a, _b;
1881
1883
  return (React__default.createElement(Box, { key: modifier.id },
1882
- React__default.createElement(FormControlLabel$1, { key: modifier.id, value: modifier.id, className: classes.root, checked: value.some(function (v) { return v.modifierId === 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 }), labelPlacement: "start" }),
1884
+ React__default.createElement(FormControlLabel$1, { key: modifier.id, value: modifier.id, className: classes.root, checked: value.some(function (v) { return v.modifierId === modifier.id; }), onChange: makeHandleChange(modifier), control: React__default.createElement(Checkbox$2, { className: classNames((_a = {}, _a[classes.hideCheckbox] = modifier.outOfStock, _a), (_b = {}, _b[classes.checkbox] = !modifier.outOfStock, _b)), disabled: isOutOfStock || modifier.outOfStock || (!modifier.quantity && disableNewSelections) }), label: React__default.createElement(Box, { className: classes.label },
1885
+ React__default.createElement(Label, { name: modifier.name, price: modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock }),
1886
+ modifier.outOfStock && (React__default.createElement(Box, { minWidth: "90px", marginLeft: 2 },
1887
+ React__default.createElement(StatusTag, { color: "warning", label: "Out of stock", variant: "outlined", size: "md" })))), labelPlacement: "start" }),
1883
1888
  modifier.hasModifiers && React__default.createElement(Options, { handleOptionsClick: handleOptionsClick, modifierId: modifier.id })));
1884
1889
  }))));
1885
1890
  };
1886
1891
  var MultipleQuantitySelectControl = function (props) {
1887
- var modifiers = props.modifiers, isOutOfStock = props.isOutOfStock, onChange = props.onChange, messages = props.messages, disableNewSelections = props.disableNewSelections;
1892
+ var modifiers = props.modifiers, isOutOfStock = props.isOutOfStock, onChange = props.onChange, disableNewSelections = props.disableNewSelections;
1888
1893
  var makeHandleChange = function (modifier) { return function (_e, customEvent) {
1889
1894
  onChange({
1890
1895
  isRadio: false,
@@ -1896,9 +1901,12 @@ var MultipleQuantitySelectControl = function (props) {
1896
1901
  });
1897
1902
  }; };
1898
1903
  return (React__default.createElement(FormControl, { fullWidth: true },
1899
- React__default.createElement(FormGroup, null, modifiers.map(function (modifier) { return (React__default.createElement(Box, { key: modifier.id, style: { justifyContent: 'space-between' }, display: "flex" },
1900
- React__default.createElement(Label, { messages: messages, name: modifier.name, price: modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock, outOfStock: isOutOfStock }),
1901
- React__default.createElement(QuantityPicker, { variation: "modifierCount", value: modifier.quantity, disableIncrement: disableNewSelections, preventManualChange: true, onChange: makeHandleChange(modifier) }))); }))));
1904
+ 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" },
1905
+ React__default.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%" },
1906
+ React__default.createElement(Label, { name: modifier.name, price: modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock }),
1907
+ modifier.outOfStock && (React__default.createElement(Box, { minWidth: "90px", marginLeft: 2 },
1908
+ React__default.createElement(StatusTag, { color: "warning", label: "Out of stock", variant: "outlined", size: "md" }))),
1909
+ !modifier.outOfStock && (React__default.createElement(QuantityPicker, { variation: "modifierCount", value: modifier.quantity, disableIncrement: disableNewSelections, preventManualChange: true, onChange: makeHandleChange(modifier), disabled: isOutOfStock || modifier.outOfStock }))))); }))));
1902
1910
  };
1903
1911
  var ModifierControls = function (props) {
1904
1912
  switch (props.type) {
@@ -2121,7 +2129,7 @@ function SvgLeafIcon(props) {
2121
2129
  }
2122
2130
 
2123
2131
  var MenuFilter = function (props) {
2124
- var options = props.options, onChange = props.onChange, value = props.value, _a = props.triggerLabel, triggerLabel = _a === void 0 ? 'Add Filter' : _a, _b = props.noOptionsLabel, noOptionsLabel = _b === void 0 ? 'All filters have been added' : _b;
2132
+ var options = props.options, onChange = props.onChange, onClear = props.onClear, value = props.value, _a = props.triggerLabel, triggerLabel = _a === void 0 ? 'Add Filter' : _a, _b = props.noOptionsLabel, noOptionsLabel = _b === void 0 ? 'Reset Filters' : _b;
2125
2133
  var triggerId = 'menu-filter-trigger';
2126
2134
  var popoverId = 'menu-filter-popover';
2127
2135
  var classes = useMenuFilterStyles();
@@ -2142,18 +2150,20 @@ var MenuFilter = function (props) {
2142
2150
  var handleClose = function () {
2143
2151
  setAnchorEl(null);
2144
2152
  };
2153
+ var handleClear = function () {
2154
+ onClear();
2155
+ setAnchorEl(null);
2156
+ };
2157
+ if (allFiltersSelected) {
2158
+ return (React__default.createElement(Button$1, { size: "small", startIcon: React__default.createElement(SvgLeafIcon, null), classes: { label: classes.triggerLabel }, onClick: handleClear }, noOptionsLabel));
2159
+ }
2145
2160
  return (React__default.createElement(React__default.Fragment, null,
2146
2161
  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),
2147
- React__default.createElement(Menu, { id: popoverId, anchorEl: anchorEl, open: open, onClose: handleClose },
2148
- availableFilters.map(function (option, index) {
2149
- return (React__default.createElement(MenuItem$1, { key: index, value: option.id, onClick: function (event) { return handleChange(option, event); } },
2150
- React__default.createElement(ItemTag, { alt: option.abbr, color: option.color }, option.abbr),
2151
- React__default.createElement(Box, { ml: 1 }, option.name)));
2152
- }),
2153
- allFiltersSelected && (React__default.createElement(MenuItem$1, { onClick: handleClose },
2154
- React__default.createElement(Box, { display: "flex", flexDirection: "column", alignItems: "center" },
2155
- React__default.createElement(Icon, { icon: SvgTag, color: "#9E9E9E", size: "large" }),
2156
- React__default.createElement(Typography, { variant: "body1", color: "grey.500" }, noOptionsLabel)))))));
2162
+ React__default.createElement(Menu, { id: popoverId, anchorEl: anchorEl, open: open, onClose: handleClose }, availableFilters.map(function (option, index) {
2163
+ return (React__default.createElement(MenuItem$1, { key: index, value: option.id, onClick: function (event) { return handleChange(option, event); } },
2164
+ React__default.createElement(ItemTag, { alt: option.abbr, color: option.color }, option.abbr),
2165
+ React__default.createElement(Box, { ml: 1 }, option.name)));
2166
+ }))));
2157
2167
  };
2158
2168
 
2159
2169
  var useSelectableChipStyles = makeStyles(function (theme) { return ({
@@ -2236,9 +2246,10 @@ var useStyles$4 = makeStyles$1(function (_a) {
2236
2246
  var SelectedMenuFiltersList = function (props) {
2237
2247
  var filters = props.filters, onChipClick = props.onChipClick;
2238
2248
  var classes = useStyles$4();
2239
- return (React__default.createElement(React__default.Fragment, null, filters.map(function (filter, index) { return (React__default.createElement(Chip, { key: filter.name + "-" + index, classes: classes, deleteIcon: React__default.createElement(SvgXCircle, null), onDelete: function (event) { return onChipClick(filter, event); }, label: React__default.createElement(React__default.Fragment, null,
2249
+ return (React__default.createElement(React__default.Fragment, null, filters.map(function (filter, index) { return (React__default.createElement(Chip, { key: filter.name + "-" + index, classes: classes, onClick: function (event) { return onChipClick(filter, event); }, label: React__default.createElement(React__default.Fragment, null,
2240
2250
  React__default.createElement(ItemTag, { alt: filter.abbr, color: filter.color }, filter.abbr),
2241
- React__default.createElement(Typography$1, { variant: "caption" }, filter.name)) })); })));
2251
+ React__default.createElement(Typography$1, { variant: "caption" }, filter.name),
2252
+ React__default.createElement(Icon, { icon: SvgXCircle, size: "large" })) })); })));
2242
2253
  };
2243
2254
 
2244
2255
  var MenuSectionGroup = forwardRef(function (props, ref) {