@open-tender/utils 0.1.16 → 0.1.17
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/hooks/useAddressForm.d.ts +2 -2
- package/dist/cjs/utils/cart.d.ts +3 -6
- package/dist/cjs/utils/cart.js +1 -1
- package/dist/cjs/utils/errors.d.ts +1 -1
- package/dist/cjs/utils/theme.d.ts +12 -3
- package/dist/cjs/utils/theme.js +4 -4
- package/dist/esm/hooks/useAddressForm.d.ts +2 -2
- package/dist/esm/utils/cart.d.ts +3 -6
- package/dist/esm/utils/cart.js +1 -1
- package/dist/esm/utils/errors.d.ts +1 -1
- package/dist/esm/utils/theme.d.ts +12 -3
- package/dist/esm/utils/theme.js +4 -4
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Address, FormFieldType, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export declare const useAddressForm: (address: Address, loading: RequestStatus, error:
|
|
2
|
+
import { Address, FormFieldType, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export declare const useAddressForm: (address: Address, loading: RequestStatus, error: RequestError, update: (addressId: number, updatedData: Address, callback: () => void) => void, callback: () => void) => {
|
|
4
4
|
fields: FormFieldType[];
|
|
5
5
|
data: Address;
|
|
6
6
|
errors: any;
|
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 } 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 } from '@open-tender/types';
|
|
2
2
|
export declare const getItemOptions: (item: Partial<CartItem>) => CartItemOption[];
|
|
3
3
|
export declare const makeModifierNames: (item: CartItem) => string;
|
|
4
4
|
export declare const hasGroupsBelowMin: (option: CartItemOption | null, groups: CartItemGroups) => boolean;
|
|
@@ -179,11 +179,8 @@ export declare const makeSimpleCart: <C extends {
|
|
|
179
179
|
notes: string;
|
|
180
180
|
}[];
|
|
181
181
|
export declare const validateCart: (cart: Cart, categories: MenuCategories, soldOut: SoldOut) => {
|
|
182
|
-
newCart:
|
|
183
|
-
errors:
|
|
184
|
-
missingItems: Cart;
|
|
185
|
-
invalidItems: Cart;
|
|
186
|
-
} | null;
|
|
182
|
+
newCart: Cart;
|
|
183
|
+
errors: CartErrors | null;
|
|
187
184
|
};
|
|
188
185
|
export declare const getDefaultTip: (config: CheckoutConfig) => string | null;
|
|
189
186
|
export declare const prepareOrder: (data: OrderData) => OrderCreate;
|
package/dist/cjs/utils/cart.js
CHANGED
|
@@ -740,7 +740,7 @@ const validateCart = (cart, categories, soldOut) => {
|
|
|
740
740
|
if (missingItems.length || invalidItems.length) {
|
|
741
741
|
errors = { missingItems, invalidItems };
|
|
742
742
|
}
|
|
743
|
-
return { newCart, errors };
|
|
743
|
+
return { newCart: newCart, errors };
|
|
744
744
|
};
|
|
745
745
|
exports.validateCart = validateCart;
|
|
746
746
|
/* order submission */
|
|
@@ -11,7 +11,7 @@ export declare const handleRespError: (err: RequestError) => {
|
|
|
11
11
|
export declare const processError: (msg: string | null) => string;
|
|
12
12
|
export declare const handleFormErrors: (params: Record<string, string | null>) => Record<string, string>;
|
|
13
13
|
export declare const makeFormErrors: (error: RequestError) => Record<string, string>;
|
|
14
|
-
export declare const handleCheckoutErrors: (errors:
|
|
14
|
+
export declare const handleCheckoutErrors: (errors: RequestError, asMessages?: boolean) => {};
|
|
15
15
|
export declare const errMessages: {
|
|
16
16
|
unknown: string;
|
|
17
17
|
forbidden: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ThemeLayout, Theme, ThemeWelcomeStyles, ThemeItemStyles } from '@open-tender/types';
|
|
2
2
|
export declare const makeLineHeight: (lineHeight?: string, fontSize?: string) => string;
|
|
3
3
|
export declare const remsToPixels: (rems?: string, responsive?: boolean) => string;
|
|
4
4
|
export declare const remsToNumber: (rems: string) => number;
|
|
5
|
-
export declare const objRemsToPixels: <T extends Partial<
|
|
5
|
+
export declare const objRemsToPixels: <T extends Partial<ThemeLayout & {
|
|
6
6
|
big: string;
|
|
7
7
|
giga: string;
|
|
8
8
|
h1: string;
|
|
@@ -22,5 +22,14 @@ export declare const objRemsToPixels: <T extends Partial<ConfigThemeLayout & {
|
|
|
22
22
|
}>>(object: T, responsive?: boolean) => Partial<T>;
|
|
23
23
|
export declare const pixelsToInt: (pixels: string) => string | number;
|
|
24
24
|
export declare const pixelsToFloat: (pixels: string) => string | number;
|
|
25
|
-
|
|
25
|
+
interface ThemeWelcomeStylesApp extends Omit<ThemeWelcomeStyles, 'titleLineHeight' | 'subtitleLineHeight'> {
|
|
26
|
+
titleLineHeight: string;
|
|
27
|
+
subtitleLineHeight: string;
|
|
28
|
+
}
|
|
29
|
+
interface AppTheme extends Omit<Theme, 'welcome' | 'item'> {
|
|
30
|
+
welcome: ThemeWelcomeStylesApp;
|
|
31
|
+
item: ThemeItemStyles;
|
|
32
|
+
}
|
|
33
|
+
export declare const decorateTheme: (theme: Theme) => AppTheme;
|
|
26
34
|
export declare const hexToRgbA: (hex: string, opacity: number) => string | null;
|
|
35
|
+
export {};
|
package/dist/cjs/utils/theme.js
CHANGED
|
@@ -139,15 +139,15 @@ const makeWelcome = (welcome) => {
|
|
|
139
139
|
marginBottom: (0, exports.remsToPixels)(mobile === null || mobile === void 0 ? void 0 : mobile.marginBottom),
|
|
140
140
|
titleMarginLeft: (0, exports.remsToPixels)(mobile === null || mobile === void 0 ? void 0 : mobile.titleMarginLeft),
|
|
141
141
|
titleSize,
|
|
142
|
-
titleLineHeight: (0, exports.makeLineHeight)(mobile === null || mobile === void 0 ? void 0 : mobile.titleLineHeight, titleSize),
|
|
142
|
+
titleLineHeight: (0, exports.makeLineHeight)(mobile === null || mobile === void 0 ? void 0 : mobile.titleLineHeight.toFixed(5), titleSize),
|
|
143
143
|
subtitleSize,
|
|
144
|
-
subtitleLineHeight: (0, exports.makeLineHeight)(mobile === null || mobile === void 0 ? void 0 : mobile.subtitleLineHeight, subtitleSize),
|
|
144
|
+
subtitleLineHeight: (0, exports.makeLineHeight)(mobile === null || mobile === void 0 ? void 0 : mobile.subtitleLineHeight.toFixed(5), subtitleSize),
|
|
145
145
|
subtitleMarginTop: (0, exports.remsToPixels)(mobile === null || mobile === void 0 ? void 0 : mobile.subtitleMarginTop)
|
|
146
146
|
};
|
|
147
147
|
};
|
|
148
148
|
const makeItem = (item) => {
|
|
149
149
|
const { mobile } = item;
|
|
150
|
-
return Object.assign(Object.assign({},
|
|
150
|
+
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) });
|
|
151
151
|
};
|
|
152
152
|
const decorateTheme = (theme) => {
|
|
153
153
|
const fonts = makeFonts(theme.fonts, theme.lineHeight);
|
|
@@ -161,7 +161,7 @@ const decorateTheme = (theme) => {
|
|
|
161
161
|
const welcome = makeWelcome(theme.welcome);
|
|
162
162
|
const item = makeItem(theme.item);
|
|
163
163
|
return Object.assign(Object.assign({}, theme), { fonts: fonts, lineHeight, layout: layout, buttons: buttons, border, inputs: inputs, counts,
|
|
164
|
-
cards, welcome: welcome, item });
|
|
164
|
+
cards, welcome: welcome, item: item });
|
|
165
165
|
};
|
|
166
166
|
exports.decorateTheme = decorateTheme;
|
|
167
167
|
const hexToRgbA = (hex, opacity) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Address, FormFieldType, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export declare const useAddressForm: (address: Address, loading: RequestStatus, error:
|
|
2
|
+
import { Address, FormFieldType, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export declare const useAddressForm: (address: Address, loading: RequestStatus, error: RequestError, update: (addressId: number, updatedData: Address, callback: () => void) => void, callback: () => void) => {
|
|
4
4
|
fields: FormFieldType[];
|
|
5
5
|
data: Address;
|
|
6
6
|
errors: any;
|
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 } 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 } from '@open-tender/types';
|
|
2
2
|
export declare const getItemOptions: (item: Partial<CartItem>) => CartItemOption[];
|
|
3
3
|
export declare const makeModifierNames: (item: CartItem) => string;
|
|
4
4
|
export declare const hasGroupsBelowMin: (option: CartItemOption | null, groups: CartItemGroups) => boolean;
|
|
@@ -179,11 +179,8 @@ export declare const makeSimpleCart: <C extends {
|
|
|
179
179
|
notes: string;
|
|
180
180
|
}[];
|
|
181
181
|
export declare const validateCart: (cart: Cart, categories: MenuCategories, soldOut: SoldOut) => {
|
|
182
|
-
newCart:
|
|
183
|
-
errors:
|
|
184
|
-
missingItems: Cart;
|
|
185
|
-
invalidItems: Cart;
|
|
186
|
-
} | null;
|
|
182
|
+
newCart: Cart;
|
|
183
|
+
errors: CartErrors | null;
|
|
187
184
|
};
|
|
188
185
|
export declare const getDefaultTip: (config: CheckoutConfig) => string | null;
|
|
189
186
|
export declare const prepareOrder: (data: OrderData) => OrderCreate;
|
package/dist/esm/utils/cart.js
CHANGED
|
@@ -708,7 +708,7 @@ export const validateCart = (cart, categories, soldOut) => {
|
|
|
708
708
|
if (missingItems.length || invalidItems.length) {
|
|
709
709
|
errors = { missingItems, invalidItems };
|
|
710
710
|
}
|
|
711
|
-
return { newCart, errors };
|
|
711
|
+
return { newCart: newCart, errors };
|
|
712
712
|
};
|
|
713
713
|
/* order submission */
|
|
714
714
|
export const getDefaultTip = (config) => {
|
|
@@ -11,7 +11,7 @@ export declare const handleRespError: (err: RequestError) => {
|
|
|
11
11
|
export declare const processError: (msg: string | null) => string;
|
|
12
12
|
export declare const handleFormErrors: (params: Record<string, string | null>) => Record<string, string>;
|
|
13
13
|
export declare const makeFormErrors: (error: RequestError) => Record<string, string>;
|
|
14
|
-
export declare const handleCheckoutErrors: (errors:
|
|
14
|
+
export declare const handleCheckoutErrors: (errors: RequestError, asMessages?: boolean) => {};
|
|
15
15
|
export declare const errMessages: {
|
|
16
16
|
unknown: string;
|
|
17
17
|
forbidden: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ThemeLayout, Theme, ThemeWelcomeStyles, ThemeItemStyles } from '@open-tender/types';
|
|
2
2
|
export declare const makeLineHeight: (lineHeight?: string, fontSize?: string) => string;
|
|
3
3
|
export declare const remsToPixels: (rems?: string, responsive?: boolean) => string;
|
|
4
4
|
export declare const remsToNumber: (rems: string) => number;
|
|
5
|
-
export declare const objRemsToPixels: <T extends Partial<
|
|
5
|
+
export declare const objRemsToPixels: <T extends Partial<ThemeLayout & {
|
|
6
6
|
big: string;
|
|
7
7
|
giga: string;
|
|
8
8
|
h1: string;
|
|
@@ -22,5 +22,14 @@ export declare const objRemsToPixels: <T extends Partial<ConfigThemeLayout & {
|
|
|
22
22
|
}>>(object: T, responsive?: boolean) => Partial<T>;
|
|
23
23
|
export declare const pixelsToInt: (pixels: string) => string | number;
|
|
24
24
|
export declare const pixelsToFloat: (pixels: string) => string | number;
|
|
25
|
-
|
|
25
|
+
interface ThemeWelcomeStylesApp extends Omit<ThemeWelcomeStyles, 'titleLineHeight' | 'subtitleLineHeight'> {
|
|
26
|
+
titleLineHeight: string;
|
|
27
|
+
subtitleLineHeight: string;
|
|
28
|
+
}
|
|
29
|
+
interface AppTheme extends Omit<Theme, 'welcome' | 'item'> {
|
|
30
|
+
welcome: ThemeWelcomeStylesApp;
|
|
31
|
+
item: ThemeItemStyles;
|
|
32
|
+
}
|
|
33
|
+
export declare const decorateTheme: (theme: Theme) => AppTheme;
|
|
26
34
|
export declare const hexToRgbA: (hex: string, opacity: number) => string | null;
|
|
35
|
+
export {};
|
package/dist/esm/utils/theme.js
CHANGED
|
@@ -130,15 +130,15 @@ const makeWelcome = (welcome) => {
|
|
|
130
130
|
marginBottom: remsToPixels(mobile === null || mobile === void 0 ? void 0 : mobile.marginBottom),
|
|
131
131
|
titleMarginLeft: remsToPixels(mobile === null || mobile === void 0 ? void 0 : mobile.titleMarginLeft),
|
|
132
132
|
titleSize,
|
|
133
|
-
titleLineHeight: makeLineHeight(mobile === null || mobile === void 0 ? void 0 : mobile.titleLineHeight, titleSize),
|
|
133
|
+
titleLineHeight: makeLineHeight(mobile === null || mobile === void 0 ? void 0 : mobile.titleLineHeight.toFixed(5), titleSize),
|
|
134
134
|
subtitleSize,
|
|
135
|
-
subtitleLineHeight: makeLineHeight(mobile === null || mobile === void 0 ? void 0 : mobile.subtitleLineHeight, subtitleSize),
|
|
135
|
+
subtitleLineHeight: makeLineHeight(mobile === null || mobile === void 0 ? void 0 : mobile.subtitleLineHeight.toFixed(5), subtitleSize),
|
|
136
136
|
subtitleMarginTop: remsToPixels(mobile === null || mobile === void 0 ? void 0 : mobile.subtitleMarginTop)
|
|
137
137
|
};
|
|
138
138
|
};
|
|
139
139
|
const makeItem = (item) => {
|
|
140
140
|
const { mobile } = item;
|
|
141
|
-
return Object.assign(Object.assign({},
|
|
141
|
+
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) });
|
|
142
142
|
};
|
|
143
143
|
export const decorateTheme = (theme) => {
|
|
144
144
|
const fonts = makeFonts(theme.fonts, theme.lineHeight);
|
|
@@ -152,7 +152,7 @@ export const decorateTheme = (theme) => {
|
|
|
152
152
|
const welcome = makeWelcome(theme.welcome);
|
|
153
153
|
const item = makeItem(theme.item);
|
|
154
154
|
return Object.assign(Object.assign({}, theme), { fonts: fonts, lineHeight, layout: layout, buttons: buttons, border, inputs: inputs, counts,
|
|
155
|
-
cards, welcome: welcome, item });
|
|
155
|
+
cards, welcome: welcome, item: item });
|
|
156
156
|
};
|
|
157
157
|
export const hexToRgbA = (hex, opacity) => {
|
|
158
158
|
let c;
|
package/package.json
CHANGED