@open-tender/utils 0.4.31 → 0.4.33

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 (245) hide show
  1. package/LICENSE.md +21 -21
  2. package/README.md +2 -2
  3. package/dist/cjs/__tests__/utils/helpers.test.d.ts +1 -1
  4. package/dist/cjs/__tests__/utils/helpers.test.js +96 -96
  5. package/dist/cjs/__tests__/utils/theme.test.d.ts +1 -1
  6. package/dist/cjs/__tests__/utils/theme.test.js +37 -37
  7. package/dist/cjs/hooks/index.d.ts +35 -35
  8. package/dist/cjs/hooks/index.js +38 -38
  9. package/dist/cjs/hooks/types.d.ts +4 -4
  10. package/dist/cjs/hooks/types.js +2 -2
  11. package/dist/cjs/hooks/useAccordion.d.ts +22 -22
  12. package/dist/cjs/hooks/useAccordion.js +56 -56
  13. package/dist/cjs/hooks/useAddressForm.d.ts +12 -12
  14. package/dist/cjs/hooks/useAddressForm.js +83 -83
  15. package/dist/cjs/hooks/useAllergenForm.d.ts +10 -10
  16. package/dist/cjs/hooks/useAllergenForm.js +58 -58
  17. package/dist/cjs/hooks/useBuilder.d.ts +14 -14
  18. package/dist/cjs/hooks/useBuilder.js +144 -144
  19. package/dist/cjs/hooks/useCartGuestForm.d.ts +12 -12
  20. package/dist/cjs/hooks/useCartGuestForm.js +58 -58
  21. package/dist/cjs/hooks/useCartPoints.d.ts +13 -13
  22. package/dist/cjs/hooks/useCartPoints.js +74 -74
  23. package/dist/cjs/hooks/useCommunicationPreferences.js +1 -1
  24. package/dist/cjs/hooks/useCreditCard.d.ts +13 -13
  25. package/dist/cjs/hooks/useCreditCard.js +63 -63
  26. package/dist/cjs/hooks/useCreditCardForm.d.ts +10 -10
  27. package/dist/cjs/hooks/useCreditCardForm.js +71 -71
  28. package/dist/cjs/hooks/useCurbside.d.ts +9 -9
  29. package/dist/cjs/hooks/useCurbside.js +39 -39
  30. package/dist/cjs/hooks/useDineInForm.d.ts +11 -11
  31. package/dist/cjs/hooks/useDineInForm.js +56 -56
  32. package/dist/cjs/hooks/useDonationForm.d.ts +28 -28
  33. package/dist/cjs/hooks/useDonationForm.js +172 -172
  34. package/dist/cjs/hooks/useFirstTimes.d.ts +18 -18
  35. package/dist/cjs/hooks/useFirstTimes.js +81 -81
  36. package/dist/cjs/hooks/useGiftCardAssignForm.d.ts +14 -14
  37. package/dist/cjs/hooks/useGiftCardAssignForm.js +57 -57
  38. package/dist/cjs/hooks/useGiftCardAssignOtherForm.d.ts +14 -14
  39. package/dist/cjs/hooks/useGiftCardAssignOtherForm.js +50 -50
  40. package/dist/cjs/hooks/useGiftCardForm.d.ts +12 -12
  41. package/dist/cjs/hooks/useGiftCardForm.js +74 -74
  42. package/dist/cjs/hooks/useGiftCardsForm.d.ts +31 -31
  43. package/dist/cjs/hooks/useGiftCardsForm.js +195 -195
  44. package/dist/cjs/hooks/useGuestCheckoutForm.d.ts +21 -21
  45. package/dist/cjs/hooks/useGuestCheckoutForm.js +89 -89
  46. package/dist/cjs/hooks/useGuestForm.d.ts +12 -12
  47. package/dist/cjs/hooks/useGuestForm.js +60 -60
  48. package/dist/cjs/hooks/useImage.d.ts +5 -5
  49. package/dist/cjs/hooks/useImage.js +33 -33
  50. package/dist/cjs/hooks/useLoginForm.d.ts +12 -12
  51. package/dist/cjs/hooks/useLoginForm.js +67 -67
  52. package/dist/cjs/hooks/useMenuItem.d.ts +57 -57
  53. package/dist/cjs/hooks/useMenuItem.js +67 -67
  54. package/dist/cjs/hooks/useModifier.d.ts +53 -53
  55. package/dist/cjs/hooks/useModifier.js +72 -72
  56. package/dist/cjs/hooks/useModifierGroup.d.ts +15 -15
  57. package/dist/cjs/hooks/useModifierGroup.js +17 -17
  58. package/dist/cjs/hooks/useOneTimePasscodeForm.d.ts +16 -16
  59. package/dist/cjs/hooks/useOneTimePasscodeForm.js +87 -87
  60. package/dist/cjs/hooks/useOrderFulfillmentForm.d.ts +11 -11
  61. package/dist/cjs/hooks/useOrderFulfillmentForm.js +65 -65
  62. package/dist/cjs/hooks/useOrderItem.d.ts +48 -48
  63. package/dist/cjs/hooks/useOrderItem.js +54 -54
  64. package/dist/cjs/hooks/useOrderRating.d.ts +10 -10
  65. package/dist/cjs/hooks/useOrderRating.js +34 -34
  66. package/dist/cjs/hooks/useOrderRatingForm.d.ts +11 -11
  67. package/dist/cjs/hooks/useOrderRatingForm.js +35 -35
  68. package/dist/cjs/hooks/useProfileForm.d.ts +15 -15
  69. package/dist/cjs/hooks/useProfileForm.js +116 -116
  70. package/dist/cjs/hooks/useResetPasswordForm.d.ts +12 -12
  71. package/dist/cjs/hooks/useResetPasswordForm.js +77 -77
  72. package/dist/cjs/hooks/useSendResetForm.d.ts +14 -14
  73. package/dist/cjs/hooks/useSendResetForm.js +57 -57
  74. package/dist/cjs/hooks/useSignUpForm.d.ts +20 -20
  75. package/dist/cjs/hooks/useSignUpForm.js +160 -151
  76. package/dist/cjs/hooks/useSignUpGuestForm.d.ts +23 -23
  77. package/dist/cjs/hooks/useSignUpGuestForm.js +124 -113
  78. package/dist/cjs/hooks/useSigninForm.d.ts +12 -12
  79. package/dist/cjs/hooks/useSigninForm.js +66 -66
  80. package/dist/cjs/index.d.ts +2 -2
  81. package/dist/cjs/index.js +5 -5
  82. package/dist/cjs/utils/cards.d.ts +20 -20
  83. package/dist/cjs/utils/cards.js +155 -155
  84. package/dist/cjs/utils/cart.d.ts +202 -202
  85. package/dist/cjs/utils/cart.js +909 -909
  86. package/dist/cjs/utils/checkout.d.ts +55 -55
  87. package/dist/cjs/utils/checkout.js +125 -125
  88. package/dist/cjs/utils/constants.d.ts +43 -43
  89. package/dist/cjs/utils/constants.js +58 -58
  90. package/dist/cjs/utils/customer.d.ts +4 -4
  91. package/dist/cjs/utils/customer.js +34 -34
  92. package/dist/cjs/utils/datetimes.d.ts +99 -99
  93. package/dist/cjs/utils/datetimes.js +601 -601
  94. package/dist/cjs/utils/errors.d.ts +51 -51
  95. package/dist/cjs/utils/errors.js +191 -191
  96. package/dist/cjs/utils/favorites.d.ts +10 -10
  97. package/dist/cjs/utils/favorites.js +119 -119
  98. package/dist/cjs/utils/googleMaps.d.ts +14 -14
  99. package/dist/cjs/utils/googleMaps.js +30 -30
  100. package/dist/cjs/utils/helpers.d.ts +63 -63
  101. package/dist/cjs/utils/helpers.js +244 -244
  102. package/dist/cjs/utils/index.d.ts +19 -19
  103. package/dist/cjs/utils/index.js +23 -23
  104. package/dist/cjs/utils/keypad.d.ts +9 -9
  105. package/dist/cjs/utils/keypad.js +105 -105
  106. package/dist/cjs/utils/maps.d.ts +226 -226
  107. package/dist/cjs/utils/maps.js +334 -334
  108. package/dist/cjs/utils/menu.d.ts +117 -117
  109. package/dist/cjs/utils/menu.js +82 -82
  110. package/dist/cjs/utils/orders.d.ts +21 -21
  111. package/dist/cjs/utils/orders.js +202 -202
  112. package/dist/cjs/utils/pizzaBuilder.d.ts +10 -10
  113. package/dist/cjs/utils/pizzaBuilder.js +43 -43
  114. package/dist/cjs/utils/refunds.d.ts +35 -35
  115. package/dist/cjs/utils/refunds.js +98 -98
  116. package/dist/cjs/utils/revenueCenters.d.ts +11 -11
  117. package/dist/cjs/utils/revenueCenters.js +125 -125
  118. package/dist/cjs/utils/rewards.d.ts +4 -4
  119. package/dist/cjs/utils/rewards.js +106 -106
  120. package/dist/cjs/utils/theme.d.ts +27 -27
  121. package/dist/cjs/utils/theme.js +266 -266
  122. package/dist/cjs/utils/version.d.ts +4 -4
  123. package/dist/cjs/utils/version.js +38 -38
  124. package/dist/esm/__tests__/utils/helpers.test.d.ts +1 -1
  125. package/dist/esm/__tests__/utils/helpers.test.js +94 -94
  126. package/dist/esm/__tests__/utils/theme.test.d.ts +1 -1
  127. package/dist/esm/__tests__/utils/theme.test.js +35 -35
  128. package/dist/esm/hooks/index.d.ts +35 -35
  129. package/dist/esm/hooks/index.js +35 -35
  130. package/dist/esm/hooks/types.d.ts +4 -4
  131. package/dist/esm/hooks/types.js +1 -1
  132. package/dist/esm/hooks/useAccordion.d.ts +22 -22
  133. package/dist/esm/hooks/useAccordion.js +52 -52
  134. package/dist/esm/hooks/useAddressForm.d.ts +12 -12
  135. package/dist/esm/hooks/useAddressForm.js +79 -79
  136. package/dist/esm/hooks/useAllergenForm.d.ts +10 -10
  137. package/dist/esm/hooks/useAllergenForm.js +54 -54
  138. package/dist/esm/hooks/useBuilder.d.ts +14 -14
  139. package/dist/esm/hooks/useBuilder.js +140 -140
  140. package/dist/esm/hooks/useCartGuestForm.d.ts +12 -12
  141. package/dist/esm/hooks/useCartGuestForm.js +54 -54
  142. package/dist/esm/hooks/useCartPoints.d.ts +13 -13
  143. package/dist/esm/hooks/useCartPoints.js +70 -70
  144. package/dist/esm/hooks/useCommunicationPreferences.js +1 -1
  145. package/dist/esm/hooks/useCreditCard.d.ts +13 -13
  146. package/dist/esm/hooks/useCreditCard.js +59 -59
  147. package/dist/esm/hooks/useCreditCardForm.d.ts +10 -10
  148. package/dist/esm/hooks/useCreditCardForm.js +67 -67
  149. package/dist/esm/hooks/useCurbside.d.ts +9 -9
  150. package/dist/esm/hooks/useCurbside.js +35 -35
  151. package/dist/esm/hooks/useDineInForm.d.ts +11 -11
  152. package/dist/esm/hooks/useDineInForm.js +52 -52
  153. package/dist/esm/hooks/useDonationForm.d.ts +28 -28
  154. package/dist/esm/hooks/useDonationForm.js +168 -168
  155. package/dist/esm/hooks/useFirstTimes.d.ts +18 -18
  156. package/dist/esm/hooks/useFirstTimes.js +77 -77
  157. package/dist/esm/hooks/useGiftCardAssignForm.d.ts +14 -14
  158. package/dist/esm/hooks/useGiftCardAssignForm.js +53 -53
  159. package/dist/esm/hooks/useGiftCardAssignOtherForm.d.ts +14 -14
  160. package/dist/esm/hooks/useGiftCardAssignOtherForm.js +46 -46
  161. package/dist/esm/hooks/useGiftCardForm.d.ts +12 -12
  162. package/dist/esm/hooks/useGiftCardForm.js +70 -70
  163. package/dist/esm/hooks/useGiftCardsForm.d.ts +31 -31
  164. package/dist/esm/hooks/useGiftCardsForm.js +191 -191
  165. package/dist/esm/hooks/useGuestCheckoutForm.d.ts +21 -21
  166. package/dist/esm/hooks/useGuestCheckoutForm.js +85 -85
  167. package/dist/esm/hooks/useGuestForm.d.ts +12 -12
  168. package/dist/esm/hooks/useGuestForm.js +56 -56
  169. package/dist/esm/hooks/useImage.d.ts +5 -5
  170. package/dist/esm/hooks/useImage.js +29 -29
  171. package/dist/esm/hooks/useLoginForm.d.ts +12 -12
  172. package/dist/esm/hooks/useLoginForm.js +63 -63
  173. package/dist/esm/hooks/useMenuItem.d.ts +57 -57
  174. package/dist/esm/hooks/useMenuItem.js +63 -63
  175. package/dist/esm/hooks/useModifier.d.ts +53 -53
  176. package/dist/esm/hooks/useModifier.js +68 -68
  177. package/dist/esm/hooks/useModifierGroup.d.ts +15 -15
  178. package/dist/esm/hooks/useModifierGroup.js +13 -13
  179. package/dist/esm/hooks/useOneTimePasscodeForm.d.ts +16 -16
  180. package/dist/esm/hooks/useOneTimePasscodeForm.js +83 -83
  181. package/dist/esm/hooks/useOrderFulfillmentForm.d.ts +11 -11
  182. package/dist/esm/hooks/useOrderFulfillmentForm.js +61 -61
  183. package/dist/esm/hooks/useOrderItem.d.ts +48 -48
  184. package/dist/esm/hooks/useOrderItem.js +50 -50
  185. package/dist/esm/hooks/useOrderRating.d.ts +10 -10
  186. package/dist/esm/hooks/useOrderRating.js +30 -30
  187. package/dist/esm/hooks/useOrderRatingForm.d.ts +11 -11
  188. package/dist/esm/hooks/useOrderRatingForm.js +31 -31
  189. package/dist/esm/hooks/useProfileForm.d.ts +15 -15
  190. package/dist/esm/hooks/useProfileForm.js +112 -112
  191. package/dist/esm/hooks/useResetPasswordForm.d.ts +12 -12
  192. package/dist/esm/hooks/useResetPasswordForm.js +73 -73
  193. package/dist/esm/hooks/useSendResetForm.d.ts +14 -14
  194. package/dist/esm/hooks/useSendResetForm.js +53 -53
  195. package/dist/esm/hooks/useSignUpForm.d.ts +20 -20
  196. package/dist/esm/hooks/useSignUpForm.js +156 -147
  197. package/dist/esm/hooks/useSignUpGuestForm.d.ts +23 -23
  198. package/dist/esm/hooks/useSignUpGuestForm.js +120 -109
  199. package/dist/esm/hooks/useSigninForm.d.ts +12 -12
  200. package/dist/esm/hooks/useSigninForm.js +62 -62
  201. package/dist/esm/index.d.ts +2 -2
  202. package/dist/esm/index.js +2 -2
  203. package/dist/esm/utils/cards.d.ts +20 -20
  204. package/dist/esm/utils/cards.js +146 -146
  205. package/dist/esm/utils/cart.d.ts +202 -202
  206. package/dist/esm/utils/cart.js +868 -868
  207. package/dist/esm/utils/checkout.d.ts +55 -55
  208. package/dist/esm/utils/checkout.js +117 -117
  209. package/dist/esm/utils/constants.d.ts +43 -43
  210. package/dist/esm/utils/constants.js +55 -55
  211. package/dist/esm/utils/customer.d.ts +4 -4
  212. package/dist/esm/utils/customer.js +29 -29
  213. package/dist/esm/utils/datetimes.d.ts +99 -99
  214. package/dist/esm/utils/datetimes.js +531 -531
  215. package/dist/esm/utils/errors.d.ts +51 -51
  216. package/dist/esm/utils/errors.js +180 -180
  217. package/dist/esm/utils/favorites.d.ts +10 -10
  218. package/dist/esm/utils/favorites.js +109 -109
  219. package/dist/esm/utils/googleMaps.d.ts +14 -14
  220. package/dist/esm/utils/googleMaps.js +26 -26
  221. package/dist/esm/utils/helpers.d.ts +63 -63
  222. package/dist/esm/utils/helpers.js +205 -205
  223. package/dist/esm/utils/index.d.ts +19 -19
  224. package/dist/esm/utils/index.js +20 -20
  225. package/dist/esm/utils/keypad.d.ts +9 -9
  226. package/dist/esm/utils/keypad.js +97 -97
  227. package/dist/esm/utils/maps.d.ts +226 -226
  228. package/dist/esm/utils/maps.js +316 -316
  229. package/dist/esm/utils/menu.d.ts +117 -117
  230. package/dist/esm/utils/menu.js +74 -74
  231. package/dist/esm/utils/orders.d.ts +21 -21
  232. package/dist/esm/utils/orders.js +185 -185
  233. package/dist/esm/utils/pizzaBuilder.d.ts +10 -10
  234. package/dist/esm/utils/pizzaBuilder.js +38 -38
  235. package/dist/esm/utils/refunds.d.ts +35 -35
  236. package/dist/esm/utils/refunds.js +90 -90
  237. package/dist/esm/utils/revenueCenters.d.ts +11 -11
  238. package/dist/esm/utils/revenueCenters.js +115 -115
  239. package/dist/esm/utils/rewards.d.ts +4 -4
  240. package/dist/esm/utils/rewards.js +100 -100
  241. package/dist/esm/utils/theme.d.ts +27 -27
  242. package/dist/esm/utils/theme.js +254 -254
  243. package/dist/esm/utils/version.d.ts +4 -4
  244. package/dist/esm/utils/version.js +34 -34
  245. package/package.json +69 -68
