@open-tender/utils 0.1.135 → 0.1.136

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,6 +1,5 @@
1
- import { CartCounts, Favorite, CartItem, ConfigDisplaySetting } from '@open-tender/types';
2
- export declare const useOrderItem: (orderItem: CartItem, favorite?: Favorite | null, allergenAlerts?: string[], displaySettings?: ConfigDisplaySetting | null, cartCounts?: CartCounts, isMobile?: boolean) => {
3
- showImage: boolean;
1
+ import { CartCounts, Favorite, CartItem, ThemeMenuItemsContentDescription } from '@open-tender/types';
2
+ export declare const useOrderItem: (orderItem: CartItem, favorite?: Favorite | null, allergenAlerts?: string[], cartCounts?: CartCounts, showCals?: boolean, showTags?: boolean, showAllergens?: boolean, showDesc?: ThemeMenuItemsContentDescription) => {
4
3
  displayDesc: string | null;
5
4
  displayTags: string[];
6
5
  displayAllergens: string[];
@@ -10,7 +9,6 @@ export declare const useOrderItem: (orderItem: CartItem, favorite?: Favorite | n
10
9
  isSoldOut: boolean;
11
10
  allergenAlert: string | null;
12
11
  hasSelections: boolean;
13
- showQuickAdd: boolean;
14
12
  sizeOnly: boolean | undefined;
15
13
  cartCount: number;
16
14
  cartGuestId: number | null;
@@ -2,9 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useOrderItem = void 0;
4
4
  const utils_1 = require("../utils");
5
- const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], displaySettings = null, cartCounts = {}, isMobile = true) => {
6
- const { menuImages: showImage = true, calories: showCals = false, tags: showTags = false, allergens: showAllergens = false, quickAdd = false, quickAddMobile = false, menuItemDescription = 'SHOW', menuItemDescriptionMobile = 'SHOW' } = displaySettings || {};
7
- const showQuickAdd = isMobile ? quickAddMobile : quickAdd;
5
+ const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], cartCounts = {}, showCals = false, showTags = false, showAllergens = false, showDesc = 'SHOW') => {
8
6
  const { description, shortDescription, quantity, price, totalPrice, cals, totalCals, tags, allergens, groups, isSoldOut } = orderItem;
9
7
  const cartCount = cartCounts[orderItem.id] || 0;
10
8
  const displayTags = showTags && tags.length ? tags : [];
@@ -29,7 +27,6 @@ const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], displaySe
29
27
  const nonSizeGroups = groups.filter(i => !i.isSize);
30
28
  const currentOptions = (0, utils_1.getItemOptions)(Object.assign(Object.assign({}, orderItem), { groups: nonSizeGroups }));
31
29
  const hasSelections = currentOptions.length > 0;
32
- const showDesc = isMobile ? menuItemDescriptionMobile : menuItemDescription;
33
30
  const desc = showDesc === 'HIDE'
34
31
  ? ''
35
32
  : showDesc === 'SHORT'
@@ -44,8 +41,7 @@ const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], displaySe
44
41
  .join(', ')
45
42
  : null;
46
43
  const displayDesc = optionNames || desc;
47
- return Object.assign(Object.assign({}, orderItem), { showImage,
48
- displayDesc,
44
+ return Object.assign(Object.assign({}, orderItem), { displayDesc,
49
45
  displayTags,
50
46
  displayAllergens,
51
47
  displayPrice,
@@ -54,7 +50,6 @@ const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], displaySe
54
50
  isSoldOut,
55
51
  allergenAlert,
56
52
  hasSelections,
57
- showQuickAdd,
58
53
  sizeOnly,
59
54
  cartCount });
60
55
  };
@@ -167,18 +167,20 @@ const fontSizeToLineHeight = (lineHeight, fontSize) => {
167
167
  return `${(lineHt * (0, exports.pixelsToFloat)(textFontSize)).toFixed(2)}px`;
168
168
  };
