@tapcart/mobile-components 0.7.0 → 0.7.2

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 (81) hide show
  1. package/dist/components/hooks/use-infinite-scroll.d.ts +3 -1
  2. package/dist/components/hooks/use-infinite-scroll.d.ts.map +1 -1
  3. package/dist/components/hooks/use-infinite-scroll.js +34 -11
  4. package/dist/components/hooks/use-nosto-recommendation.d.ts +8 -0
  5. package/dist/components/hooks/use-nosto-recommendation.d.ts.map +1 -0
  6. package/dist/components/hooks/use-nosto-recommendation.js +105 -0
  7. package/dist/components/hooks/use-products.d.ts +3 -1
  8. package/dist/components/hooks/use-products.d.ts.map +1 -1
  9. package/dist/components/hooks/use-products.js +21 -6
  10. package/dist/components/hooks/use-reviews.d.ts +27 -0
  11. package/dist/components/hooks/use-reviews.d.ts.map +1 -0
  12. package/dist/components/hooks/use-reviews.js +130 -0
  13. package/dist/components/templates/ProductCard/utils.d.ts +78 -0
  14. package/dist/components/templates/ProductCard/utils.d.ts.map +1 -0
  15. package/dist/components/templates/ProductCard/utils.js +128 -0
  16. package/dist/components/templates/ProductGrid/index.d.ts +1 -0
  17. package/dist/components/templates/ProductGrid/index.d.ts.map +1 -0
  18. package/dist/components/templates/ProductGrid/index.js +1 -0
  19. package/dist/components/ui/Input/input.d.ts +1 -1
  20. package/dist/components/ui/Input/input.d.ts.map +1 -1
  21. package/dist/components/ui/Input/input.js +23 -5
  22. package/dist/components/ui/Input/types.d.ts +3 -2
  23. package/dist/components/ui/Input/types.d.ts.map +1 -1
  24. package/dist/components/ui/Input/useInput.d.ts +2 -2
  25. package/dist/components/ui/Input/useInput.d.ts.map +1 -1
  26. package/dist/components/ui/Input/useInput.js +24 -10
  27. package/dist/components/ui/ProductCard/utils.d.ts +94 -0
  28. package/dist/components/ui/ProductCard/utils.d.ts.map +1 -0
  29. package/dist/components/ui/ProductCard/utils.js +148 -0
  30. package/dist/components/ui/ProductGrid/index.d.ts +1 -0
  31. package/dist/components/ui/ProductGrid/index.d.ts.map +1 -0
  32. package/dist/components/ui/ProductGrid/index.js +1 -0
  33. package/dist/components/ui/accordion.d.ts +3 -1
  34. package/dist/components/ui/accordion.d.ts.map +1 -1
  35. package/dist/components/ui/accordion.js +2 -2
  36. package/dist/components/ui/button.d.ts +2 -2
  37. package/dist/components/ui/button.d.ts.map +1 -1
  38. package/dist/components/ui/button.js +1 -1
  39. package/dist/components/ui/carousel.d.ts +1 -0
  40. package/dist/components/ui/carousel.d.ts.map +1 -1
  41. package/dist/components/ui/carousel.js +62 -2
  42. package/dist/components/ui/chip.d.ts +2 -2
  43. package/dist/components/ui/icon.d.ts +4 -1
  44. package/dist/components/ui/icon.d.ts.map +1 -1
  45. package/dist/components/ui/icon.js +35 -8
  46. package/dist/components/ui/image.d.ts.map +1 -1
  47. package/dist/components/ui/image.js +3 -3
  48. package/dist/components/ui/radio-group.d.ts +2 -2
  49. package/dist/components/ui/scroll-area.d.ts +1 -0
  50. package/dist/components/ui/scroll-area.d.ts.map +1 -1
  51. package/dist/components/ui/scroll-area.js +2 -2
  52. package/dist/components/ui/toast.d.ts +2 -2
  53. package/dist/components/ui/toggle-group.d.ts +2 -2
  54. package/dist/components/ui/toggle.d.ts +2 -2
  55. package/dist/index.d.ts +9 -2
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +9 -2
  58. package/dist/lib/price.d.ts +29 -0
  59. package/dist/lib/price.d.ts.map +1 -0
  60. package/dist/lib/price.js +66 -0
  61. package/dist/lib/utils.d.ts +18 -0
  62. package/dist/lib/utils.d.ts.map +1 -1
  63. package/dist/lib/utils.js +44 -1
  64. package/dist/styles.css +201 -727
  65. package/dist/tapcart-mobile-components.umd.js +44 -0
  66. package/package.json +4 -3
  67. package/dist/components/templates/product-card.d.ts +0 -33
  68. package/dist/components/templates/product-card.d.ts.map +0 -1
  69. package/dist/components/templates/product-card.js +0 -42
  70. package/dist/components/templates/product-grid.d.ts +0 -14
  71. package/dist/components/templates/product-grid.d.ts.map +0 -1
  72. package/dist/components/templates/product-grid.js +0 -22
  73. package/dist/components/ui/input.d.ts +0 -17
  74. package/dist/components/ui/input.d.ts.map +0 -1
  75. package/dist/components/ui/input.js +0 -35
  76. package/dist/components/ui/product-grid.d.ts +0 -15
  77. package/dist/components/ui/product-grid.d.ts.map +0 -1
  78. package/dist/components/ui/product-grid.js +0 -22
  79. package/dist/components/ui/select.d.ts +0 -14
  80. package/dist/components/ui/select.d.ts.map +0 -1
  81. package/dist/components/ui/select.js +0 -59
