@open-tender/store 0.4.1 → 0.5.1

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.
Files changed (48) hide show
  1. package/dist/.DS_Store +0 -0
  2. package/dist/cjs/app/hooks.d.ts +1 -0
  3. package/dist/cjs/app/store.d.ts +3 -0
  4. package/dist/cjs/app/store.js +1 -0
  5. package/dist/cjs/services/api.d.ts +2 -1
  6. package/dist/cjs/services/api.js +3 -0
  7. package/dist/cjs/slices/index.d.ts +1 -0
  8. package/dist/cjs/slices/index.js +1 -0
  9. package/dist/cjs/slices/kiosk.d.ts +32 -0
  10. package/dist/cjs/slices/kiosk.js +116 -0
  11. package/dist/cjs/slices/types.d.ts +1 -0
  12. package/dist/cjs/slices/types.js +1 -0
  13. package/dist/cjs/types/api/index.d.ts +2 -0
  14. package/dist/cjs/types/api/index.js +2 -0
  15. package/dist/cjs/types/api/kiosk.d.ts +12 -0
  16. package/dist/cjs/types/api/kiosk.js +2 -0
  17. package/dist/cjs/types/api/themeCloud.d.ts +344 -0
  18. package/dist/cjs/types/api/themeCloud.js +2 -0
  19. package/dist/cjs/utils/helpers.d.ts +2 -1
  20. package/dist/cjs/utils/helpers.js +7 -3
  21. package/dist/cjs/utils/index.d.ts +1 -0
  22. package/dist/cjs/utils/index.js +1 -0
  23. package/dist/cjs/utils/themeCloud.d.ts +304 -0
  24. package/dist/cjs/utils/themeCloud.js +197 -0
  25. package/dist/esm/app/hooks.d.ts +1 -0
  26. package/dist/esm/app/store.d.ts +3 -0
  27. package/dist/esm/app/store.js +2 -1
  28. package/dist/esm/services/api.d.ts +2 -1
  29. package/dist/esm/services/api.js +3 -0
  30. package/dist/esm/slices/index.d.ts +1 -0
  31. package/dist/esm/slices/index.js +1 -0
  32. package/dist/esm/slices/kiosk.d.ts +32 -0
  33. package/dist/esm/slices/kiosk.js +110 -0
  34. package/dist/esm/slices/types.d.ts +1 -0
  35. package/dist/esm/slices/types.js +1 -0
  36. package/dist/esm/types/api/index.d.ts +2 -0
  37. package/dist/esm/types/api/index.js +2 -0
  38. package/dist/esm/types/api/kiosk.d.ts +12 -0
  39. package/dist/esm/types/api/kiosk.js +1 -0
  40. package/dist/esm/types/api/themeCloud.d.ts +344 -0
  41. package/dist/esm/types/api/themeCloud.js +1 -0
  42. package/dist/esm/utils/helpers.d.ts +2 -1
  43. package/dist/esm/utils/helpers.js +5 -2
  44. package/dist/esm/utils/index.d.ts +1 -0
  45. package/dist/esm/utils/index.js +1 -0
  46. package/dist/esm/utils/themeCloud.d.ts +304 -0
  47. package/dist/esm/utils/themeCloud.js +190 -0
  48. package/package.json +1 -1