@@ -1,244 +1,244 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sample = exports.range = exports.hasEntities = exports.convertStringToArray = exports.formatDollars = exports.formatPercentage = 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.containsAll = exports.containsAny = exports.contains = exports.isNum = exports.isEmpty = exports.isObject = exports.isString = void 0;
4
- const isString = (str) => {
5
- return typeof str === 'string';
6
- };
7
- exports.isString = isString;
8
- const isObject = (obj) => {
9
- return typeof obj === 'object' && obj !== null;
10
- };
11
- exports.isObject = isObject;
12
- const isEmpty = (obj) => {
13
- return (!obj || (obj.constructor === Object && Object.entries(obj).length === 0));
14
- };
15
- exports.isEmpty = isEmpty;
16
- const isNum = (s) => /^\d+$/.test(s);
17
- exports.isNum = isNum;
18
- /**
19
- * @deprecated please use `containsAll` or `containsAny` instead
20
- * @returns true if first argument contains any of the values in the second argument
21
- */
22
- const contains = (arr, values) => {
23
- return values.filter(i => arr.includes(i)).length > 0;
24
- };
25
- exports.contains = contains;
26
- /**
27
- * @returns true if first argument contains any of the values in the second argument
28
- */
29
- const containsAny = (arr, values) => {
30
- return values.length === 0 || values.filter(i => arr.includes(i)).length > 0;
31
- };
32
- exports.containsAny = containsAny;
33
- /**
34
- * @returns true if first argument contains all of the values of the second argument
35
- */
36
- const containsAll = (arr, values) => {
37
- return values.filter(i => arr.includes(i)).length === values.length;
38
- };
39
- exports.containsAll = containsAll;
40
- // https://gist.github.com/mathewbyrne/1280286
41
- const slugify = (text) => {
42
- return text
43
- .toString()
44
- .toLowerCase()
45
- .replace('_', '-') // replace _ with -
46
- .replace(/\s+/g, '-') // Replace spaces with -
47
- .replace(/[^\w-]+/g, '') // Remove all non-word chars
48
- .replace(/--+/g, '-') // Replace multiple - with single -
49
- .replace(/^-+/, '') // Trim - from start of text
50
- .replace(/-+$/, ''); // Trim - from end of text
51
- };
52
- exports.slugify = slugify;
53
- const stripTags = (s) => s.replace(/(<([^>]+)>)/gi, '').replace('&amp;', '&');
54
- exports.stripTags = stripTags;
55
- const serialize = (obj) => {
56
- const str = [];
57
- for (const p in obj)
58
- if (Object.prototype.hasOwnProperty.call(obj, p)) {
59
- str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
60
- }
61
- return str.join('&');
62
- };
63
- exports.serialize = serialize;
64
- const capitalize = (s) => {
65
- if (!s || !s.length)
66
- return '';
67
- return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
68
- };
69
- exports.capitalize = capitalize;
70
- const cleanPhone = (phone) => {
71
- if (!phone)
72
- return '';
73
- let p = phone.replace(/\D/g, '');
74
- if (p.length > 11)
75
- return phone;
76
- p = p.length === 11 && p[0] === '1' ? p.slice(1, 11) : p;
77
- p =
78
- p.length === 10 ? `${p.slice(0, 3)}-${p.slice(3, 6)}-${p.slice(6, 10)}` : p;
79
- return p;
80
- };
81
- exports.cleanPhone = cleanPhone;
82
- const makePhone = (phone) => {
83
- if (!phone)
84
- return '';
85
- const p = phone.replace(/\D/g, '');
86
- if (p.length > 6) {
87
- return `${p.slice(0, 3)}-${p.slice(3, 6)}-${p.slice(6, 10)}`;
88
- }
89
- else if (p.length > 3) {
90
- return `${p.slice(0, 3)}-${p.slice(3, 6)}`;
91
- }
92
- return p;
93
- };
94
- exports.makePhone = makePhone;
95
- const validatePhone = (phone) => {
96
- var _a;
97
- if (!phone)
98
- return false;
99
- return ((_a = phone.match(/\d/g)) === null || _a === void 0 ? void 0 : _a.length) === 10;
100
- };
101
- exports.validatePhone = validatePhone;
102
- const makeBirthDate = (birthDate) => {
103
- if (!birthDate)
104
- return null;
105
- const b = birthDate.replace(/\D/g, '');
106
- if (b.length > 4) {
107
- return `${b.slice(0, 2)}/${b.slice(2, 4)}/${b.slice(4, 8)}`;
108
- }
109
- else if (b.length > 2) {
110
- return `${b.slice(0, 2)}/${b.slice(2, 4)}`;
111
- }
112
- return b;
113
- };
114
- exports.makeBirthDate = makeBirthDate;
115
- const slashesToDashes = (birthDate) => {
116
- if (!birthDate)
117
- return null;
118
- const parts = birthDate.split('/');
119
- return `${parts[2] || ''}-${parts[0] || ''}-${parts[1] || ''}`;
120
- };
121
- exports.slashesToDashes = slashesToDashes;
122
- const dashesToSlashes = (birthDate) => {
123
- if (!birthDate)
124
- return null;
125
- const parts = birthDate.split('-');
126
- return `${parts[1] || ''}/${parts[2] || ''}/${parts[0] || ''}`;
127
- };
128
- exports.dashesToSlashes = dashesToSlashes;
129
- const validateEmail = (email) => {
130
- const re =
131
- // eslint-disable-next-line no-useless-escape
132
- /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
133
- return re.test(email);
134
- };
135
- exports.validateEmail = validateEmail;
136
- const checkEmpty = (data) => {
137
- if ((0, exports.isEmpty)(data))
138
- return true;
139
- return Object.values(data).filter(i => !i).length > 0;
140
- };
141
- exports.checkEmpty = checkEmpty;
142
- const checkGuestData = (data, email) => {
143
- const { first_name, last_name, phone } = data;
144
- const guestData = { first_name, last_name, phone, email };
145
- const validPhone = phone ? (0, exports.validatePhone)(phone) || null : null;
146
- const guestIncomplete = (0, exports.checkEmpty)(Object.assign(Object.assign({}, guestData), { phone: validPhone }));
147
- return { guestData, guestIncomplete };
148
- };
149
- exports.checkGuestData = checkGuestData;
150
- const checkNotFound = (errors) => {
151
- const errMsg = errors ? errors.email || errors.form : null;
152
- if (!errMsg)
153
- return null;
154
- return (errMsg.includes('not associated') || errMsg.includes('Account not found'));
155
- };
156
- exports.checkNotFound = checkNotFound;
157
- const makeRandomNumberString = () => Math.floor(Math.random() * 1000000000).toString();
158
- exports.makeRandomNumberString = makeRandomNumberString;
159
- const getWidth = () => {
160
- return Math.max(document.body.scrollWidth, document.documentElement.scrollWidth, document.body.offsetWidth, document.documentElement.offsetWidth, document.documentElement.clientWidth);
161
- };
162
- exports.getWidth = getWidth;
163
- const getHeight = () => {
164
- return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.documentElement.clientHeight);
165
- };
166
- exports.getHeight = getHeight;
167
- const makeImageMap = (images) => {
168
- const imagesMap = images
169
- .filter(i => i.url)
170
- .reduce((obj, i) => (Object.assign(Object.assign({}, obj), { [i.type]: i.url })), {});
171
- return imagesMap;
172
- };
173
- exports.makeImageMap = makeImageMap;
174
- const makeImageUrl = (images, isMobile) => {
175
- var _a;
176
- return (_a = images.find(i => i.type === (isMobile ? 'SECONDARY_IMAGE' : 'FEATURED_IMAGE'))) === null || _a === void 0 ? void 0 : _a.url;
177
- };
178
- exports.makeImageUrl = makeImageUrl;
179
- const makeSlides = (items, isMobile) => {
180
- if (!items || !items.length)
181
- return null;
182
- return items.map(i => (Object.assign(Object.assign({}, i), { imageUrl: (0, exports.makeImageUrl)(i.images, isMobile) })));
183
- };
184
- exports.makeSlides = makeSlides;
185
- const displayPrice = (price) => {
186
- return parseFloat(price).toFixed(2);
187
- };
188
- exports.displayPrice = displayPrice;
189
- const addCommas = (x, d) => {
190
- const valueToReplace = d === undefined ? x.toString() : x.toFixed(d);
191
- return valueToReplace.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
192
- };
193
- exports.addCommas = addCommas;
194
- const formatQuantity = (n) => {
195
- return (0, exports.addCommas)(parseFloat(n), 0);
196
- };
197
- exports.formatQuantity = formatQuantity;
198
- const formatPercentage = (n, d) => {
199
- return (0, exports.addCommas)(parseFloat(n), d);
200
- };
201
- exports.formatPercentage = formatPercentage;
202
- const formatDollars = (str, space = '', decimals = 2) => {
203
- const floatPrice = parseFloat(str);
204
- return floatPrice < 0
205
- ? `($${(0, exports.addCommas)(Math.abs(floatPrice), decimals)})`
206
- : `$${(0, exports.addCommas)(floatPrice, decimals)}${space}`;
207
- };
208
- exports.formatDollars = formatDollars;
209
- const convertStringToArray = (str) => {
210
- return str
211
- ? str
212
- .split(',')
213
- .map(i => i.trim())
214
- .filter(i => i.length)
215
- : [];
216
- };
217
- exports.convertStringToArray = convertStringToArray;
218
- const hasEntities = (reducer) => {
219
- if (!reducer)
220
- return false;
221
- const { entities, loading, error } = reducer;
222
- if (!entities)
223
- return false;
224
- if (loading === 'pending' && !entities.length)
225
- return false;
226
- return !error && entities.length;
227
- };
228
- exports.hasEntities = hasEntities;
229
- const range = (start, end, step = 1) => {
230
- if (typeof end === 'undefined') {
231
- end = start;
232
- start = 0;
233
- }
234
- const length = Math.max(Math.ceil((end - start) / step), 0);
235
- return Array.from({ length }, (_, index) => start + index * step);
236
- };
237
- exports.range = range;
238
- const sample = (collection) => {
239
- if (collection.length === 0)
240
- return undefined;
241
- const randomIndex = Math.floor(Math.random() * collection.length);
242
- return collection[randomIndex];
243
- };
244
- exports.sample = sample;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sample = exports.range = exports.hasEntities = exports.convertStringToArray = exports.formatDollars = exports.formatPercentage = 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.containsAll = exports.containsAny = exports.contains = exports.isNum = exports.isEmpty = exports.isObject = exports.isString = void 0;
4
+ const isString = (str) => {
5
+ return typeof str === 'string';
6
+ };
7
+ exports.isString = isString;
8
+ const isObject = (obj) => {
9
+ return typeof obj === 'object' && obj !== null;
10
+ };
11
+ exports.isObject = isObject;
12
+ const isEmpty = (obj) => {
13
+ return (!obj || (obj.constructor === Object && Object.entries(obj).length === 0));
14
+ };
15
+ exports.isEmpty = isEmpty;
16
+ const isNum = (s) => /^\d+$/.test(s);
17
+ exports.isNum = isNum;
18
+ /**
19
+ * @deprecated please use `containsAll` or `containsAny` instead
20
+ * @returns true if first argument contains any of the values in the second argument
21
+ */
22
+ const contains = (arr, values) => {
23
+ return values.filter(i => arr.includes(i)).length > 0;
24
+ };
25
+ exports.contains = contains;
26
+ /**
27
+ * @returns true if first argument contains any of the values in the second argument
28
+ */
29
+ const containsAny = (arr, values) => {
30
+ return values.length === 0 || values.filter(i => arr.includes(i)).length > 0;
31
+ };
32
+ exports.containsAny = containsAny;
33
+ /**
34
+ * @returns true if first argument contains all of the values of the second argument
35
+ */
36
+ const containsAll = (arr, values) => {
37
+ return values.filter(i => arr.includes(i)).length === values.length;
38
+ };
39
+ exports.containsAll = containsAll;
40
+ // https://gist.github.com/mathewbyrne/1280286
41
+ const slugify = (text) => {
42
+ return text
43
+ .toString()
44
+ .toLowerCase()
45
+ .replace('_', '-') // replace _ with -
46
+ .replace(/\s+/g, '-') // Replace spaces with -
47
+ .replace(/[^\w-]+/g, '') // Remove all non-word chars
48
+ .replace(/--+/g, '-') // Replace multiple - with single -
49
+ .replace(/^-+/, '') // Trim - from start of text
50
+ .replace(/-+$/, ''); // Trim - from end of text
51
+ };
52
+ exports.slugify = slugify;
53
+ const stripTags = (s) => s.replace(/(<([^>]+)>)/gi, '').replace('&amp;', '&');
54
+ exports.stripTags = stripTags;
55
+ const serialize = (obj) => {
56
+ const str = [];
57
+ for (const p in obj)
58
+ if (Object.prototype.hasOwnProperty.call(obj, p)) {
59
+ str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
60
+ }
61
+ return str.join('&');
62
+ };
63
+ exports.serialize = serialize;
64
+ const capitalize = (s) => {
65
+ if (!s || !s.length)
66
+ return '';
67
+ return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
68
+ };
69
+ exports.capitalize = capitalize;
70
+ const cleanPhone = (phone) => {
71
+ if (!phone)
72
+ return '';
73
+ let p = phone.replace(/\D/g, '');
74
+ if (p.length > 11)
75
+ return phone;
76
+ p = p.length === 11 && p[0] === '1' ? p.slice(1, 11) : p;
77
+ p =
78
+ p.length === 10 ? `${p.slice(0, 3)}-${p.slice(3, 6)}-${p.slice(6, 10)}` : p;
79
+ return p;
80
+ };
81
+ exports.cleanPhone = cleanPhone;
82
+ const makePhone = (phone) => {
83
+ if (!phone)
84
+ return '';
85
+ const p = phone.replace(/\D/g, '');
86
+ if (p.length > 6) {
87
+ return `${p.slice(0, 3)}-${p.slice(3, 6)}-${p.slice(6, 10)}`;
88
+ }
89
+ else if (p.length > 3) {
90
+ return `${p.slice(0, 3)}-${p.slice(3, 6)}`;
91
+ }
92
+ return p;
93
+ };
94
+ exports.makePhone = makePhone;
95
+ const validatePhone = (phone) => {
96
+ var _a;
97
+ if (!phone)
98
+ return false;
99
+ return ((_a = phone.match(/\d/g)) === null || _a === void 0 ? void 0 : _a.length) === 10;
100
+ };
101
+ exports.validatePhone = validatePhone;
102
+ const makeBirthDate = (birthDate) => {
103
+ if (!birthDate)
104
+ return null;
105
+ const b = birthDate.replace(/\D/g, '');
106
+ if (b.length > 4) {
107
+ return `${b.slice(0, 2)}/${b.slice(2, 4)}/${b.slice(4, 8)}`;
108
+ }
109
+ else if (b.length > 2) {
110
+ return `${b.slice(0, 2)}/${b.slice(2, 4)}`;
111
+ }
112
+ return b;
113
+ };
114
+ exports.makeBirthDate = makeBirthDate;
115
+ const slashesToDashes = (birthDate) => {
116
+ if (!birthDate)
117
+ return null;
118
+ const parts = birthDate.split('/');
119
+ return `${parts[2] || ''}-${parts[0] || ''}-${parts[1] || ''}`;
120
+ };
121
+ exports.slashesToDashes = slashesToDashes;
122
+ const dashesToSlashes = (birthDate) => {
123
+ if (!birthDate)
124
+ return null;
125
+ const parts = birthDate.split('-');
126
+ return `${parts[1] || ''}/${parts[2] || ''}/${parts[0] || ''}`;
127
+ };
128
+ exports.dashesToSlashes = dashesToSlashes;
129
+ const validateEmail = (email) => {
130
+ const re =
131
+ // eslint-disable-next-line no-useless-escape
132
+ /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
133
+ return re.test(email);
134
+ };
135
+ exports.validateEmail = validateEmail;
136
+ const checkEmpty = (data) => {
137
+ if ((0, exports.isEmpty)(data))
138
+ return true;
139
+ return Object.values(data).filter(i => !i).length > 0;
140
+ };
141
+ exports.checkEmpty = checkEmpty;
142
+ const checkGuestData = (data, email) => {
143
+ const { first_name, last_name, phone } = data;
144
+ const guestData = { first_name, last_name, phone, email };
145
+ const validPhone = phone ? (0, exports.validatePhone)(phone) || null : null;
146
+ const guestIncomplete = (0, exports.checkEmpty)(Object.assign(Object.assign({}, guestData), { phone: validPhone }));
147
+ return { guestData, guestIncomplete };
148
+ };
149
+ exports.checkGuestData = checkGuestData;
150
+ const checkNotFound = (errors) => {
151
+ const errMsg = errors ? errors.email || errors.form : null;
152
+ if (!errMsg)
153
+ return null;
154
+ return (errMsg.includes('not associated') || errMsg.includes('Account not found'));
155
+ };
156
+ exports.checkNotFound = checkNotFound;
157
+ const makeRandomNumberString = () => Math.floor(Math.random() * 1000000000).toString();
158
+ exports.makeRandomNumberString = makeRandomNumberString;
159
+ const getWidth = () => {
160
+ return Math.max(document.body.scrollWidth, document.documentElement.scrollWidth, document.body.offsetWidth, document.documentElement.offsetWidth, document.documentElement.clientWidth);
161
+ };
162
+ exports.getWidth = getWidth;
163
+ const getHeight = () => {
164
+ return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.documentElement.clientHeight);
165
+ };
166
+ exports.getHeight = getHeight;
167
+ const makeImageMap = (images) => {
168
+ const imagesMap = images
169
+ .filter(i => i.url)
170
+ .reduce((obj, i) => (Object.assign(Object.assign({}, obj), { [i.type]: i.url })), {});
171
+ return imagesMap;
172
+ };
173
+ exports.makeImageMap = makeImageMap;
174
+ const makeImageUrl = (images, isMobile) => {
175
+ var _a;
176
+ return (_a = images.find(i => i.type === (isMobile ? 'SECONDARY_IMAGE' : 'FEATURED_IMAGE'))) === null || _a === void 0 ? void 0 : _a.url;
177
+ };
178
+ exports.makeImageUrl = makeImageUrl;
179
+ const makeSlides = (items, isMobile) => {
180
+ if (!items || !items.length)
181
+ return null;
182
+ return items.map(i => (Object.assign(Object.assign({}, i), { imageUrl: (0, exports.makeImageUrl)(i.images, isMobile) })));
183
+ };
184
+ exports.makeSlides = makeSlides;
185
+ const displayPrice = (price) => {
186
+ return parseFloat(price).toFixed(2);
187
+ };
188
+ exports.displayPrice = displayPrice;
189
+ const addCommas = (x, d) => {
190
+ const valueToReplace = d === undefined ? x.toString() : x.toFixed(d);
191
+ return valueToReplace.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
192
+ };
193
+ exports.addCommas = addCommas;
194
+ const formatQuantity = (n) => {
195
+ return (0, exports.addCommas)(parseFloat(n), 0);
196
+ };
197
+ exports.formatQuantity = formatQuantity;
198
+ const formatPercentage = (n, d) => {
199
+ return (0, exports.addCommas)(parseFloat(n), d);
200
+ };
201
+ exports.formatPercentage = formatPercentage;
202
+ const formatDollars = (str, space = '', decimals = 2) => {
203
+ const floatPrice = parseFloat(str);
204
+ return floatPrice < 0
205
+ ? `($${(0, exports.addCommas)(Math.abs(floatPrice), decimals)})`
206
+ : `$${(0, exports.addCommas)(floatPrice, decimals)}${space}`;
207
+ };
208
+ exports.formatDollars = formatDollars;
209
+ const convertStringToArray = (str) => {
210
+ return str
211
+ ? str
212
+ .split(',')
213
+ .map(i => i.trim())
214
+ .filter(i => i.length)
215
+ : [];
216
+ };
217
+ exports.convertStringToArray = convertStringToArray;
218
+ const hasEntities = (reducer) => {
219
+ if (!reducer)
220
+ return false;
221
+ const { entities, loading, error } = reducer;
222
+ if (!entities)
223
+ return false;
224
+ if (loading === 'pending' && !entities.length)
225
+ return false;
226
+ return !error && entities.length;
227
+ };
228
+ exports.hasEntities = hasEntities;
229
+ const range = (start, end, step = 1) => {
230
+ if (typeof end === 'undefined') {
231
+ end = start;
232
+ start = 0;
233
+ }
234
+ const length = Math.max(Math.ceil((end - start) / step), 0);
235
+ return Array.from({ length }, (_, index) => start + index * step);
236
+ };
237
+ exports.range = range;
238
+ const sample = (collection) => {
239
+ if (collection.length === 0)
240
+ return undefined;
241
+ const randomIndex = Math.floor(Math.random() * collection.length);
242
+ return collection[randomIndex];
243
+ };
244
+ exports.sample = sample;
@@ -1,19 +1,19 @@
1
- export * from './cards';
2
- export * from './cart';
3
- export * from './checkout';
4
- export * from './constants';
5
- export * from './customer';
6
- export * from './datetimes';
7
- export * from './errors';
8
- export * from './googleMaps';
9
- export * from './helpers';
10
- export * from './keypad';
11
- export * from './maps';
12
- export * from './menu';
13
- export * from './revenueCenters';
14
- export * from './refunds';
15
- export * from './rewards';
16
- export * from './version';
17
- export * from './theme';
18
- export * from './favorites';
19
- export * from './pizzaBuilder';
1
+ export * from './cards';
2
+ export * from './cart';
3
+ export * from './checkout';
4
+ export * from './constants';
5
+ export * from './customer';
6
+ export * from './datetimes';
7
+ export * from './errors';
8
+ export * from './googleMaps';
9
+ export * from './helpers';
10
+ export * from './keypad';
11
+ export * from './maps';
12
+ export * from './menu';
13
+ export * from './revenueCenters';
14
+ export * from './refunds';
15
+ export * from './rewards';
16
+ export * from './version';
17
+ export * from './theme';
18
+ export * from './favorites';
19
+ export * from './pizzaBuilder';
@@ -1,23 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./cards"), exports);
5
- tslib_1.__exportStar(require("./cart"), exports);
6
- tslib_1.__exportStar(require("./checkout"), exports);
7
- tslib_1.__exportStar(require("./constants"), exports);
8
- tslib_1.__exportStar(require("./customer"), exports);
9
- tslib_1.__exportStar(require("./datetimes"), exports);
10
- tslib_1.__exportStar(require("./errors"), exports);
11
- tslib_1.__exportStar(require("./googleMaps"), exports);
12
- tslib_1.__exportStar(require("./helpers"), exports);
13
- tslib_1.__exportStar(require("./keypad"), exports);
14
- tslib_1.__exportStar(require("./maps"), exports);
15
- tslib_1.__exportStar(require("./menu"), exports);
16
- tslib_1.__exportStar(require("./revenueCenters"), exports);
17
- tslib_1.__exportStar(require("./refunds"), exports);
18
- tslib_1.__exportStar(require("./rewards"), exports);
19
- tslib_1.__exportStar(require("./version"), exports);
20
- // export * from './orders'
21
- tslib_1.__exportStar(require("./theme"), exports);
22
- tslib_1.__exportStar(require("./favorites"), exports);
23
- tslib_1.__exportStar(require("./pizzaBuilder"), exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./cards"), exports);
5
+ tslib_1.__exportStar(require("./cart"), exports);
6
+ tslib_1.__exportStar(require("./checkout"), exports);
7
+ tslib_1.__exportStar(require("./constants"), exports);
8
+ tslib_1.__exportStar(require("./customer"), exports);
9
+ tslib_1.__exportStar(require("./datetimes"), exports);
10
+ tslib_1.__exportStar(require("./errors"), exports);
11
+ tslib_1.__exportStar(require("./googleMaps"), exports);
12
+ tslib_1.__exportStar(require("./helpers"), exports);
13
+ tslib_1.__exportStar(require("./keypad"), exports);
14
+ tslib_1.__exportStar(require("./maps"), exports);
15
+ tslib_1.__exportStar(require("./menu"), exports);
16
+ tslib_1.__exportStar(require("./revenueCenters"), exports);
17
+ tslib_1.__exportStar(require("./refunds"), exports);
18
+ tslib_1.__exportStar(require("./rewards"), exports);
19
+ tslib_1.__exportStar(require("./version"), exports);
20
+ // export * from './orders'
21
+ tslib_1.__exportStar(require("./theme"), exports);
22
+ tslib_1.__exportStar(require("./favorites"), exports);
23
+ tslib_1.__exportStar(require("./pizzaBuilder"), exports);
@@ -1,9 +1,9 @@
1
- export declare const centsToDollars: (cents: number) => string;
2
- export declare const buttonsKeypad: string[][];
3
- export declare const buttonsNumpad: string[][];
4
- export declare const buttonsDollars: string[][];
5
- export declare const buttonsCheckout: string[][];
6
- export declare const reduceKeypad: (value: string, key: string) => string;
7
- export declare const reduceNumpad: (value: string, key: string, clear: boolean) => string;
8
- export declare const reduceDollars: (value: string, key: string, clear: boolean) => string;
9
- export declare const reduceCheckout: (value: string, key: string, clear: boolean) => string;
1
+ export declare const centsToDollars: (cents: number) => string;
2
+ export declare const buttonsKeypad: string[][];
3
+ export declare const buttonsNumpad: string[][];
4
+ export declare const buttonsDollars: string[][];
5
+ export declare const buttonsCheckout: string[][];
6
+ export declare const reduceKeypad: (value: string, key: string) => string;
7
+ export declare const reduceNumpad: (value: string, key: string, clear: boolean) => string;
8
+ export declare const reduceDollars: (value: string, key: string, clear: boolean) => string;
9
+ export declare const reduceCheckout: (value: string, key: string, clear: boolean) => string;