package/dist/lib/utils.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { clsx } from "clsx";
2
2
  import { twMerge } from "tailwind-merge";
3
+ import dayjs from 'dayjs';
4
+ import relativeTime from 'dayjs/plugin/relativeTime';
3
5
  export function cn(...inputs) {
4
6
  return twMerge(clsx(inputs));
5
7
  }
@@ -147,6 +149,28 @@ export function variantGidFromId(id) {
147
149
  return id;
148
150
  return `gid://shopify/ProductVariant/${id}`;
149
151
  }
152
+ // Use to prevent multiple clicks in quick succession
153
+ export function throttle(fn, wait) {
154
+ let throttle = false;
155
+ return [
156
+ function () {
157
+ return throttle;
158
+ },
159
+ function (...args) {
160
+ if (!throttle) {
161
+ fn(...args);
162
+ throttle = true;
163
+ setInterval(() => {
164
+ throttle = false;
165
+ }, wait);
166
+ }
167
+ },
168
+ ];
169
+ }
170
+ export function formatRelativeTime(inputDate) {
171
+ dayjs.extend(relativeTime);
172
+ return dayjs(inputDate).fromNow();
173
+ }
150
174
  export const stringRatioToInt = (string) => {
151
175
  const [numerator, denominator] = string
152
176
  .replace(":", "/")
@@ -166,4 +190,23 @@ export const getOverlayStyle = (opacity) => {
166
190
  backgroundColor: `rgba(0, 0, 0, ${opacityDecimal})`,
167
191
  };
168
192
  };
169
- // #endregion =-=-=-= END BLOCK UTILS =-=-=-=
193
+ const DESTINATION_HANDLERS = {
194
+ "app-screen": (location, actions) => actions.openScreen({ destination: { type: "internal", url: location } }),
195
+ url: (location, actions) => actions.openScreen({
196
+ destination: { type: "web", url: `https://${location}` },
197
+ }),
198
+ product: (location, actions) => actions.openProduct({ productId: location }),
199
+ collection: (location, actions) => actions.openCollection({ collectionId: location }),
200
+ none: () => { },
201
+ };
202
+ export const getDestinationHandler = (type) => {
203
+ return DESTINATION_HANDLERS[type];
204
+ };
205
+ export function getProductGidsFromIds(ids) {
206
+ return ids.map((id) => {
207
+ if (id.startsWith("gid://shopify/Product/")) {
208
+ return id;
209
+ }
210
+ return `gid://shopify/Product/${id}`;
211
+ });
212
+ }