@popmenu/ordering-ui 0.83.0 → 0.84.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.
@@ -1,14 +1,16 @@
1
1
  export interface DishCheckoutCardProps {
2
2
  /** Modifiers of the dish in tuple format */
3
- modifiers?: Array<[string | number, string | number]>;
3
+ modifiers?: [string, string][];
4
4
  /** Id of the dish */
5
5
  id: number;
6
+ /** disables all interactive elements in the card, like "edit" or "delete" */
7
+ disabled?: boolean;
6
8
  /** Name of the dish */
7
9
  name: string;
8
10
  /** Quantity of dish selected */
9
11
  quantity: number;
10
12
  /** Price of description should be formatted in the correct currency before passing as a prop */
11
- price: string;
13
+ price: number | string;
12
14
  /** Callback for edit button */
13
15
  onEdit: () => void;
14
16
  /** Callback for delete button */
@@ -16,5 +18,5 @@ export interface DishCheckoutCardProps {
16
18
  /** Callback that runs when the select value is changed. Expects two arguments, the id of the selected dish and the new value that is being changed from the dropdown. Callback should update the dish */
17
19
  onChange: (id: number, value: number | string) => void;
18
20
  /** Special instructions text */
19
- specialInstructions?: string | undefined;
21
+ specialInstructions?: string | null;
20
22
  }
@@ -1,13 +1,14 @@
1
- import React from 'react';
2
- declare type OrderingAppContextState = {
1
+ import React, { PropsWithChildren } from 'react';
2
+ declare type OrderingAppContextValue = {
3
3
  currencySymbol?: string;
4
4
  basePath: string;
5
5
  restaurantId: number;
6
- } | null;
7
- declare type OrderingAppContextType = [OrderingAppContextState, React.Dispatch<React.SetStateAction<OrderingAppContextState>>];
6
+ };
7
+ declare type OrderingAppContextType = [OrderingAppContextValue, React.Dispatch<React.SetStateAction<OrderingAppContextValue>>];
8
8
  export declare const OrderingAppContext: React.Context<OrderingAppContextType | null>;
9
9
  export declare const useOrderingAppContext: () => OrderingAppContextType;
10
- export declare const OrderingAppContextProvider: (props: {
11
- children: React.ReactNode;
12
- }) => JSX.Element;
10
+ declare type OrderingAppContextProviderProps = PropsWithChildren<{
11
+ defaultContext: OrderingAppContextValue;
12
+ }>;
13
+ export declare const OrderingAppContextProvider: (props: OrderingAppContextProviderProps) => JSX.Element;
13
14
  export {};
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const PageSection: (props: {
3
+ children: React.ReactNode;
4
+ }) => JSX.Element;
@@ -0,0 +1 @@
1
+ export { PageSection } from './PageSection';
@@ -20,3 +20,4 @@ export { SelectedMenuFiltersList, SelectedMenuFiltersListProps } from './Selecte
20
20
  export { MenuSectionGroup } from './MenuSectionGroup';
21
21
  export { MenuSection, MenuSectionProps } from './MenuSection';
22
22
  export { MenuItemGroup } from './MenuItemGroup';
23
+ export { PageSection } from './PageSection';
package/build/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Button as Button$2, makeStyles as makeStyles$1, Box, Typography as Typography$1, Link as Link$1, Paper as Paper$1, Avatar as Avatar$1, Card, CardActionArea, FormControl, Select, InputAdornment, MenuItem as MenuItem$1, FormControlLabel as FormControlLabel$1, Checkbox as Checkbox$1, Radio as Radio$1, Menu, TextField, Tabs, Chip } from '@material-ui/core';
2
2
  export * from '@material-ui/core';
3
3
  import * as React from 'react';
4
- import React__default, { forwardRef, createElement, useState, createContext, useContext } from 'react';
4
+ import React__default, { forwardRef, createElement, createContext, useContext, useState } from 'react';
5
5
  import { makeStyles, useTheme, lighten } from '@material-ui/core/styles';
6
6
  import '@material-ui/lab/Alert';
7
7
  import '@material-ui/core/AppBar';