@@ -0,0 +1,110 @@
1
+ var _a;
2
+ import { __awaiter, __generator } from "tslib";
3
+ import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
4
+ import { PosAPI } from '../services';
5
+ import { ReducerType } from './types';
6
+ import { errorsApi } from '../services/errors';
7
+ var initialState = {
8
+ api: null,
9
+ app: null,
10
+ version: null,
11
+ store: null,
12
+ revenueCenterId: null,
13
+ brand: null,
14
+ content: null,
15
+ theme: null,
16
+ loading: 'idle',
17
+ error: null,
18
+ retries: 0
19
+ };
20
+ export var KioskActionType;
21
+ (function (KioskActionType) {
22
+ KioskActionType["FetchKiosk"] = "kiosk/getKiosk";
23
+ })(KioskActionType || (KioskActionType = {}));
24
+ export var fetchKioskConfig = createAsyncThunk(KioskActionType.FetchKiosk, function (_a, _b) {
25
+ var apiUrl = _a.apiUrl;
26
+ var rejectWithValue = _b.rejectWithValue;
27
+ return __awaiter(void 0, void 0, void 0, function () {
28
+ var app, api, _c, kioskConfig, store, err, brand, content, theme, revenueCenterId, err_1;
29
+ return __generator(this, function (_d) {
30
+ switch (_d.label) {
31
+ case 0:
32
+ _d.trys.push([0, 2, , 3]);
33
+ app = { apiUrl: apiUrl };
34
+ api = new PosAPI(app);
35
+ return [4 /*yield*/, Promise.all([
36
+ api.getKioskConfig(),
37
+ api.getStore()
38
+ ])];
39
+ case 1:
40
+ _c = _d.sent(), kioskConfig = _c[0], store = _c[1];
41
+ if (!kioskConfig || !store) {
42
+ err = errorsApi.internalServerError;
43
+ return [2 /*return*/, rejectWithValue(err)];
44
+ }
45
+ brand = kioskConfig.brand, content = kioskConfig.content, theme = kioskConfig.theme;
46
+ revenueCenterId = store.revenue_center_id;
47
+ return [2 /*return*/, {
48
+ api: api,
49
+ app: app,
50
+ store: store,
51
+ revenueCenterId: revenueCenterId,
52
+ brand: brand,
53
+ content: content,
54
+ theme: theme,
55
+ error: null,
56
+ loading: 'idle',
57
+ retries: 0
58
+ }];
59
+ case 2:
60
+ err_1 = _d.sent();
61
+ return [2 /*return*/, rejectWithValue(err_1)];
62
+ case 3: return [2 /*return*/];
63
+ }
64
+ });
65
+ });
66
+ });
67
+ var kioskSlice = createSlice({
68
+ name: ReducerType.Kiosk,
69
+ initialState: initialState,
70
+ reducers: {
71
+ resetKiosk: function () { return initialState; },
72
+ resetKioskRetries: function (state) {
73
+ state.retries = 0;
74
+ },
75
+ incrementKioskRetries: function (state) {
76
+ state.retries = state.retries + 1;
77
+ },
78
+ setKioskVersion: function (state, action) {
79
+ state.version = action.payload;
80
+ }
81
+ },
82
+ extraReducers: function (builder) {
83
+ builder
84
+ .addCase(fetchKioskConfig.fulfilled, function (state, action) {
85
+ var _a = action.payload, api = _a.api, app = _a.app, store = _a.store, revenueCenterId = _a.revenueCenterId, brand = _a.brand, content = _a.content, theme = _a.theme;
86
+ state.api = api;
87
+ state.app = app;
88
+ state.store = store;
89
+ state.revenueCenterId = revenueCenterId;
90
+ state.brand = brand;
91
+ state.content = content;
92
+ state.theme = theme;
93
+ state.loading = 'idle';
94
+ state.retries = 0;
95
+ state.error = null;
96
+ })
97
+ .addCase(fetchKioskConfig.pending, function (state) {
98
+ state.loading = 'pending';
99
+ })
100
+ .addCase(fetchKioskConfig.rejected, function (state, action) {
101
+ state.error = action.payload;
102
+ state.loading = 'idle';
103
+ });
104
+ }
105
+ });
106
+ export var resetKiosk = (_a = kioskSlice.actions, _a.resetKiosk), resetKioskRetries = _a.resetKioskRetries, incrementKioskRetries = _a.incrementKioskRetries, setKioskVersion = _a.setKioskVersion;
107
+ export var selectKiosk = function (state) { return state.kiosk; };
108
+ export var selectKioskApi = function (state) { return state.kiosk.api; };
109
+ export var selectKioskVersion = function (state) { return state.kiosk.version; };
110
+ export var kioskReducer = kioskSlice.reducer;
@@ -7,6 +7,7 @@ export declare enum ReducerType {
7
7
  Discounts = "discounts",
8
8
  ErrorAlerts = "errorAlerts",
9
9
  Kds = "kds",
10
+ Kiosk = "kiosk",
10
11
  MenuPages = "menuPages",
11
12
  Menu = "menu",
12
13
  Modal = "modal",
@@ -8,6 +8,7 @@ export var ReducerType;
8
8
  ReducerType["Discounts"] = "discounts";
9
9
  ReducerType["ErrorAlerts"] = "errorAlerts";
10
10
  ReducerType["Kds"] = "kds";
11
+ ReducerType["Kiosk"] = "kiosk";
11
12
  ReducerType["MenuPages"] = "menuPages";
12
13
  ReducerType["Menu"] = "menu";
13
14
  ReducerType["Modal"] = "modal";
@@ -11,6 +11,7 @@ export * from './errorAlerts';
11
11
  export * from './favorite';
12
12
  export * from './giftCard';
13
13
  export * from './kds';
14
+ export * from './kiosk';
14
15
  export * from './menu';
15
16
  export * from './menuPages';
16
17
  export * from './messages';
@@ -23,3 +24,4 @@ export * from './settings';
23
24
  export * from './store';
24
25
  export * from './surcharges';
25
26
  export * from './taxes';
27
+ export * from './themeCloud';
@@ -11,6 +11,7 @@ export * from './errorAlerts';
11
11
  export * from './favorite';
12
12
  export * from './giftCard';
13
13
  export * from './kds';
14
+ export * from './kiosk';
14
15
  export * from './menu';
15
16
  export * from './menuPages';
16
17
  export * from './messages';
@@ -23,3 +24,4 @@ export * from './settings';
23
24
  export * from './store';
24
25
  export * from './surcharges';
25
26
  export * from './taxes';
27
+ export * from './themeCloud';
@@ -0,0 +1,12 @@
1
+ import { ThemeCloud } from './themeCloud';
2
+ export interface Dimensions {
3
+ width: number;
4
+ height: number;
5
+ }
6
+ export declare type KioskBrand = Record<string, unknown>;
7
+ export declare type KioskContent = Record<string, unknown>;
8
+ export interface KioskConfig {
9
+ brand: KioskBrand;
10
+ content: KioskContent;
11
+ theme: ThemeCloud;
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,344 @@
1
+ export declare type RGBA = `rgba(${number}, ${number}, ${number}, ${number})` | 'none';
2
+ export declare type HEX = `#${string}` | 'transparent';
3
+ export declare type Pixels = `${string}px`;
4
+ export declare type Rems = `${string}rem`;
5
+ export declare type PaddingRems = `${Rems} ${Rems} ${Rems}`;
6
+ export interface TCMessageColor {
7
+ bgColor: HEX;
8
+ color: HEX;
9
+ }
10
+ export interface TCBgColors {
11
+ alert: HEX;
12
+ allergens: HEX;
13
+ dark: HEX;
14
+ error: HEX;
15
+ highlight: HEX;
16
+ light: HEX;
17
+ primary: HEX;
18
+ secondary: HEX;
19
+ success: HEX;
20
+ tertiary: HEX;
21
+ toast: HEX;
22
+ }
23
+ export declare type TCBoldWeight = string;
24
+ export interface TCBorder {
25
+ color: HEX;
26
+ radius: string;
27
+ radiusSmall: string;
28
+ width: string;
29
+ widthApp: string;
30
+ }
31
+ export interface TCBoxShadow {
32
+ appBig: string;
33
+ appSmall: string;
34
+ inset: string;
35
+ outer: string;
36
+ }
37
+ export interface TCBreakpoints {
38
+ laptop: string;
39
+ mobile: string;
40
+ narrow: string;
41
+ tablet: string;
42
+ }
43
+ export interface TCButtonColor {
44
+ bgColor: HEX;
45
+ borderColor: HEX;
46
+ color: HEX;
47
+ iconColor?: HEX;
48
+ subtitleColor?: HEX;
49
+ }
50
+ export interface TCButtonColors {
51
+ cart: TCButtonColor;
52
+ cartHover: TCButtonColor;
53
+ header: TCButtonColor;
54
+ headerHover: TCButtonColor;
55
+ large: TCButtonColor;
56
+ largeHover: TCButtonColor;
57
+ light: TCButtonColor;
58
+ lightHover: TCButtonColor;
59
+ primary: TCButtonColor;
60
+ primaryHover: TCButtonColor;
61
+ secondary: TCButtonColor;
62
+ secondaryHover: TCButtonColor;
63
+ }
64
+ export interface TCButtonSize {
65
+ borderRadius: string;
66
+ borderWidth: string;
67
+ borderWidthApp: string;
68
+ family: string;
69
+ fontMobile: string;
70
+ fontSize: string;
71
+ fontSmoothing: string;
72
+ letterSpacing: string;
73
+ padding: string;
74
+ textTransform: string;
75
+ weight: string;
76
+ }
77
+ export interface TCButtonLargeSize {
78
+ borderRadius: string;
79
+ borderWidth: string;
80
+ borderWidthApp: string;
81
+ fontSize: string;
82
+ letterSpacing: string;
83
+ padding: string;
84
+ showButtonApp: boolean;
85
+ showSubtitle: boolean;
86
+ showSubtitleMobile: boolean;
87
+ subtitleFontMobile: string;
88
+ subtitleFontSize: string;
89
+ subtitleFontSizeMobile: string;
90
+ subtitleFontWeight: string;
91
+ subtitleMarginTop: string;
92
+ subtitleMarginTopMobile: string;
93
+ titleFontMobile: string;
94
+ titleFontSize: string;
95
+ titleFontSizeMobile: string;
96
+ titleFontWeight: string;
97
+ titleMarginLeft: string;
98
+ titleMarginLeftMobile: string;
99
+ }
100
+ export interface TCButtonSizes {
101
+ big: TCButtonSize;
102
+ default: TCButtonSize;
103
+ header: TCButtonSize;
104
+ large: TCButtonLargeSize;
105
+ small: TCButtonSize;
106
+ }
107
+ export interface TCButtons {
108
+ colors: TCButtonColors;
109
+ sizes: TCButtonSizes;
110
+ }
111
+ export interface TCCard {
112
+ bgColor: HEX;
113
+ borderColor: HEX;
114
+ borderRadius: string;
115
+ borderWidth: string;
116
+ borderWidthApp: string;
117
+ boxShadow: string;
118
+ overrideFontColors: boolean;
119
+ textColor: HEX;
120
+ titleColor: HEX;
121
+ }
122
+ export interface TCCards {
123
+ default: TCCard;
124
+ form: TCCard;
125
+ menuItem: TCCard;
126
+ modifier: TCCard;
127
+ }
128
+ export interface TCColors {
129
+ alert: HEX;
130
+ allergens: HEX;
131
+ dark: HEX;
132
+ error: HEX;
133
+ light: HEX;
134
+ primary: HEX;
135
+ secondary: HEX;
136
+ success: HEX;
137
+ tags: HEX;
138
+ tertiary: HEX;
139
+ title: HEX;
140
+ toast: HEX;
141
+ }
142
+ export interface TCCount {
143
+ bgColor?: HEX;
144
+ borderColor?: HEX;
145
+ borderWidth?: string;
146
+ borderWidthApp?: string;
147
+ color?: HEX;
148
+ family: string;
149
+ fontMobile: string;
150
+ fontSize: string;
151
+ fontSizeMobile: string;
152
+ fontSmoothing: string;
153
+ paddingBottom: string;
154
+ paddingTop: string;
155
+ weight: string;
156
+ }
157
+ export interface TCCounts {
158
+ alerts: TCCount;
159
+ quantity: TCCount;
160
+ }
161
+ export interface TCFavorite {
162
+ iconSize: string;
163
+ size: string;
164
+ }
165
+ export interface TCFont {
166
+ color?: HEX;
167
+ family: string;
168
+ fontMobile: string;
169
+ fontSize?: string;
170
+ fontSmoothing: string;
171
+ letterSpacing: string;
172
+ lineHeight: number;
173
+ textTransform: string;
174
+ url?: string;
175
+ weight: string;
176
+ }
177
+ export interface TCFontSizes {
178
+ big: string;
179
+ giga: string;
180
+ h1: string;
181
+ h2: string;
182
+ h3: string;
183
+ h4: string;
184
+ h5: string;
185
+ h6: string;
186
+ main: string;
187
+ mega: string;
188
+ small: string;
189
+ tera: string;
190
+ xBig: string;
191
+ xSmall: string;
192
+ xxBig: string;
193
+ xxSmall: string;
194
+ }
195
+ export interface TCFonts {
196
+ body: TCFont;
197
+ headings: TCFont;
198
+ headline: TCFont;
199
+ preface: TCFont;
200
+ sizes: TCFontSizes;
201
+ }
202
+ export interface TCHeader {
203
+ primary: HEX;
204
+ stuck: HEX;
205
+ }
206
+ export interface TCIcons {
207
+ strokeWidth: number;
208
+ }
209
+ export interface TCInputLabel {
210
+ fontSize: string;
211
+ fontSizeMobile: string;
212
+ left: string;
213
+ offset: string;
214
+ padding: string;
215
+ top: string;
216
+ }
217
+ export interface TCInputs {
218
+ bgColor: HEX;
219
+ bgColorFocus: HEX;
220
+ borderColor: HEX;
221
+ borderColorFocus: HEX;
222
+ borderStyle: string;
223
+ borderWidth: string;
224
+ borderWidthApp: string;
225
+ bottomBorderOnly: boolean;
226
+ boxShadow: string;
227
+ color: HEX;
228
+ colorFocus: HEX;
229
+ family: string;
230
+ fontMobile: string;
231
+ fontSize: string;
232
+ fontSizeMobile: string;
233
+ fontSmoothing: string;
234
+ iconLeft: string;
235
+ iconPadding: string;
236
+ label: TCInputLabel;
237
+ letterSpacing: string;
238
+ lineHeight: string;
239
+ padding: string;
240
+ paddingBottom: string;
241
+ paddingBottomActive: string;
242
+ paddingHorizontal: string;
243
+ paddingTop: string;
244
+ paddingTopActive: string;
245
+ paddingVertical: string;
246
+ placeholderColor: HEX;
247
+ radius: string;
248
+ selectPaddingBottom: string;
249
+ selectSize: string;
250
+ selectSizeMobile: string;
251
+ showIcon: boolean;
252
+ showLabel: boolean;
253
+ showOutline: boolean;
254
+ textTransform: string;
255
+ weight: string;
256
+ }
257
+ export interface TCItem {
258
+ imageHeight: string;
259
+ imageMaxHeight: string;
260
+ imageMinHeight: string;
261
+ imagePadding: string;
262
+ maxWidth: string;
263
+ padding: string;
264
+ }
265
+ export interface TCItems {
266
+ desktop: TCItem;
267
+ mobile: TCItem;
268
+ }
269
+ export interface TCLayout {
270
+ containerMaxWidth: string;
271
+ headerHeightApp: string;
272
+ headerHeightSite: string;
273
+ headerHeightSiteMobile: string;
274
+ margin: string;
275
+ marginMobile: string;
276
+ maxWidth: string;
277
+ navHeight: string;
278
+ navHeightApp: string;
279
+ navHeightMobile: string;
280
+ padding: string;
281
+ paddingMobile: string;
282
+ }
283
+ export declare type TCLineHeight = string;
284
+ export interface TCLinkColor {
285
+ color: HEX;
286
+ hover: HEX;
287
+ }
288
+ export declare type TCLinkDecoration = 'none' | 'underline' | 'line-through' | 'overline' | 'inherit';
289
+ export interface TCLinks {
290
+ dark: TCLinkColor;
291
+ light: TCLinkColor;
292
+ primary: TCLinkColor;
293
+ textDecoration: TCLinkDecoration;
294
+ transition: string;
295
+ }
296
+ export interface TCOverlay {
297
+ alert: RGBA;
298
+ dark: RGBA;
299
+ light: RGBA;
300
+ primary: RGBA;
301
+ secondary: RGBA;
302
+ tertiary: RGBA;
303
+ }
304
+ export declare type TCTextAlign = 'left' | 'right' | 'center';
305
+ export interface TCWelcome {
306
+ marginBottom: string;
307
+ marginTop: string;
308
+ subtitleLineHeight: number;
309
+ subtitleMarginTop: string;
310
+ subtitleSize: string;
311
+ textAlign: TCTextAlign;
312
+ titleLineHeight: number;
313
+ titleMarginLeft: string;
314
+ titleSize: string;
315
+ }
316
+ export interface TCWelcomes {
317
+ desktop: TCWelcome;
318
+ mobile: TCWelcome;
319
+ }
320
+ export interface ThemeCloud {
321
+ alert: TCMessageColor;
322
+ bgColors: TCBgColors;
323
+ boldWeight: TCBoldWeight;
324
+ border: TCBorder;
325
+ boxShadow: TCBoxShadow;
326
+ breakpoints: TCBreakpoints;
327
+ buttons: TCButtons;
328
+ cards: TCCards;
329
+ colors: TCColors;
330
+ counts: TCCounts;
331
+ error: TCMessageColor;
332
+ fonts: TCFonts;
333
+ header: TCHeader;
334
+ icons: TCIcons;
335
+ inputs: TCInputs;
336
+ item: TCItems;
337
+ layout: TCLayout;
338
+ lineHeight: TCLineHeight;
339
+ links: TCLinks;
340
+ overlay: TCOverlay;
341
+ success: TCMessageColor;
342
+ toast: TCMessageColor;
343
+ welcome: TCWelcomes;
344
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -11,7 +11,8 @@ export declare const addCommas: (x: number, d: number) => string;
11
11
  export declare const formatQuantity: (n: string | number) => string;
12
12
  export declare const formatDollars: (n: string | number, space?: string, decimals?: number) => string;
13
13
  export declare const remsToInt: (rems: string) => number;
14
- export declare const pixelsToInt: (rems: string) => number;
14
+ export declare const pixelsToInt: (pixels: string) => number;
15
+ export declare const pixelsToFloat: (pixels: string) => number;
15
16
  export declare const handleRespError: (err: RequestErrorAPI | string) => {
16
17
  title: string;
17
18
  detail: string;
@@ -54,8 +54,11 @@ export var formatDollars = function (n, space, decimals) {
54
54
  export var remsToInt = function (rems) {
55
55
  return parseInt((parseFloat(rems.replace('rem', '')) * 10).toString());
56
56
  };
57
- export var pixelsToInt = function (rems) {
58
- return parseInt(parseFloat(rems.replace('px', '')).toString());
57
+ export var pixelsToInt = function (pixels) {
58
+ return parseInt(parseFloat(pixels.replace('px', '')).toString());
59
+ };
60
+ export var pixelsToFloat = function (pixels) {
61
+ return parseFloat(pixels.replace('px', ''));
59
62
  };
60
63
  export var handleRespError = function (err) {
61
64
  if (typeof err === 'string') {
@@ -8,3 +8,4 @@ export * from './pos';
8
8
  export * from './punches';
9
9
  export * from './refunds';
10
10
  export * from './theme';
11
+ export * from './themeCloud';
@@ -8,3 +8,4 @@ export * from './pos';
8
8
  export * from './punches';
9
9
  export * from './refunds';
10
10
  export * from './theme';
11
+ export * from './themeCloud';