@popmenu/ordering-ui 0.113.3 → 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;
package/build/index.es.js CHANGED
@@ -1679,6 +1679,11 @@ var useDishModifierCardStyles = makeStyles(function (theme) { return ({
1679
1679
  },
1680
1680
  }); });
1681
1681
  var useRadioModifierFormStyles = makeStyles(function (theme) { return ({
1682
+ label: {
1683
+ alignItems: 'center',
1684
+ display: 'flex',
1685
+ justifyContent: 'space-between',
1686
+ },
1682
1687
  radio: {
1683
1688
  fontSize: theme.spacing(2),
1684
1689
  padding: 'unset',
@@ -1687,14 +1692,25 @@ var useRadioModifierFormStyles = makeStyles(function (theme) { return ({
1687
1692
  color: theme.palette.info.main,
1688
1693
  },
1689
1694
  },
1695
+ hideRadio: {
1696
+ display: 'none',
1697
+ },
1690
1698
  root: {
1691
1699
  justifyContent: 'space-between',
1692
1700
  margin: 0,
1693
1701
  width: 'fill-available',
1702
+ '& > :last-child': {
1703
+ flex: 1,
1704
+ },
1694
1705
  },
1695
1706
  }); });
1696
1707
  var useCheckboxModifierFormStyles = makeStyles(function (theme) { return ({
1697
- radio: {
1708
+ label: {
1709
+ alignItems: 'center',
1710
+ display: 'flex',
1711
+ justifyContent: 'space-between',
1712
+ },
1713
+ checkbox: {
1698
1714
  color: '#616161',
1699
1715
  fontSize: theme.spacing(2),
1700
1716
  marginRight: theme.spacing(-0.25),
@@ -1703,18 +1719,23 @@ var useCheckboxModifierFormStyles = makeStyles(function (theme) { return ({
1703
1719
  color: theme.palette.info.main,
1704
1720
  },
1705
1721
  },
1722
+ hideCheckbox: {
1723
+ display: 'none',
1724
+ },
1706
1725
  root: {
1707
- justifyContent: 'space-between',
1708
1726
  margin: 0,
1709
1727
  width: 'fill-available',
1728
+ '& > :last-child': {
1729
+ flex: 1,
1730
+ },
1710
1731
  },
1711
1732
  }); });
1712
1733
  var useLabelStyles = makeStyles(function (theme) { return ({
1713
1734
  label: {
1714
1735
  margin: theme.spacing(0.5, 0),
1715
1736
  },
1716
- outOfStock: {
1717
- color: theme.palette.warning.dark,
1737
+ disabled: {
1738
+ color: theme.palette.grey[500],
1718
1739
  },
1719
1740
  price: {
1720
1741
  color: theme.palette.grey[700],
@@ -1799,15 +1820,15 @@ var QuantityPicker = function (props) {
1799
1820
  };
1800
1821
 
1801
1822
  var Label = function (props) {
1802
- 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;
1803
1825
  var classes = useLabelStyles();
1804
1826
  return (React__default.createElement(Box, { display: "flex", flexDirection: "column", className: classes.label },
1805
1827
  React__default.createElement(Box, { display: "flex", alignItems: "center", gridGap: 8 },
1806
- React__default.createElement(Typography$1, null, name),
1807
- outOfStock && (React__default.createElement(Typography$1, { variant: "caption", className: classes.outOfStock }, messages.outOfStockText))),
1808
- 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)) },
1809
1830
  "+ ",
1810
- price)));
1831
+ price))));
1811
1832
  };
1812
1833
  var Options = function (props) {
1813
1834
  var handleOptionsClick = props.handleOptionsClick, modifierId = props.modifierId;
@@ -1818,7 +1839,7 @@ var Options = function (props) {
1818
1839
  React__default.createElement(Icon, { icon: SvgChevronRight }))));
1819
1840
  };
1820
1841
  var SingleSelectModifierControl = function (props) {
1821
- 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;
1822
1843
  var radioClasses = useRadioModifierFormStyles();
1823
1844
  var makeHandleChange = function (modifier) { return function (e) {
1824
1845
  onChange({
@@ -1832,14 +1853,18 @@ var SingleSelectModifierControl = function (props) {
1832
1853
  }; };
1833
1854
  return (React__default.createElement(FormControl, { fullWidth: true },
1834
1855
  React__default.createElement(RadioGroup, null, modifiers.map(function (modifier) {
1835
- var _a;
1856
+ var _a, _b;
1857
+ var _c;
1836
1858
  return (React__default.createElement(Box, { key: modifier.id },
1837
- 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" }),
1838
1863
  modifier.hasModifiers && React__default.createElement(Options, { handleOptionsClick: handleOptionsClick, modifierId: modifier.id })));
1839
1864
  }))));
1840
1865
  };
1841
1866
  var MultipleSelectControl = function (props) {
1842
- 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;
1843
1868
  var classes = useCheckboxModifierFormStyles();
1844
1869
  var makeHandleChange = function (modifier) { return function () {
1845
1870
  var isModifierInValue = Boolean(value.find(function (v) { return v.modifierId === modifier.id; }));
@@ -1854,13 +1879,17 @@ var MultipleSelectControl = function (props) {
1854
1879
  }; };
1855
1880
  return (React__default.createElement(FormControl, { fullWidth: true },
1856
1881
  React__default.createElement(FormGroup, null, modifiers.map(function (modifier) {
1882
+ var _a, _b;
1857
1883
  return (React__default.createElement(Box, { key: modifier.id },
1858
- 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" }),
1859
1888
  modifier.hasModifiers && React__default.createElement(Options, { handleOptionsClick: handleOptionsClick, modifierId: modifier.id })));
1860
1889
  }))));
1861
1890
  };
1862
1891
  var MultipleQuantitySelectControl = function (props) {
1863
- 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;
1864
1893
  var makeHandleChange = function (modifier) { return function (_e, customEvent) {
1865
1894
  onChange({
1866
1895
  isRadio: false,
@@ -1872,9 +1901,12 @@ var MultipleQuantitySelectControl = function (props) {
1872
1901
  });
1873
1902
  }; };
1874
1903
  return (React__default.createElement(FormControl, { fullWidth: true },
1875
- React__default.createElement(FormGroup, null, modifiers.map(function (modifier) { return (React__default.createElement(Box, { key: modifier.id, style: { justifyContent: 'space-between' }, display: "flex" },
1876
- React__default.createElement(Label, { messages: messages, name: modifier.name, price: modifier.formattedPrice, disabled: isOutOfStock || modifier.outOfStock, outOfStock: isOutOfStock }),
1877
- 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 }))))); }))));
1878
1910
  };
1879
1911
  var ModifierControls = function (props) {
1880
1912
  switch (props.type) {