@@ -1245,8 +1245,7 @@ var useDishCheckoutCardStyles = makeStyles(function (theme) { return ({
1245
1245
  gridGap: theme.spacing(2),
1246
1246
  border: '1px',
1247
1247
  },
1248
- deleteIcon: {
1249
- height: theme.spacing(2.5),
1248
+ deleteButton: {
1250
1249
  color: theme.palette.info.main,
1251
1250
  },
1252
1251
  editButton: {
@@ -1283,10 +1282,26 @@ var useDishCheckoutCardStyles = makeStyles(function (theme) { return ({
1283
1282
  },
1284
1283
  }); });
1285
1284
 
1285
+ var OrderingAppContext = createContext(null);
1286
+ var useOrderingAppContext = function () {
1287
+ var context = useContext(OrderingAppContext);
1288
+ if (!context) {
1289
+ throw new Error('useOrderingAppContext has to be used within <OrderingAppContext.Provider>');
1290
+ }
1291
+ return context;
1292
+ };
1293
+ var OrderingAppContextProvider = function (props) {
1294
+ var context = useState(props.defaultContext);
1295
+ return React__default.createElement(OrderingAppContext.Provider, { value: context }, props.children);
1296
+ };
1297
+
1286
1298
  var DishCheckoutCard = function (props) {
1287
- var id = props.id, name = props.name, quantity = props.quantity, modifiers = props.modifiers, onDelete = props.onDelete, onEdit = props.onEdit, onChange = props.onChange, price = props.price, specialInstructions = props.specialInstructions;
1299
+ var _a;
1300
+ var id = props.id, name = props.name, quantity = props.quantity, modifiers = props.modifiers, onDelete = props.onDelete, onEdit = props.onEdit, onChange = props.onChange, price = props.price, specialInstructions = props.specialInstructions, disabled = props.disabled;
1288
1301
  var classes = useDishCheckoutCardStyles(props);
1289
- var _a = useState(false), open = _a[0], setOpen = _a[1];
1302
+ var appContext = useOrderingAppContext()[0];
1303
+ var _b = useState(false), open = _b[0], setOpen = _b[1];
1304
+ var formattedPrice = typeof price === 'number' ? "" + ((_a = appContext.currencySymbol) !== null && _a !== void 0 ? _a : '') + price.toFixed(2) : price;
1290
1305
  return (React__default.createElement(Box, { className: classes.root },
1291
1306
  React__default.createElement(Box, { display: "flex", justifyContent: "space-between", gridGap: 3 },
1292
1307
  React__default.createElement(Box, null,
@@ -1300,13 +1315,13 @@ var DishCheckoutCard = function (props) {
1300
1315
  "\"",
1301
1316
  specialInstructions,
1302
1317
  "\"")),
1303
- React__default.createElement(Box, { display: "flex", gridGap: 1, height: "100%" },
1304
- React__default.createElement(Button$1, { className: classes.editButton, variant: "text", onClick: onEdit }, "Edit"),
1305
- React__default.createElement(IconButton, { onClick: onDelete },
1306
- React__default.createElement(Icon, { icon: SvgTrash, className: classes.deleteIcon })))),
1318
+ React__default.createElement(Box, { display: "flex", gridGap: 1, height: "100%", alignItems: "center" },
1319
+ React__default.createElement(Button$1, { disabled: disabled, className: classes.editButton, variant: "text", onClick: onEdit }, "Edit"),
1320
+ React__default.createElement(IconButton, { disabled: disabled, onClick: onDelete, classes: { root: classes.deleteButton } },
1321
+ React__default.createElement(Icon, { icon: SvgTrash, size: "large" })))),
1307
1322
  React__default.createElement(Box, { display: "flex", gridGap: 16, alignItems: "center" },
1308
1323
  React__default.createElement(FormControl, { variant: "outlined", hiddenLabel: true },
1309
- React__default.createElement(Select, { open: open, value: quantity, labelId: "select-label-" + id, onClick: function () { return setOpen(!open); }, disableUnderline: true, onChange: function (event) { return onChange(id, event.target.value); }, fullWidth: true, startAdornment: React__default.createElement(InputAdornment, { position: "start" },
1324
+ React__default.createElement(Select, { disabled: disabled, open: open, value: quantity, labelId: "select-label-" + id, onClick: function () { return setOpen(!open); }, disableUnderline: true, onChange: function (event) { return onChange(id, event.target.value); }, fullWidth: true, startAdornment: React__default.createElement(InputAdornment, { position: "start" },
1310
1325
  React__default.createElement(Icon, { icon: open ? SvgChevronUp : SvgChevronDown, size: "large" })), inputProps: { shrink: false }, MenuProps: {
1311
1326
  disablePortal: true,
1312
1327
  anchorOrigin: {
@@ -1320,7 +1335,7 @@ var DishCheckoutCard = function (props) {
1320
1335
  getContentAnchorEl: null,
1321
1336
  classes: { paper: classes.selectPaper },
1322
1337
  }, className: classes.select }, Array.from({ length: 99 }, function (_, index) { return (React__default.createElement(MenuItem$1, { key: index + 1, value: index + 1 }, index + 1)); }))),
1323
- React__default.createElement(Typography, { className: classes.price }, price))));
1338
+ React__default.createElement(Typography, { className: classes.price }, formattedPrice))));
1324
1339
  };
1325
1340
 
1326
1341
  var DishDetailsReview = forwardRef(function (props) {
@@ -1499,19 +1514,6 @@ StatusTag.defaultProps = {
1499
1514
  };
1500
1515
  StatusTag.displayName = 'StatusTag';
1501
1516
 
1502
- var OrderingAppContext = createContext(null);
1503
- var useOrderingAppContext = function () {
1504
- var context = useContext(OrderingAppContext);
1505
- if (!context) {
1506
- throw new Error('useOrderingAppContext has to be used within <OrderingAppContext.Provider>');
1507
- }
1508
- return context;
1509
- };
1510
- var OrderingAppContextProvider = function (props) {
1511
- var context = useState(null);
1512
- return React__default.createElement(OrderingAppContext.Provider, { value: context }, props.children);
1513
- };
1514
-
1515
1517
  var Label = function (props) {
1516
1518
  var name = props.name, price = props.price;
1517
1519
  return (React__default.createElement(Box, { display: "flex", flexDirection: "column" },
@@ -1974,6 +1976,8 @@ var MenuItemGroup = forwardRef(function (props, ref) {
1974
1976
  });
1975
1977
  MenuItemGroup.displayName = 'MenuItemGroup';
1976
1978
 
1979
+ var PageSection = function (props) { return (React__default.createElement(Box, { p: 4, borderBottom: "1px solid #E0E0E0" }, props.children)); };
1980
+
1977
1981
  var palette = {
1978
1982
  primary: {
1979
1983
  light: '#7B7FA3',
@@ -2088,5 +2092,5 @@ var orderingTheme = {
2088
2092
  props: props,
2089
2093
  };
2090
2094
 
2091
- export { Button$1 as Button, DishCheckoutCard, DishDetailsReview, DishModifierCard, ItemTag, ItemTagGroup, LocationCard, MenuDropdown, MenuFilter, MenuItem, MenuItemGroup, MenuSection, MenuSectionGroup, OrderingAppContext, OrderingAppContextProvider, QuantityPicker, ReactionCounter, ReactionCounterGroup, SelectableChip, SelectableChipGroup, SelectedMenuFiltersList, StatusTag, orderingTheme, useOrderingAppContext };
2095
+ export { Button$1 as Button, DishCheckoutCard, DishDetailsReview, DishModifierCard, ItemTag, ItemTagGroup, LocationCard, MenuDropdown, MenuFilter, MenuItem, MenuItemGroup, MenuSection, MenuSectionGroup, OrderingAppContext, OrderingAppContextProvider, PageSection, QuantityPicker, ReactionCounter, ReactionCounterGroup, SelectableChip, SelectableChipGroup, SelectedMenuFiltersList, StatusTag, orderingTheme, useOrderingAppContext };
2092
2096
  //# sourceMappingURL=index.es.js.map