169
169
  const makeMenuItems = (menuItems, lineHeight) => {
170
- const { allergens, box, calories, container, content, image, price, tags, text, title } = menuItems;
170
+ const { allergens, box, calories, container, content, buttons, image, price, tags, tagsAllergens, text, title } = menuItems;
171
171
  return {
172
- allergens: Object.assign(Object.assign({}, allergens), { fontSize: (0, exports.remsToPixels)(allergens.fontSize), fontSizeMobile: (0, exports.remsToPixels)(allergens.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, allergens.fontSizeMobile) }),
172
+ allergens: Object.assign(Object.assign({}, allergens), { fontSize: (0, exports.remsToPixels)(allergens.fontSize), fontSizeMobile: (0, exports.remsToPixels)(allergens.fontSizeMobile), letterSpacing: (0, exports.remsToPixels)(allergens.letterSpacing), lineHeight: fontSizeToLineHeight(lineHeight, allergens.fontSizeMobile), gap: (0, exports.remsToPixels)(allergens.gap), gapMobile: (0, exports.remsToPixels)(allergens.gapMobile), width: (0, exports.remsToPixels)(allergens.width), widthMobile: (0, exports.remsToPixels)(allergens.widthMobile) }),
173
173
  box: Object.assign(Object.assign({}, box), { border: boxRemsToPixels(box.border), borderMobile: boxRemsToPixels(box.borderMobile), borderRadius: (0, exports.remsToPixels)(box.borderRadius), borderRadiusMobile: (0, exports.remsToPixels)(box.borderRadiusMobile), margin: boxRemsToPixels(box.margin), marginMobile: boxRemsToPixels(box.marginMobile), minWidth: (0, exports.remsToPixels)(box.minWidth), minWidthMobile: (0, exports.remsToPixels)(box.minWidthMobile), padding: boxRemsToPixels(box.padding), paddingMobile: boxRemsToPixels(box.paddingMobile) }),
174
- calories: Object.assign(Object.assign({}, calories), { fontSize: (0, exports.remsToPixels)(calories.fontSize), fontSizeMobile: (0, exports.remsToPixels)(calories.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, calories.fontSizeMobile) }),
174
+ calories: Object.assign(Object.assign({}, calories), { fontSize: (0, exports.remsToPixels)(calories.fontSize), fontSizeMobile: (0, exports.remsToPixels)(calories.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, calories.fontSizeMobile), padding: boxRemsToPixels(calories.padding), paddingMobile: boxRemsToPixels(calories.paddingMobile) }),
175
175
  container: Object.assign(Object.assign({}, container), { gap: (0, exports.remsToPixels)(container.gap), gapHalf: (0, exports.remsToPixels)(container.gapHalf), gapHalfMobile: (0, exports.remsToPixels)(container.gapHalfMobile), gapMobile: (0, exports.remsToPixels)(container.gapMobile), margin: boxRemsToPixels(container.margin), marginMobile: boxRemsToPixels(container.marginMobile), maxWidth: (0, exports.remsToPixels)(container.maxWidth), padding: boxRemsToPixels(container.padding), paddingMobile: boxRemsToPixels(container.paddingMobile) }),
176
176
  content: Object.assign(Object.assign({}, content), { padding: boxRemsToPixels(content.padding), paddingMobile: boxRemsToPixels(content.paddingMobile) }),
177
+ buttons: Object.assign(Object.assign({}, buttons), { padding: boxRemsToPixels(buttons.padding), paddingMobile: boxRemsToPixels(buttons.paddingMobile) }),
177
178
  image: Object.assign(Object.assign({}, image), { border: boxRemsToPixels(image.border), borderMobile: boxRemsToPixels(image.borderMobile), borderRadius: (0, exports.remsToPixels)(image.borderRadius), borderRadiusMobile: (0, exports.remsToPixels)(image.borderRadiusMobile), margin: boxRemsToPixels(image.margin), marginMobile: boxRemsToPixels(image.marginMobile), minWidth: (0, exports.remsToPixels)(image.minWidth), minWidthMobile: (0, exports.remsToPixels)(image.minWidthMobile), padding: boxRemsToPixels(image.padding), paddingMobile: boxRemsToPixels(image.paddingMobile) }),
178
- price: Object.assign(Object.assign({}, price), { fontSize: (0, exports.remsToPixels)(price.fontSize), fontSizeMobile: (0, exports.remsToPixels)(price.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, price.fontSizeMobile) }),
179
- tags: Object.assign(Object.assign({}, tags), { fontSize: (0, exports.remsToPixels)(tags.fontSize), fontSizeMobile: (0, exports.remsToPixels)(tags.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, tags.fontSizeMobile), gap: (0, exports.remsToPixels)(tags.gap), gapMobile: (0, exports.remsToPixels)(tags.gapMobile), width: (0, exports.remsToPixels)(tags.width), widthMobile: (0, exports.remsToPixels)(tags.widthMobile) }),
180
- text: Object.assign(Object.assign({}, text), { fontSize: (0, exports.remsToPixels)(text.fontSize), fontSizeMobile: (0, exports.remsToPixels)(text.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, text.fontSizeMobile) }),
181
- title: Object.assign(Object.assign({}, title), { fontSize: (0, exports.remsToPixels)(title.fontSize), fontSizeMobile: (0, exports.remsToPixels)(title.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, title.fontSizeMobile) })
179
+ price: Object.assign(Object.assign({}, price), { fontSize: (0, exports.remsToPixels)(price.fontSize), fontSizeMobile: (0, exports.remsToPixels)(price.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, price.fontSizeMobile), padding: boxRemsToPixels(price.padding), paddingMobile: boxRemsToPixels(price.paddingMobile) }),
180
+ tags: Object.assign(Object.assign({}, tags), { fontSize: (0, exports.remsToPixels)(tags.fontSize), fontSizeMobile: (0, exports.remsToPixels)(tags.fontSizeMobile), letterSpacing: (0, exports.remsToPixels)(tags.letterSpacing), lineHeight: fontSizeToLineHeight(lineHeight, tags.fontSizeMobile), gap: (0, exports.remsToPixels)(tags.gap), gapMobile: (0, exports.remsToPixels)(tags.gapMobile), width: (0, exports.remsToPixels)(tags.width), widthMobile: (0, exports.remsToPixels)(tags.widthMobile) }),
181
+ tagsAllergens: Object.assign(Object.assign({}, tagsAllergens), { gap: (0, exports.remsToPixels)(tagsAllergens.gap), gapMobile: (0, exports.remsToPixels)(tagsAllergens.gapMobile), padding: boxRemsToPixels(tagsAllergens.padding), paddingMobile: boxRemsToPixels(tagsAllergens.paddingMobile) }),
182
+ text: Object.assign(Object.assign({}, text), { fontSize: (0, exports.remsToPixels)(text.fontSize), fontSizeMobile: (0, exports.remsToPixels)(text.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, text.fontSizeMobile), padding: boxRemsToPixels(text.padding), paddingMobile: boxRemsToPixels(text.paddingMobile) }),
183
+ title: Object.assign(Object.assign({}, title), { fontSize: (0, exports.remsToPixels)(title.fontSize), fontSizeMobile: (0, exports.remsToPixels)(title.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, title.fontSizeMobile), padding: boxRemsToPixels(title.padding), paddingMobile: boxRemsToPixels(title.paddingMobile) })
182
184
  };
183
185
  };
