@popmenu/ordering-ui 0.84.0 → 0.84.1

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.
@@ -1,3 +1,4 @@
1
1
  export declare const useDishModifierCardStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<string>;
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
+ export declare const useLabelStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<string>;
@@ -16,6 +16,7 @@ interface Base {
16
16
  value: Array<ModifierValue> | undefined;
17
17
  /** Handles the change event */
18
18
  onChange: OnChange;
19
+ isOutOfStock: boolean;
19
20
  }
20
21
  export declare type DishModifierCardProps = Base & {
21
22
  /** Name of the modifier */
package/build/index.es.js CHANGED
@@ -1376,14 +1376,6 @@ var useDishModifierCardStyles = makeStyles(function (theme) { return ({
1376
1376
  },
1377
1377
  }); });
1378
1378
  var useRadioModifierFormStyles = makeStyles(function (theme) { return ({
1379
- root: {
1380
- '& .MuiFormControlLabel-label': {
1381
- margin: theme.spacing(0.5, 0),
1382
- '& div p:nth-child(2)': {
1383
- color: theme.palette.grey[700],
1384
- },
1385
- },
1386
- },
1387
1379
  radio: {
1388
1380
  fontSize: theme.spacing(2),
1389
1381
  padding: 'unset',
@@ -1394,14 +1386,6 @@ var useRadioModifierFormStyles = makeStyles(function (theme) { return ({
1394
1386
  },
1395
1387
  }); });
1396
1388
  var useCheckboxModifierFormStyles = makeStyles(function (theme) { return ({
1397
- root: {
1398
- '& .MuiFormControlLabel-label': {
1399
- margin: theme.spacing(0.5, 0),
1400
- },
1401
- '&:not(.Mui-disabled) div p:nth-child(2)': {
1402
- color: theme.palette.grey[700],
1403
- },
1404
- },
1405
1389
  radio: {
1406
1390
  color: '#616161',
1407
1391
  fontSize: theme.spacing(2),
@@ -1411,6 +1395,14 @@ var useCheckboxModifierFormStyles = makeStyles(function (theme) { return ({
1411
1395
  color: theme.palette.info.main,
1412
1396
  },
1413
1397
  },
1398
+ }); });
1399
+ var useLabelStyles = makeStyles(function (theme) { return ({
1400
+ label: {
1401
+ margin: theme.spacing(0.5, 0),
1402
+ },
1403
+ price: {
1404
+ color: theme.palette.grey[700],
1405
+ },
1414
1406
  }); });
1415
1407
 
1416
1408
  var useStatusTagStyles = makeStyles(function (theme) { return ({
@@ -1515,15 +1507,16 @@ StatusTag.defaultProps = {
1515
1507
  StatusTag.displayName = 'StatusTag';
1516
1508
 
1517
1509
  var Label = function (props) {
1518
- var name = props.name, price = props.price;
1519
- return (React__default.createElement(Box, { display: "flex", flexDirection: "column" },
1510
+ var name = props.name, price = props.price, disabled = props.disabled;
1511
+ var classes = useLabelStyles();
1512
+ return (React__default.createElement(Box, { display: "flex", flexDirection: "column", className: classes.label },
1520
1513
  React__default.createElement(Typography$1, null, name),
1521
- price && React__default.createElement(Typography$1, null,
1514
+ price && React__default.createElement(Typography$1, { className: !disabled ? classes.price : '' },
1522
1515
  "+ ",
1523
1516
  price)));
1524
1517
  };
1525
1518
  var CheckboxGroup = function (props) {
1526
- var value = props.value, modifiers = props.modifiers, onChange = props.onChange, disableNewSelections = props.disableNewSelections;
1519
+ var value = props.value, modifiers = props.modifiers, onChange = props.onChange, disableNewSelections = props.disableNewSelections, isOutOfStock = props.isOutOfStock;
1527
1520
  var classes = useCheckboxModifierFormStyles();
1528
1521
  var appContext = useOrderingAppContext()[0];
1529
1522
  var handleChange = function (event) {
@@ -1539,13 +1532,13 @@ var CheckboxGroup = function (props) {
1539
1532
  };
1540
1533
  return (React__default.createElement(Box, { display: "flex", flexDirection: "column" }, modifiers.map(function (modifier, index) {
1541
1534
  var targetValue = value === null || value === void 0 ? void 0 : value.find(function (v) { return v.id == modifier.id; });
1542
- return (React__default.createElement(FormControlLabel$1, { key: index, value: modifier.id, control: React__default.createElement(Checkbox$1, { className: classes.radio, disabled: !targetValue && disableNewSelections }), label: React__default.createElement(Label, { name: modifier.name, price: modifier.price
1535
+ return (React__default.createElement(FormControlLabel$1, { key: index, value: modifier.id, control: React__default.createElement(Checkbox$1, { className: classes.radio, disabled: (!targetValue && disableNewSelections) || isOutOfStock }), label: React__default.createElement(Label, { name: modifier.name, price: modifier.price
1543
1536
  ? "" + (appContext && appContext.currencySymbol) + Number(modifier.price).toFixed(2)
1544
- : null }), className: classes.root, checked: !!targetValue, onChange: handleChange }));
1537
+ : null, disabled: isOutOfStock }), className: classes.root, checked: !!targetValue, onChange: handleChange }));
1545
1538
  })));
1546
1539
  };
1547
1540
  var RadioGroup = function (props) {
1548
- var value = props.value, modifiers = props.modifiers, onChange = props.onChange;
1541
+ var value = props.value, modifiers = props.modifiers, onChange = props.onChange, isOutOfStock = props.isOutOfStock;
1549
1542
  var classes = useRadioModifierFormStyles();
1550
1543
  var appContext = useOrderingAppContext()[0];
1551
1544
  var handleChange = function (event) {
@@ -1559,16 +1552,16 @@ var RadioGroup = function (props) {
1559
1552
  },
1560
1553
  ]);
1561
1554
  };
1562
- return (React__default.createElement(MuiRadioGroup, { name: "selectedModifiers", value: value ? value[0].id : '', onChange: handleChange }, modifiers.map(function (modifier, index) { return (React__default.createElement(FormControlLabel$1, { key: index, value: modifier.id, control: React__default.createElement(Radio$1, { className: classes.radio }), label: React__default.createElement(Label, { name: modifier.name, price: modifier.price ? "" + (appContext && appContext.currencySymbol) + Number(modifier.price).toFixed(2) : null }), className: classes.root })); })));
1555
+ return (React__default.createElement(MuiRadioGroup, { name: "selectedModifiers", value: value ? value[0].id : '', onChange: handleChange }, modifiers.map(function (modifier, index) { return (React__default.createElement(FormControlLabel$1, { key: index, value: modifier.id, control: React__default.createElement(Radio$1, { className: classes.radio, disabled: isOutOfStock }), label: React__default.createElement(Label, { name: modifier.name, price: modifier.price ? "" + (appContext && appContext.currencySymbol) + Number(modifier.price).toFixed(2) : null, disabled: isOutOfStock }) })); })));
1563
1556
  };
1564
1557
 
1565
1558
  var ModifierOptionsControl = function (props) {
1566
- var type = props.type, modifiers = props.modifiers, value = props.value, onChange = props.onChange, disableNewSelections = props.disableNewSelections;
1559
+ var type = props.type, modifiers = props.modifiers, value = props.value, onChange = props.onChange, disableNewSelections = props.disableNewSelections, isOutOfStock = props.isOutOfStock;
1567
1560
  switch (type) {
1568
1561
  case 'singleSelect':
1569
- return React__default.createElement(RadioGroup, { modifiers: modifiers, value: value, onChange: onChange });
1562
+ return React__default.createElement(RadioGroup, { modifiers: modifiers, value: value, onChange: onChange, isOutOfStock: isOutOfStock });
1570
1563
  case 'multipleSelect':
1571
- return (React__default.createElement(CheckboxGroup, { modifiers: modifiers, value: value, onChange: onChange, disableNewSelections: disableNewSelections }));
1564
+ return (React__default.createElement(CheckboxGroup, { modifiers: modifiers, value: value, onChange: onChange, disableNewSelections: disableNewSelections, isOutOfStock: isOutOfStock }));
1572
1565
  default:
1573
1566
  return null;
1574
1567
  }
@@ -1587,10 +1580,12 @@ var DishModifierCard = function (props) {
1587
1580
  }
1588
1581
  var label = optionalText;
1589
1582
  switch (true) {
1590
- case isRequired:
1591
- label = requiredText;
1592
1583
  case isOutOfStock:
1593
1584
  label = outOfStockText;
1585
+ break;
1586
+ case isRequired:
1587
+ label = requiredText;
1588
+ break;
1594
1589
  }
1595
1590
  return (React__default.createElement(Box, { className: classes.root },
1596
1591
  React__default.createElement(Box, { display: "flex", justifyContent: "space-between", width: "100%", alignItems: "center", height: "fit-content" },
@@ -1601,7 +1596,7 @@ var DishModifierCard = function (props) {
1601
1596
  React__default.createElement(Typography, { variant: "subtitle1", className: error ? classes.error : undefined }, helperText)),
1602
1597
  React__default.createElement(Box, null,
1603
1598
  React__default.createElement(FormControl, null,
1604
- React__default.createElement(ModifierOptionsControl, { type: type, modifiers: modifiers, value: value, onChange: onChange, disableNewSelections: disableNewSelections })))));
1599
+ React__default.createElement(ModifierOptionsControl, { type: type, modifiers: modifiers, value: value, onChange: onChange, disableNewSelections: disableNewSelections, isOutOfStock: isOutOfStock })))));
1605
1600
  };
1606
1601
  DishModifierCard.displayName = 'DishModifierCard';
1607
1602