@open-tender/utils 0.1.116 → 0.1.118
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.
- package/dist/cjs/utils/cart.d.ts +2 -2
- package/dist/cjs/utils/theme.js +14 -8
- package/dist/esm/utils/cart.d.ts +2 -2
- package/dist/esm/utils/theme.js +14 -8
- package/package.json +2 -2
- package/dist/.DS_Store +0 -0
package/dist/cjs/utils/cart.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cart, CartItem, CartItemGroups, CartLevels, CartItemOption, CartOwner, CheckoutConfig, CheckoutFormAddress, CheckoutFormCustomer, CheckoutPromoCodes, CheckoutTenders, DisplayItem, DisplayItems, Favorites, GroupOrderGuest, GroupOrderGuests, MenuCategories, MenuItem, MenuItems, Money, NutritionalInfo, NutritionalInfoCalcs, Order, OrderCreate, OrderCreateDiscounts, OrderCreateSurcharges, OrderData, OrderItem, OrderItemGroups, Orders, SimpleCart, SimpleCartGroups, SimpleCartItem, SoldOut, Images, CartErrors, BaseItem } from '@open-tender/types';
|
|
1
|
+
import { Cart, CartItem, CartItemGroups, CartLevels, CartItemOption, CartOwner, CheckoutConfig, CheckoutFormAddress, CheckoutFormCustomer, CheckoutPromoCodes, CheckoutTenders, DisplayItem, DisplayItems, Favorites, GroupOrderGuest, GroupOrderGuests, MenuCategories, MenuItem, MenuItems, Money, NutritionalInfo, NutritionalInfoCalcs, Order, OrderCreate, OrderCreateDiscounts, OrderCreateSurcharges, OrderData, OrderItem, OrderItemGroups, Orders, SimpleCart, SimpleCartGroups, SimpleCartItem, SoldOut, Images, CartErrors, BaseItem, FavoritesLookup } from '@open-tender/types';
|
|
2
2
|
export declare const getItemOptions: <T extends BaseItem>(item: T) => BaseItem[];
|
|
3
3
|
export declare const makeModifierNames: <T extends BaseItem>(item: T) => string;
|
|
4
4
|
export declare const hasGroupsBelowMin: (option: CartItemOption | null, groups: CartItemGroups) => boolean;
|
|
@@ -138,7 +138,7 @@ export declare const makeDisplayItemGroups: (optionGroups: OrderItemGroups) => {
|
|
|
138
138
|
export declare const makeDisplayItem: (item: OrderItem, isOption?: boolean) => DisplayItem;
|
|
139
139
|
export declare const makeDisplayItems: (orders: Orders) => DisplayItem[];
|
|
140
140
|
export declare const makeUniqueDisplayItems: (orders: Orders) => DisplayItems;
|
|
141
|
-
export declare const makeFavoritesLookup: (favorites: Favorites) =>
|
|
141
|
+
export declare const makeFavoritesLookup: (favorites: Favorites) => FavoritesLookup;
|
|
142
142
|
export declare const makeItemSignature: (item: SimpleCartItem) => string;
|
|
143
143
|
export declare const makeCartItemSignature: (item: CartItem) => string;
|
|
144
144
|
export declare const addItem: (cart: Cart, item: CartItem) => {
|
package/dist/cjs/utils/theme.js
CHANGED
|
@@ -160,19 +160,25 @@ const makeCategories = (categories) => {
|
|
|
160
160
|
const { mobile } = categories;
|
|
161
161
|
return Object.assign(Object.assign({}, mobile), { borderRadius: (0, exports.remsToPixels)(mobile.borderRadius), containerMaxWidth: (0, exports.remsToPixels)(mobile.containerMaxWidth), gap: (0, exports.remsToPixels)(mobile.gap), gapDouble: (0, exports.remsToPixels)(mobile.gapDouble), gapHalf: (0, exports.remsToPixels)(mobile.gapHalf), imageBorderRadius: (0, exports.remsToPixels)(mobile.imageBorderRadius), lineHeight: (0, exports.remsToPixels)(mobile.lineHeight), lineMargin: (0, exports.remsToPixels)(mobile.lineMargin), lineWidth: (0, exports.remsToPixels)(mobile.lineWidth), maxWidth: (0, exports.remsToPixels)(mobile.maxWidth), minWidth: (0, exports.remsToPixels)(mobile.minWidth), paddingBottom: (0, exports.remsToPixels)(mobile.paddingBottom), paddingHorizontal: (0, exports.remsToPixels)(mobile.paddingHorizontal), paddingTop: (0, exports.remsToPixels)(mobile.paddingTop), subtitleSize: (0, exports.remsToPixels)(mobile.subtitleSize), titleSize: (0, exports.remsToPixels)(mobile.titleSize) });
|
|
162
162
|
};
|
|
163
|
-
const
|
|
163
|
+
const fontSizeToLineHeight = (lineHeight, fontSize) => {
|
|
164
|
+
var _a;
|
|
165
|
+
const lineHt = (_a = parseFloat(lineHeight)) !== null && _a !== void 0 ? _a : 1;
|
|
166
|
+
const textFontSize = (0, exports.remsToPixels)(fontSize);
|
|
167
|
+
return `${(lineHt * (0, exports.pixelsToFloat)(textFontSize)).toFixed(2)}px`;
|
|
168
|
+
};
|
|
169
|
+
const makeMenuItems = (menuItems, lineHeight) => {
|
|
164
170
|
const { allergens, box, calories, container, content, image, price, tags, text, title } = menuItems;
|
|
165
171
|
return {
|
|
166
|
-
allergens: Object.assign(Object.assign({}, allergens), { fontSize: (0, exports.remsToPixels)(allergens.fontSize), fontSizeMobile: (0, exports.remsToPixels)(allergens.fontSizeMobile) }),
|
|
172
|
+
allergens: Object.assign(Object.assign({}, allergens), { fontSize: (0, exports.remsToPixels)(allergens.fontSize), fontSizeMobile: (0, exports.remsToPixels)(allergens.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, allergens.fontSizeMobile) }),
|
|
167
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) }),
|
|
168
|
-
calories: Object.assign(Object.assign({}, calories), { fontSize: (0, exports.remsToPixels)(calories.fontSize), fontSizeMobile: (0, exports.remsToPixels)(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) }),
|
|
169
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) }),
|
|
170
176
|
content: Object.assign(Object.assign({}, content), { padding: boxRemsToPixels(content.padding), paddingMobile: boxRemsToPixels(content.paddingMobile) }),
|
|
171
177
|
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) }),
|
|
172
|
-
price: Object.assign(Object.assign({}, price), { fontSize: (0, exports.remsToPixels)(price.fontSize), fontSizeMobile: (0, exports.remsToPixels)(price.fontSizeMobile) }),
|
|
173
|
-
tags: Object.assign(Object.assign({}, tags), { fontSize: (0, exports.remsToPixels)(tags.fontSize), fontSizeMobile: (0, exports.remsToPixels)(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) }),
|
|
174
|
-
text: Object.assign(Object.assign({}, text), { fontSize: (0, exports.remsToPixels)(text.fontSize), fontSizeMobile: (0, exports.remsToPixels)(text.fontSizeMobile) }),
|
|
175
|
-
title: Object.assign(Object.assign({}, title), { fontSize: (0, exports.remsToPixels)(title.fontSize), fontSizeMobile: (0, exports.remsToPixels)(title.fontSizeMobile) })
|
|
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) })
|
|
176
182
|
};
|
|
177
183
|
};
|
|
178
184
|
const decorateTheme = (theme) => {
|
|
@@ -187,7 +193,7 @@ const decorateTheme = (theme) => {
|
|
|
187
193
|
const welcome = makeWelcome(theme.welcome);
|
|
188
194
|
const item = makeItem(theme.item);
|
|
189
195
|
const categories = makeCategories(theme.categories);
|
|
190
|
-
const menuItems = makeMenuItems(theme.menuItems);
|
|
196
|
+
const menuItems = makeMenuItems(theme.menuItems, theme.lineHeight);
|
|
191
197
|
return Object.assign(Object.assign({}, theme), { fonts: fonts, lineHeight, layout: layout, buttons: buttons, border, inputs: inputs, counts,
|
|
192
198
|
cards, welcome: welcome, item: item, categories,
|
|
193
199
|
menuItems });
|
package/dist/esm/utils/cart.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cart, CartItem, CartItemGroups, CartLevels, CartItemOption, CartOwner, CheckoutConfig, CheckoutFormAddress, CheckoutFormCustomer, CheckoutPromoCodes, CheckoutTenders, DisplayItem, DisplayItems, Favorites, GroupOrderGuest, GroupOrderGuests, MenuCategories, MenuItem, MenuItems, Money, NutritionalInfo, NutritionalInfoCalcs, Order, OrderCreate, OrderCreateDiscounts, OrderCreateSurcharges, OrderData, OrderItem, OrderItemGroups, Orders, SimpleCart, SimpleCartGroups, SimpleCartItem, SoldOut, Images, CartErrors, BaseItem } from '@open-tender/types';
|
|
1
|
+
import { Cart, CartItem, CartItemGroups, CartLevels, CartItemOption, CartOwner, CheckoutConfig, CheckoutFormAddress, CheckoutFormCustomer, CheckoutPromoCodes, CheckoutTenders, DisplayItem, DisplayItems, Favorites, GroupOrderGuest, GroupOrderGuests, MenuCategories, MenuItem, MenuItems, Money, NutritionalInfo, NutritionalInfoCalcs, Order, OrderCreate, OrderCreateDiscounts, OrderCreateSurcharges, OrderData, OrderItem, OrderItemGroups, Orders, SimpleCart, SimpleCartGroups, SimpleCartItem, SoldOut, Images, CartErrors, BaseItem, FavoritesLookup } from '@open-tender/types';
|
|
2
2
|
export declare const getItemOptions: <T extends BaseItem>(item: T) => BaseItem[];
|
|
3
3
|
export declare const makeModifierNames: <T extends BaseItem>(item: T) => string;
|
|
4
4
|
export declare const hasGroupsBelowMin: (option: CartItemOption | null, groups: CartItemGroups) => boolean;
|
|
@@ -138,7 +138,7 @@ export declare const makeDisplayItemGroups: (optionGroups: OrderItemGroups) => {
|
|
|
138
138
|
export declare const makeDisplayItem: (item: OrderItem, isOption?: boolean) => DisplayItem;
|
|
139
139
|
export declare const makeDisplayItems: (orders: Orders) => DisplayItem[];
|
|
140
140
|
export declare const makeUniqueDisplayItems: (orders: Orders) => DisplayItems;
|
|
141
|
-
export declare const makeFavoritesLookup: (favorites: Favorites) =>
|
|
141
|
+
export declare const makeFavoritesLookup: (favorites: Favorites) => FavoritesLookup;
|
|
142
142
|
export declare const makeItemSignature: (item: SimpleCartItem) => string;
|
|
143
143
|
export declare const makeCartItemSignature: (item: CartItem) => string;
|
|
144
144
|
export declare const addItem: (cart: Cart, item: CartItem) => {
|
package/dist/esm/utils/theme.js
CHANGED
|
@@ -151,19 +151,25 @@ const makeCategories = (categories) => {
|
|
|
151
151
|
const { mobile } = categories;
|
|
152
152
|
return Object.assign(Object.assign({}, mobile), { borderRadius: remsToPixels(mobile.borderRadius), containerMaxWidth: remsToPixels(mobile.containerMaxWidth), gap: remsToPixels(mobile.gap), gapDouble: remsToPixels(mobile.gapDouble), gapHalf: remsToPixels(mobile.gapHalf), imageBorderRadius: remsToPixels(mobile.imageBorderRadius), lineHeight: remsToPixels(mobile.lineHeight), lineMargin: remsToPixels(mobile.lineMargin), lineWidth: remsToPixels(mobile.lineWidth), maxWidth: remsToPixels(mobile.maxWidth), minWidth: remsToPixels(mobile.minWidth), paddingBottom: remsToPixels(mobile.paddingBottom), paddingHorizontal: remsToPixels(mobile.paddingHorizontal), paddingTop: remsToPixels(mobile.paddingTop), subtitleSize: remsToPixels(mobile.subtitleSize), titleSize: remsToPixels(mobile.titleSize) });
|
|
153
153
|
};
|
|
154
|
-
const
|
|
154
|
+
const fontSizeToLineHeight = (lineHeight, fontSize) => {
|
|
155
|
+
var _a;
|
|
156
|
+
const lineHt = (_a = parseFloat(lineHeight)) !== null && _a !== void 0 ? _a : 1;
|
|
157
|
+
const textFontSize = remsToPixels(fontSize);
|
|
158
|
+
return `${(lineHt * pixelsToFloat(textFontSize)).toFixed(2)}px`;
|
|
159
|
+
};
|
|
160
|
+
const makeMenuItems = (menuItems, lineHeight) => {
|
|
155
161
|
const { allergens, box, calories, container, content, image, price, tags, text, title } = menuItems;
|
|
156
162
|
return {
|
|
157
|
-
allergens: Object.assign(Object.assign({}, allergens), { fontSize: remsToPixels(allergens.fontSize), fontSizeMobile: remsToPixels(allergens.fontSizeMobile) }),
|
|
163
|
+
allergens: Object.assign(Object.assign({}, allergens), { fontSize: remsToPixels(allergens.fontSize), fontSizeMobile: remsToPixels(allergens.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, allergens.fontSizeMobile) }),
|
|
158
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) }),
|
|
159
|
-
calories: Object.assign(Object.assign({}, calories), { fontSize: remsToPixels(calories.fontSize), fontSizeMobile: remsToPixels(calories.fontSizeMobile) }),
|
|
165
|
+
calories: Object.assign(Object.assign({}, calories), { fontSize: remsToPixels(calories.fontSize), fontSizeMobile: remsToPixels(calories.fontSizeMobile), lineHeight: fontSizeToLineHeight(lineHeight, calories.fontSizeMobile) }),
|
|
160
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) }),
|
|
161
167
|
content: Object.assign(Object.assign({}, content), { padding: boxRemsToPixels(content.padding), paddingMobile: boxRemsToPixels(content.paddingMobile) }),
|
|
162
168
|
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) }),
|
|
163
|
-
price: Object.assign(Object.assign({}, price), { fontSize: remsToPixels(price.fontSize), fontSizeMobile: remsToPixels(price.fontSizeMobile) }),
|
|
164
|
-
tags: Object.assign(Object.assign({}, tags), { fontSize: remsToPixels(tags.fontSize), fontSizeMobile: remsToPixels(tags.fontSizeMobile), gap: remsToPixels(tags.gap), gapMobile: remsToPixels(tags.gapMobile), width: remsToPixels(tags.width), widthMobile: remsToPixels(tags.widthMobile) }),
|
|
165
|
-
text: Object.assign(Object.assign({}, text), { fontSize: remsToPixels(text.fontSize), fontSizeMobile: remsToPixels(text.fontSizeMobile) }),
|
|
166
|
-
title: Object.assign(Object.assign({}, title), { fontSize: remsToPixels(title.fontSize), fontSizeMobile: remsToPixels(title.fontSizeMobile) })
|
|
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) })
|
|
167
173
|
};
|
|
168
174
|
};
|
|
169
175
|
export const decorateTheme = (theme) => {
|
|
@@ -178,7 +184,7 @@ export const decorateTheme = (theme) => {
|
|
|
178
184
|
const welcome = makeWelcome(theme.welcome);
|
|
179
185
|
const item = makeItem(theme.item);
|
|
180
186
|
const categories = makeCategories(theme.categories);
|
|
181
|
-
const menuItems = makeMenuItems(theme.menuItems);
|
|
187
|
+
const menuItems = makeMenuItems(theme.menuItems, theme.lineHeight);
|
|
182
188
|
return Object.assign(Object.assign({}, theme), { fonts: fonts, lineHeight, layout: layout, buttons: buttons, border, inputs: inputs, counts,
|
|
183
189
|
cards, welcome: welcome, item: item, categories,
|
|
184
190
|
menuItems });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.118",
|
|
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.
|
|
57
|
+
"@open-tender/types": "^0.2.54",
|
|
58
58
|
"@reduxjs/toolkit": "^1.8.5",
|
|
59
59
|
"react": "^18.2.0"
|
|
60
60
|
},
|
package/dist/.DS_Store
DELETED
|
Binary file
|