184
186
  const decorateTheme = (theme) => {
@@ -1,6 +1,5 @@
1
- import { CartCounts, Favorite, CartItem, ConfigDisplaySetting } from '@open-tender/types';
2
- export declare const useOrderItem: (orderItem: CartItem, favorite?: Favorite | null, allergenAlerts?: string[], displaySettings?: ConfigDisplaySetting | null, cartCounts?: CartCounts, isMobile?: boolean) => {
3
- showImage: boolean;
1
+ import { CartCounts, Favorite, CartItem, ThemeMenuItemsContentDescription } from '@open-tender/types';
2
+ export declare const useOrderItem: (orderItem: CartItem, favorite?: Favorite | null, allergenAlerts?: string[], cartCounts?: CartCounts, showCals?: boolean, showTags?: boolean, showAllergens?: boolean, showDesc?: ThemeMenuItemsContentDescription) => {
4
3
  displayDesc: string | null;
5
4
  displayTags: string[];
6
5
  displayAllergens: string[];
@@ -10,7 +9,6 @@ export declare const useOrderItem: (orderItem: CartItem, favorite?: Favorite | n
10
9
  isSoldOut: boolean;
11
10
  allergenAlert: string | null;
12
11
  hasSelections: boolean;
13
- showQuickAdd: boolean;
14
12
  sizeOnly: boolean | undefined;
15
13
  cartCount: number;
16
14
  cartGuestId: number | null;
@@ -1,7 +1,5 @@
1
1
  import { formatDollars, getItemOptions, hasGroupsBelowMin } from '../utils';
2
- export const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], displaySettings = null, cartCounts = {}, isMobile = true) => {
3
- const { menuImages: showImage = true, calories: showCals = false, tags: showTags = false, allergens: showAllergens = false, quickAdd = false, quickAddMobile = false, menuItemDescription = 'SHOW', menuItemDescriptionMobile = 'SHOW' } = displaySettings || {};
4
- const showQuickAdd = isMobile ? quickAddMobile : quickAdd;
2
+ export const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], cartCounts = {}, showCals = false, showTags = false, showAllergens = false, showDesc = 'SHOW') => {
5
3
  const { description, shortDescription, quantity, price, totalPrice, cals, totalCals, tags, allergens, groups, isSoldOut } = orderItem;
6
4
  const cartCount = cartCounts[orderItem.id] || 0;
7
5
  const displayTags = showTags && tags.length ? tags : [];
@@ -26,7 +24,6 @@ export const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], di
26
24
  const nonSizeGroups = groups.filter(i => !i.isSize);
27
25
  const currentOptions = getItemOptions(Object.assign(Object.assign({}, orderItem), { groups: nonSizeGroups }));
28
26
  const hasSelections = currentOptions.length > 0;
29
- const showDesc = isMobile ? menuItemDescriptionMobile : menuItemDescription;
30
27
  const desc = showDesc === 'HIDE'
31
28
  ? ''
32
29
  : showDesc === 'SHORT'
@@ -41,8 +38,7 @@ export const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], di
41
38
  .join(', ')
