@open-tender/utils 0.1.111 → 0.1.113
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,4 +1,4 @@
|
|
|
1
|
-
import { Announcements, CheckoutFormCustomer, ContentImages, DateString, Images, RequestError, RequestStatus } from '@open-tender/types';
|
|
1
|
+
import { Announcements, CheckoutFormCustomer, ContentImages, DateString, Images, MenuDisplayedSections, MenuItems, RequestError, RequestStatus } from '@open-tender/types';
|
|
2
2
|
export declare const isString: (str: any) => boolean;
|
|
3
3
|
export declare const isObject: (obj: any) => boolean;
|
|
4
4
|
export declare const isEmpty: (obj?: object | null) => boolean;
|
|
@@ -46,3 +46,50 @@ export declare const hasEntities: <T extends unknown[]>(reducer: {
|
|
|
46
46
|
loading: RequestStatus;
|
|
47
47
|
error: RequestError;
|
|
48
48
|
}) => number | false;
|
|
49
|
+
export declare const getBinaryArr: <T>(arr: T[]) => T[][];
|
|
50
|
+
export declare const makeMenuItemChunks: (items: MenuItems, chunkSize: number) => {
|
|
51
|
+
key: string;
|
|
52
|
+
items: import("@open-tender/types").MenuItem[];
|
|
53
|
+
}[];
|
|
54
|
+
export declare const makeOtherSections: (displayedSections: MenuDisplayedSections, length?: number) => {
|
|
55
|
+
name: string;
|
|
56
|
+
id: string;
|
|
57
|
+
key: string;
|
|
58
|
+
data: {
|
|
59
|
+
key: string;
|
|
60
|
+
allergens: string | null;
|
|
61
|
+
app_image_url: string | null;
|
|
62
|
+
calories: number | null;
|
|
63
|
+
description: string | null;
|
|
64
|
+
dimensions: number[] | null;
|
|
65
|
+
featured_position: number | null;
|
|
66
|
+
id: number;
|
|
67
|
+
increment: number;
|
|
68
|
+
ingredients: string | null;
|
|
69
|
+
is_alcohol: boolean;
|
|
70
|
+
item_id: number;
|
|
71
|
+
large_image_url: string | null;
|
|
72
|
+
max_quantity: number;
|
|
73
|
+
menu_position: number;
|
|
74
|
+
min_quantity: number;
|
|
75
|
+
name: string;
|
|
76
|
+
nutritional_info: import("@open-tender/types").NutritionalInfo | null;
|
|
77
|
+
option_groups: import("@open-tender/types").MenuItemGroups;
|
|
78
|
+
plu: string | null;
|
|
79
|
+
points: number | null;
|
|
80
|
+
pos_display_color: string | null;
|
|
81
|
+
price: string;
|
|
82
|
+
sales_tax_override: `${number}.${number}` | null;
|
|
83
|
+
short_description: string | null;
|
|
84
|
+
short_name: string;
|
|
85
|
+
shorthand: string | null;
|
|
86
|
+
similar_items: number[];
|
|
87
|
+
slug: string;
|
|
88
|
+
small_image_url: string | null;
|
|
89
|
+
suspend_until: number | null;
|
|
90
|
+
tags: string | null;
|
|
91
|
+
taxes: import("@open-tender/types").MenuItemTaxes;
|
|
92
|
+
temperature: import("@open-tender/types").Temperature;
|
|
93
|
+
upsell_items: number[];
|
|
94
|
+
}[];
|
|
95
|
+
}[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasEntities = exports.convertStringToArray = exports.formatDollars = exports.formatQuantity = exports.addCommas = exports.displayPrice = exports.makeSlides = exports.makeImageUrl = exports.makeImageMap = exports.getHeight = exports.getWidth = exports.makeRandomNumberString = exports.checkNotFound = exports.checkGuestData = exports.checkEmpty = exports.validateEmail = exports.dashesToSlashes = exports.slashesToDashes = exports.makeBirthDate = exports.validatePhone = exports.makePhone = exports.cleanPhone = exports.capitalize = exports.serialize = exports.stripTags = exports.slugify = exports.contains = exports.isNum = exports.isEmpty = exports.isObject = exports.isString = void 0;
|
|
3
|
+
exports.makeOtherSections = exports.makeMenuItemChunks = exports.getBinaryArr = exports.hasEntities = exports.convertStringToArray = exports.formatDollars = exports.formatQuantity = exports.addCommas = exports.displayPrice = exports.makeSlides = exports.makeImageUrl = exports.makeImageMap = exports.getHeight = exports.getWidth = exports.makeRandomNumberString = exports.checkNotFound = exports.checkGuestData = exports.checkEmpty = exports.validateEmail = exports.dashesToSlashes = exports.slashesToDashes = exports.makeBirthDate = exports.validatePhone = exports.makePhone = exports.cleanPhone = exports.capitalize = exports.serialize = exports.stripTags = exports.slugify = exports.contains = exports.isNum = exports.isEmpty = exports.isObject = exports.isString = void 0;
|
|
4
4
|
const isString = (str) => {
|
|
5
5
|
return typeof str === 'string';
|
|
6
6
|
};
|
|
@@ -201,3 +201,37 @@ const hasEntities = (reducer) => {
|
|
|
201
201
|
return !error && entities.length;
|
|
202
202
|
};
|
|
203
203
|
exports.hasEntities = hasEntities;
|
|
204
|
+
const getBinaryArr = (arr) => {
|
|
205
|
+
const result = [];
|
|
206
|
+
for (let i = 0; i < arr.length; i += 2) {
|
|
207
|
+
const firstItem = arr[i];
|
|
208
|
+
const secondItem = arr[i + 1];
|
|
209
|
+
result.push(secondItem ? [firstItem, secondItem] : [firstItem]);
|
|
210
|
+
}
|
|
211
|
+
return result;
|
|
212
|
+
};
|
|
213
|
+
exports.getBinaryArr = getBinaryArr;
|
|
214
|
+
const makeMenuItemChunks = (items, chunkSize) => {
|
|
215
|
+
const arr = [];
|
|
216
|
+
for (let i = 0; i < items.length; i += chunkSize) {
|
|
217
|
+
const chunk = items.slice(i, i + chunkSize);
|
|
218
|
+
const key = chunk.map((item, index) => `${i + index}-${item.id}`).join('-');
|
|
219
|
+
arr.push({ key, items: chunk });
|
|
220
|
+
}
|
|
221
|
+
return arr;
|
|
222
|
+
};
|
|
223
|
+
exports.makeMenuItemChunks = makeMenuItemChunks;
|
|
224
|
+
const makeOtherSections = (displayedSections, length = 10) => {
|
|
225
|
+
return Object.entries(displayedSections).map(([section, items]) => {
|
|
226
|
+
const slug = (0, exports.slugify)(section);
|
|
227
|
+
return {
|
|
228
|
+
name: (0, exports.capitalize)(section),
|
|
229
|
+
id: slug,
|
|
230
|
+
key: slug,
|
|
231
|
+
data: items
|
|
232
|
+
.map((i, idx) => (Object.assign(Object.assign({}, i), { key: `${slug}-${i.id}-${idx}` })))
|
|
233
|
+
.slice(0, length)
|
|
234
|
+
};
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
exports.makeOtherSections = makeOtherSections;
|
package/dist/cjs/utils/theme.js
CHANGED
|
@@ -155,6 +155,10 @@ const makeItem = (item) => {
|
|
|
155
155
|
const { mobile } = item;
|
|
156
156
|
return Object.assign(Object.assign({}, mobile), { padding: (0, exports.remsToPixels)(mobile.padding), imagePadding: (0, exports.remsToPixels)(mobile.imagePadding), maxWidth: (0, exports.remsToPixels)(mobile.maxWidth), imageMinHeight: (0, exports.remsToPixels)(mobile.imageMinHeight), imageMaxHeight: (0, exports.remsToPixels)(mobile.imageMaxHeight) });
|
|
157
157
|
};
|
|
158
|
+
const makeCategories = (categories) => {
|
|
159
|
+
const { mobile } = categories;
|
|
160
|
+
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) });
|
|
161
|
+
};
|
|
158
162
|
const makeMenuItems = (menuItems) => {
|
|
159
163
|
const { allergens, box, calories, container, content, image, price, tags, text, title } = menuItems;
|
|
160
164
|
return {
|
|
@@ -181,9 +185,11 @@ const decorateTheme = (theme) => {
|
|
|
181
185
|
const cards = makeCards(theme.cards);
|
|
182
186
|
const welcome = makeWelcome(theme.welcome);
|
|
183
187
|
const item = makeItem(theme.item);
|
|
188
|
+
const categories = makeCategories(theme.categories);
|
|
184
189
|
const menuItems = makeMenuItems(theme.menuItems);
|
|
185
190
|
return Object.assign(Object.assign({}, theme), { fonts: fonts, lineHeight, layout: layout, buttons: buttons, border, inputs: inputs, counts,
|
|
186
|
-
cards, welcome: welcome, item: item,
|
|
191
|
+
cards, welcome: welcome, item: item, categories,
|
|
192
|
+
menuItems });
|
|
187
193
|
};
|
|
188
194
|
exports.decorateTheme = decorateTheme;
|
|
189
195
|
const hexToRgbA = (hex, opacity) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Announcements, CheckoutFormCustomer, ContentImages, DateString, Images, RequestError, RequestStatus } from '@open-tender/types';
|
|
1
|
+
import { Announcements, CheckoutFormCustomer, ContentImages, DateString, Images, MenuDisplayedSections, MenuItems, RequestError, RequestStatus } from '@open-tender/types';
|
|
2
2
|
export declare const isString: (str: any) => boolean;
|
|
3
3
|
export declare const isObject: (obj: any) => boolean;
|
|
4
4
|
export declare const isEmpty: (obj?: object | null) => boolean;
|
|
@@ -46,3 +46,50 @@ export declare const hasEntities: <T extends unknown[]>(reducer: {
|
|
|
46
46
|
loading: RequestStatus;
|
|
47
47
|
error: RequestError;
|
|
48
48
|
}) => number | false;
|
|
49
|
+
export declare const getBinaryArr: <T>(arr: T[]) => T[][];
|
|
50
|
+
export declare const makeMenuItemChunks: (items: MenuItems, chunkSize: number) => {
|
|
51
|
+
key: string;
|
|
52
|
+
items: import("@open-tender/types").MenuItem[];
|
|
53
|
+
}[];
|
|
54
|
+
export declare const makeOtherSections: (displayedSections: MenuDisplayedSections, length?: number) => {
|
|
55
|
+
name: string;
|
|
56
|
+
id: string;
|
|
57
|
+
key: string;
|
|
58
|
+
data: {
|
|
59
|
+
key: string;
|
|
60
|
+
allergens: string | null;
|
|
61
|
+
app_image_url: string | null;
|
|
62
|
+
calories: number | null;
|
|
63
|
+
description: string | null;
|
|
64
|
+
dimensions: number[] | null;
|
|
65
|
+
featured_position: number | null;
|
|
66
|
+
id: number;
|
|
67
|
+
increment: number;
|
|
68
|
+
ingredients: string | null;
|
|
69
|
+
is_alcohol: boolean;
|
|
70
|
+
item_id: number;
|
|
71
|
+
large_image_url: string | null;
|
|
72
|
+
max_quantity: number;
|
|
73
|
+
menu_position: number;
|
|
74
|
+
min_quantity: number;
|
|
75
|
+
name: string;
|
|
76
|
+
nutritional_info: import("@open-tender/types").NutritionalInfo | null;
|
|
77
|
+
option_groups: import("@open-tender/types").MenuItemGroups;
|
|
78
|
+
plu: string | null;
|
|
79
|
+
points: number | null;
|
|
80
|
+
pos_display_color: string | null;
|
|
81
|
+
price: string;
|
|
82
|
+
sales_tax_override: `${number}.${number}` | null;
|
|
83
|
+
short_description: string | null;
|
|
84
|
+
short_name: string;
|
|
85
|
+
shorthand: string | null;
|
|
86
|
+
similar_items: number[];
|
|
87
|
+
slug: string;
|
|
88
|
+
small_image_url: string | null;
|
|
89
|
+
suspend_until: number | null;
|
|
90
|
+
tags: string | null;
|
|
91
|
+
taxes: import("@open-tender/types").MenuItemTaxes;
|
|
92
|
+
temperature: import("@open-tender/types").Temperature;
|
|
93
|
+
upsell_items: number[];
|
|
94
|
+
}[];
|
|
95
|
+
}[];
|
|
@@ -167,3 +167,34 @@ export const hasEntities = (reducer) => {
|
|
|
167
167
|
return false;
|
|
168
168
|
return !error && entities.length;
|
|
169
169
|
};
|
|
170
|
+
export const getBinaryArr = (arr) => {
|
|
171
|
+
const result = [];
|
|
172
|
+
for (let i = 0; i < arr.length; i += 2) {
|
|
173
|
+
const firstItem = arr[i];
|
|
174
|
+
const secondItem = arr[i + 1];
|
|
175
|
+
result.push(secondItem ? [firstItem, secondItem] : [firstItem]);
|
|
176
|
+
}
|
|
177
|
+
return result;
|
|
178
|
+
};
|
|
179
|
+
export const makeMenuItemChunks = (items, chunkSize) => {
|
|
180
|
+
const arr = [];
|
|
181
|
+
for (let i = 0; i < items.length; i += chunkSize) {
|
|
182
|
+
const chunk = items.slice(i, i + chunkSize);
|
|
183
|
+
const key = chunk.map((item, index) => `${i + index}-${item.id}`).join('-');
|
|
184
|
+
arr.push({ key, items: chunk });
|
|
185
|
+
}
|
|
186
|
+
return arr;
|
|
187
|
+
};
|
|
188
|
+
export const makeOtherSections = (displayedSections, length = 10) => {
|
|
189
|
+
return Object.entries(displayedSections).map(([section, items]) => {
|
|
190
|
+
const slug = slugify(section);
|
|
191
|
+
return {
|
|
192
|
+
name: capitalize(section),
|
|
193
|
+
id: slug,
|
|
194
|
+
key: slug,
|
|
195
|
+
data: items
|
|
196
|
+
.map((i, idx) => (Object.assign(Object.assign({}, i), { key: `${slug}-${i.id}-${idx}` })))
|
|
197
|
+
.slice(0, length)
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
};
|
package/dist/esm/utils/theme.js
CHANGED
|
@@ -146,6 +146,10 @@ const makeItem = (item) => {
|
|
|
146
146
|
const { mobile } = item;
|
|
147
147
|
return Object.assign(Object.assign({}, mobile), { padding: remsToPixels(mobile.padding), imagePadding: remsToPixels(mobile.imagePadding), maxWidth: remsToPixels(mobile.maxWidth), imageMinHeight: remsToPixels(mobile.imageMinHeight), imageMaxHeight: remsToPixels(mobile.imageMaxHeight) });
|
|
148
148
|
};
|
|
149
|
+
const makeCategories = (categories) => {
|
|
150
|
+
const { mobile } = categories;
|
|
151
|
+
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) });
|
|
152
|
+
};
|
|
149
153
|
const makeMenuItems = (menuItems) => {
|
|
150
154
|
const { allergens, box, calories, container, content, image, price, tags, text, title } = menuItems;
|
|
151
155
|
return {
|
|
@@ -172,9 +176,11 @@ export const decorateTheme = (theme) => {
|
|
|
172
176
|
const cards = makeCards(theme.cards);
|
|
173
177
|
const welcome = makeWelcome(theme.welcome);
|
|
174
178
|
const item = makeItem(theme.item);
|
|
179
|
+
const categories = makeCategories(theme.categories);
|
|
175
180
|
const menuItems = makeMenuItems(theme.menuItems);
|
|
176
181
|
return Object.assign(Object.assign({}, theme), { fonts: fonts, lineHeight, layout: layout, buttons: buttons, border, inputs: inputs, counts,
|
|
177
|
-
cards, welcome: welcome, item: item,
|
|
182
|
+
cards, welcome: welcome, item: item, categories,
|
|
183
|
+
menuItems });
|
|
178
184
|
};
|
|
179
185
|
export const hexToRgbA = (hex, opacity) => {
|
|
180
186
|
let c;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.113",
|
|
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.52",
|
|
58
58
|
"@reduxjs/toolkit": "^1.8.5",
|
|
59
59
|
"react": "^18.2.0"
|
|
60
60
|
},
|
package/dist/.DS_Store
DELETED
|
Binary file
|