42
39
  : null;
43
40
  const displayDesc = optionNames || desc;
44
- return Object.assign(Object.assign({}, orderItem), { showImage,
45
- displayDesc,
41
+ return Object.assign(Object.assign({}, orderItem), { displayDesc,
46
42
  displayTags,
47
43
  displayAllergens,
48
44
  displayPrice,
@@ -51,7 +47,6 @@ export const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], di
51
47
  isSoldOut,
52
48
  allergenAlert,
53
49
  hasSelections,
54
- showQuickAdd,
55
50
  sizeOnly,
56
51
  cartCount });
57
52
  };
@@ -158,18 +158,20 @@ const fontSizeToLineHeight = (lineHeight, fontSize) => {
158
158
  return `${(lineHt * pixelsToFloat(textFontSize)).toFixed(2)}px`;
159
159
  };
160
160
  const makeMenuItems = (menuItems, lineHeight) => {
161
- const { allergens, box, calories, container, content, image, price, tags, text, title } = menuItems;
161
+ const { allergens, box, calories, container, content, buttons, image, price, tags, tagsAllergens, text, title } = menuItems;
162
162
  return {
163
- allergens: Object.assign(Object.assign({}, allergens), { fontSize: remsToPixels(allergens.fontSize), fontSizeMobile: remsToPixels(allergens.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, allergens.fontSizeMobile) }),
163
+ allergens: Object.assign(Object.assign({}, allergens), { fontSize: remsToPixels(allergens.fontSize), fontSizeMobile: remsToPixels(allergens.fontSizeMobile), letterSpacing: remsToPixels(allergens.letterSpacing), lineHeight: fontSizeToLineHeight(lineHeight, allergens.fontSizeMobile), gap: remsToPixels(allergens.gap), gapMobile: remsToPixels(allergens.gapMobile), width: remsToPixels(allergens.width), widthMobile: remsToPixels(allergens.widthMobile) }),
164
164
  box: Object.assign(Object.assign({}, box), { border: boxRemsToPixels(box.border), borderMobile: boxRemsToPixels(box.borderMobile), borderRadius: remsToPixels(box.borderRadius), borderRadiusMobile: remsToPixels(box.borderRadiusMobile), margin: boxRemsToPixels(box.margin), marginMobile: boxRemsToPixels(box.marginMobile), minWidth: remsToPixels(box.minWidth), minWidthMobile: remsToPixels(box.minWidthMobile), padding: boxRemsToPixels(box.padding), paddingMobile: boxRemsToPixels(box.paddingMobile) }),
165
- calories: Object.assign(Object.assign({}, calories), { fontSize: remsToPixels(calories.fontSize), fontSizeMobile: remsToPixels(calories.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, calories.fontSizeMobile) }),
165
+ calories: Object.assign(Object.assign({}, calories), { fontSize: remsToPixels(calories.fontSize), fontSizeMobile: remsToPixels(calories.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, calories.fontSizeMobile), padding: boxRemsToPixels(calories.padding), paddingMobile: boxRemsToPixels(calories.paddingMobile) }),
166
166
  container: Object.assign(Object.assign({}, container), { gap: remsToPixels(container.gap), gapHalf: remsToPixels(container.gapHalf), gapHalfMobile: remsToPixels(container.gapHalfMobile), gapMobile: remsToPixels(container.gapMobile), margin: boxRemsToPixels(container.margin), marginMobile: boxRemsToPixels(container.marginMobile), maxWidth: remsToPixels(container.maxWidth), padding: boxRemsToPixels(container.padding), paddingMobile: boxRemsToPixels(container.paddingMobile) }),
167
167
  content: Object.assign(Object.assign({}, content), { padding: boxRemsToPixels(content.padding), paddingMobile: boxRemsToPixels(content.paddingMobile) }),
168
+ buttons: Object.assign(Object.assign({}, buttons), { padding: boxRemsToPixels(buttons.padding), paddingMobile: boxRemsToPixels(buttons.paddingMobile) }),
168
169
  image: Object.assign(Object.assign({}, image), { border: boxRemsToPixels(image.border), borderMobile: boxRemsToPixels(image.borderMobile), borderRadius: remsToPixels(image.borderRadius), borderRadiusMobile: remsToPixels(image.borderRadiusMobile), margin: boxRemsToPixels(image.margin), marginMobile: boxRemsToPixels(image.marginMobile), minWidth: remsToPixels(image.minWidth), minWidthMobile: remsToPixels(image.minWidthMobile), padding: boxRemsToPixels(image.padding), paddingMobile: boxRemsToPixels(image.paddingMobile) }),
169
- price: Object.assign(Object.assign({}, price), { fontSize: remsToPixels(price.fontSize), fontSizeMobile: remsToPixels(price.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, price.fontSizeMobile) }),
170
- tags: Object.assign(Object.assign({}, tags), { fontSize: remsToPixels(tags.fontSize), fontSizeMobile: remsToPixels(tags.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, tags.fontSizeMobile), gap: remsToPixels(tags.gap), gapMobile: remsToPixels(tags.gapMobile), width: remsToPixels(tags.width), widthMobile: remsToPixels(tags.widthMobile) }),
171
- text: Object.assign(Object.assign({}, text), { fontSize: remsToPixels(text.fontSize), fontSizeMobile: remsToPixels(text.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, text.fontSizeMobile) }),
172
- title: Object.assign(Object.assign({}, title), { fontSize: remsToPixels(title.fontSize), fontSizeMobile: remsToPixels(title.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, title.fontSizeMobile) })
170
+ price: Object.assign(Object.assign({}, price), { fontSize: remsToPixels(price.fontSize), fontSizeMobile: remsToPixels(price.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, price.fontSizeMobile), padding: boxRemsToPixels(price.padding), paddingMobile: boxRemsToPixels(price.paddingMobile) }),
171
+ tags: Object.assign(Object.assign({}, tags), { fontSize: remsToPixels(tags.fontSize), fontSizeMobile: remsToPixels(tags.fontSizeMobile), letterSpacing: remsToPixels(tags.letterSpacing), lineHeight: fontSizeToLineHeight(lineHeight, tags.fontSizeMobile), gap: remsToPixels(tags.gap), gapMobile: remsToPixels(tags.gapMobile), width: remsToPixels(tags.width), widthMobile: remsToPixels(tags.widthMobile) }),
172
+ tagsAllergens: Object.assign(Object.assign({}, tagsAllergens), { gap: remsToPixels(tagsAllergens.gap), gapMobile: remsToPixels(tagsAllergens.gapMobile), padding: boxRemsToPixels(tagsAllergens.padding), paddingMobile: boxRemsToPixels(tagsAllergens.paddingMobile) }),
173
+ text: Object.assign(Object.assign({}, text), { fontSize: remsToPixels(text.fontSize), fontSizeMobile: remsToPixels(text.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, text.fontSizeMobile), padding: boxRemsToPixels(text.padding), paddingMobile: boxRemsToPixels(text.paddingMobile) }),
174
+ title: Object.assign(Object.assign({}, title), { fontSize: remsToPixels(title.fontSize), fontSizeMobile: remsToPixels(title.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, title.fontSizeMobile), padding: boxRemsToPixels(title.padding), paddingMobile: boxRemsToPixels(title.paddingMobile) })
173
175
  };
174
176
  };
175
177
  export const decorateTheme = (theme) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.1.135",
3
+ "version": "0.1.136",
4
4
  "description": "A library of utils for use with Open Tender applications that utilize our cloud-based Order API.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -54,7 +54,7 @@
54
54
  "typescript": "^4.8.2"
55
55
  },
56
56
  "peerDependencies": {
57
- "@open-tender/types": "^0.2.64",
57
+ "@open-tender/types": "^0.2.72",
58
58
  "@reduxjs/toolkit": "^1.8.5",
59
59
  "react": "^18.2.0"
60
60
  },