@storepecker/storefront-core 2.3.6 → 2.4.0

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 (91) hide show
  1. package/dist/api/index.cjs +28 -24
  2. package/dist/api/index.d.cts +8 -5
  3. package/dist/api/index.d.ts +8 -5
  4. package/dist/api/index.js +1 -1
  5. package/dist/{booking-CG6tul9l.d.ts → booking-BVWe8HHh.d.ts} +1 -1
  6. package/dist/{booking-DNVf5ZAS.d.cts → booking-DX9SU_qm.d.cts} +1 -1
  7. package/dist/cart-kJoawc_Z.d.cts +126 -0
  8. package/dist/cart-y-7RPmnQ.d.ts +126 -0
  9. package/dist/checkout/index.cjs +22 -22
  10. package/dist/checkout/index.d.cts +3 -1
  11. package/dist/checkout/index.d.ts +3 -1
  12. package/dist/checkout/index.js +2 -2
  13. package/dist/{chunk-BTT3XQ32.cjs → chunk-33TWVRZE.cjs} +6 -6
  14. package/dist/chunk-3YRSHPM6.cjs +34 -0
  15. package/dist/{chunk-ILVGYHNI.js → chunk-6Q7QMPOQ.js} +2 -1
  16. package/dist/{chunk-HTFVROIV.cjs → chunk-7UK3E7SL.cjs} +6 -0
  17. package/dist/chunk-B3BXKMQA.cjs +271 -0
  18. package/dist/chunk-BTR3HLL4.js +14 -0
  19. package/dist/chunk-EGFOTJPC.js +22 -0
  20. package/dist/{chunk-YUPBTD4M.js → chunk-F45S7UWC.js} +1 -139
  21. package/dist/chunk-HAQWCNDY.cjs +24 -0
  22. package/dist/{chunk-Y4NGR42Z.js → chunk-HUIT4JCR.js} +1 -1
  23. package/dist/{chunk-TF2KMTB6.js → chunk-JRYWZMNT.js} +1 -1
  24. package/dist/{chunk-JCOOINQF.cjs → chunk-KLNKIQQM.cjs} +4 -3
  25. package/dist/chunk-L43KF3AC.js +269 -0
  26. package/dist/chunk-LHF5BSWO.cjs +16 -0
  27. package/dist/chunk-LJUGNSQQ.cjs +149 -0
  28. package/dist/chunk-NA5GT4D3.js +75 -0
  29. package/dist/chunk-OSM73ETC.js +139 -0
  30. package/dist/{chunk-4CVKE6CC.cjs → chunk-OTMTHA5C.cjs} +0 -147
  31. package/dist/{chunk-JH4JJBXE.cjs → chunk-TTIQRDHX.cjs} +2 -2
  32. package/dist/chunk-U7EXLQCT.js +32 -0
  33. package/dist/{chunk-LW3V53WJ.js → chunk-UVU7H4E6.js} +6 -1
  34. package/dist/chunk-V447PVRV.cjs +308 -0
  35. package/dist/chunk-VWQR3A7V.cjs +81 -0
  36. package/dist/chunk-YK4M3SFP.js +301 -0
  37. package/dist/{collections-Bz9KD7Na.d.cts → collections-BDSVfRNo.d.ts} +1 -1
  38. package/dist/{collections-CkEUi3BR.d.ts → collections-WzvTO0OQ.d.cts} +1 -1
  39. package/dist/components/address-form.cjs +17 -0
  40. package/dist/components/address-form.css +329 -0
  41. package/dist/components/address-form.d.cts +33 -0
  42. package/dist/components/address-form.d.ts +33 -0
  43. package/dist/components/address-form.js +11 -0
  44. package/dist/components/digital-product-download-modal.cjs +8 -0
  45. package/dist/components/digital-product-download-modal.d.cts +15 -0
  46. package/dist/components/digital-product-download-modal.d.ts +15 -0
  47. package/dist/components/digital-product-download-modal.js +2 -0
  48. package/dist/components/index.cjs +35 -695
  49. package/dist/components/index.d.cts +14 -87
  50. package/dist/components/index.d.ts +14 -87
  51. package/dist/components/index.js +11 -688
  52. package/dist/components/search-dropdown.cjs +7 -0
  53. package/dist/components/search-dropdown.css +200 -0
  54. package/dist/components/search-dropdown.d.cts +28 -0
  55. package/dist/components/search-dropdown.d.ts +28 -0
  56. package/dist/components/search-dropdown.js +1 -0
  57. package/dist/components/share-button.cjs +9 -0
  58. package/dist/components/share-button.d.cts +11 -0
  59. package/dist/components/share-button.d.ts +11 -0
  60. package/dist/components/share-button.js +3 -0
  61. package/dist/components/share-icon.cjs +7 -0
  62. package/dist/components/share-icon.d.cts +9 -0
  63. package/dist/components/share-icon.d.ts +9 -0
  64. package/dist/components/share-icon.js +1 -0
  65. package/dist/components/theme-data-initializer.cjs +8 -0
  66. package/dist/components/theme-data-initializer.d.cts +12 -0
  67. package/dist/components/theme-data-initializer.d.ts +12 -0
  68. package/dist/components/theme-data-initializer.js +2 -0
  69. package/dist/hooks/index.cjs +18 -17
  70. package/dist/hooks/index.d.cts +4 -2
  71. package/dist/hooks/index.d.ts +4 -2
  72. package/dist/hooks/index.js +6 -5
  73. package/dist/models/index.d.cts +6 -4
  74. package/dist/models/index.d.ts +6 -4
  75. package/dist/orders-CjNmCY5I.d.cts +144 -0
  76. package/dist/orders-L_8eIkUS.d.ts +144 -0
  77. package/dist/{pixelEvents-OVIkPw-J.d.ts → pixelEvents-Bo-VjAx8.d.ts} +4 -2
  78. package/dist/{pixelEvents-DYkiTkb2.d.cts → pixelEvents-C1rFPOwb.d.cts} +4 -2
  79. package/dist/{orders-fIdANHSl.d.ts → product-DJMdi4D4.d.cts} +1 -265
  80. package/dist/{orders-fIdANHSl.d.cts → product-DJMdi4D4.d.ts} +1 -265
  81. package/dist/store/index.cjs +5 -5
  82. package/dist/store/index.d.cts +6 -4
  83. package/dist/store/index.d.ts +6 -4
  84. package/dist/store/index.js +2 -2
  85. package/dist/utils/index.cjs +44 -43
  86. package/dist/utils/index.d.cts +7 -5
  87. package/dist/utils/index.d.ts +7 -5
  88. package/dist/utils/index.js +3 -2
  89. package/dist/{wishlist-stNzfvIP.d.cts → wishlist-CUuCTSVJ.d.cts} +1 -1
  90. package/dist/{wishlist-_bd4gLyQ.d.ts → wishlist-DKYFZR0s.d.ts} +1 -1
  91. package/package.json +49 -1
@@ -1,143 +1,5 @@
1
1
  'use strict';
2
2
 
3
- // src/utils/cache.ts
4
- var DEFAULT_EXPIRY_HOURS = 24;
5
- var CacheManager = class _CacheManager {
6
- constructor() {
7
- this.cache = /* @__PURE__ */ new Map();
8
- this.loadFromStorage();
9
- }
10
- static getInstance() {
11
- if (!_CacheManager.instance) {
12
- _CacheManager.instance = new _CacheManager();
13
- }
14
- return _CacheManager.instance;
15
- }
16
- loadFromStorage() {
17
- if (typeof window === "undefined") return;
18
- try {
19
- const stored = localStorage.getItem("app_cache");
20
- if (stored) {
21
- const parsed = JSON.parse(stored);
22
- this.cache = new Map(Object.entries(parsed));
23
- this.cleanExpired();
24
- }
25
- } catch (error) {
26
- console.warn("Failed to load cache from storage:", error);
27
- }
28
- }
29
- saveToStorage() {
30
- if (typeof window === "undefined") return;
31
- try {
32
- const cacheObject = Object.fromEntries(this.cache);
33
- localStorage.setItem("app_cache", JSON.stringify(cacheObject));
34
- } catch (error) {
35
- console.warn("Failed to save cache to storage:", error);
36
- }
37
- }
38
- cleanExpired() {
39
- const now = Date.now();
40
- const keysToDelete = [];
41
- this.cache.forEach((item, key) => {
42
- if (now > item.expiry) {
43
- keysToDelete.push(key);
44
- }
45
- });
46
- keysToDelete.forEach((key) => {
47
- this.cache.delete(key);
48
- });
49
- this.saveToStorage();
50
- }
51
- set(key, data, options = {}) {
52
- const expiryHours = options.expiryHours || DEFAULT_EXPIRY_HOURS;
53
- const now = Date.now();
54
- const expiry = now + expiryHours * 60 * 60 * 1e3;
55
- const cacheItem = {
56
- data,
57
- timestamp: now,
58
- expiry
59
- };
60
- this.cache.set(key, cacheItem);
61
- this.saveToStorage();
62
- }
63
- get(key) {
64
- this.cleanExpired();
65
- const item = this.cache.get(key);
66
- if (!item) return null;
67
- const now = Date.now();
68
- if (now > item.expiry) {
69
- this.cache.delete(key);
70
- this.saveToStorage();
71
- return null;
72
- }
73
- return item.data;
74
- }
75
- has(key) {
76
- this.cleanExpired();
77
- return this.cache.has(key);
78
- }
79
- delete(key) {
80
- this.cache.delete(key);
81
- this.saveToStorage();
82
- }
83
- clear() {
84
- this.cache.clear();
85
- if (typeof window !== "undefined") {
86
- localStorage.removeItem("app_cache");
87
- }
88
- }
89
- getCacheInfo() {
90
- this.cleanExpired();
91
- return {
92
- size: this.cache.size,
93
- keys: Array.from(this.cache.keys())
94
- };
95
- }
96
- invalidateCache(pattern) {
97
- this.cleanExpired();
98
- if (!pattern) {
99
- this.clear();
100
- return;
101
- }
102
- const keysToDelete = [];
103
- this.cache.forEach((item, key) => {
104
- if (key.includes(pattern)) {
105
- keysToDelete.push(key);
106
- }
107
- });
108
- keysToDelete.forEach((key) => {
109
- this.cache.delete(key);
110
- });
111
- this.saveToStorage();
112
- }
113
- };
114
- var cache = CacheManager.getInstance();
115
- function setCache(key, data, options = {}) {
116
- cache.set(key, data, options);
117
- }
118
- function getCache(key) {
119
- return cache.get(key);
120
- }
121
- function hasCache(key) {
122
- return cache.has(key);
123
- }
124
- function deleteCache(key) {
125
- cache.delete(key);
126
- }
127
- function clearCache() {
128
- cache.clear();
129
- }
130
- function invalidateCache(pattern) {
131
- cache.invalidateCache(pattern);
132
- }
133
- function generateCacheKey(endpoint, params) {
134
- const baseKey = endpoint.replace(/[^a-zA-Z0-9]/g, "_");
135
- if (!params) return baseKey;
136
- const paramString = JSON.stringify(params);
137
- const hash = btoa(paramString).replace(/[^a-zA-Z0-9]/g, "");
138
- return `${baseKey}_${hash}`;
139
- }
140
-
141
3
  // src/utils/misc.ts
142
4
  function convertObjectToParams(params) {
143
5
  const cleanedParams = Object.fromEntries(
@@ -288,25 +150,16 @@ async function getAddressMeta(countryCode) {
288
150
  };
289
151
  }
290
152
 
291
- exports.CacheManager = CacheManager;
292
- exports.cache = cache;
293
- exports.clearCache = clearCache;
294
153
  exports.constructFilter = constructFilter;
295
154
  exports.convertObjectToParams = convertObjectToParams;
296
155
  exports.convertToCurrency = convertToCurrency;
297
- exports.deleteCache = deleteCache;
298
156
  exports.digestMessage = digestMessage;
299
157
  exports.formatDateTime = formatDateTime;
300
158
  exports.formatPostalLabel = formatPostalLabel;
301
- exports.generateCacheKey = generateCacheKey;
302
159
  exports.getAddressMeta = getAddressMeta;
303
- exports.getCache = getCache;
304
160
  exports.getDelayInMilliseconds = getDelayInMilliseconds;
305
161
  exports.getParamsFromURL = getParamsFromURL;
306
162
  exports.getQueryParams = getQueryParams;
307
- exports.hasCache = hasCache;
308
- exports.invalidateCache = invalidateCache;
309
163
  exports.pluralize = pluralize;
310
164
  exports.pushParamsToURL = pushParamsToURL;
311
- exports.setCache = setCache;
312
165
  exports.shareLink = shareLink;
@@ -2,7 +2,7 @@
2
2
 
3
3
  var chunkY2CPMT34_cjs = require('./chunk-Y2CPMT34.cjs');
4
4
  var chunkSMHJRNCR_cjs = require('./chunk-SMHJRNCR.cjs');
5
- var chunkHTFVROIV_cjs = require('./chunk-HTFVROIV.cjs');
5
+ var chunk7UK3E7SL_cjs = require('./chunk-7UK3E7SL.cjs');
6
6
  var chunkBBRXE57K_cjs = require('./chunk-BBRXE57K.cjs');
7
7
  var chunkNE3ZHELZ_cjs = require('./chunk-NE3ZHELZ.cjs');
8
8
  var zustand = require('zustand');
@@ -123,7 +123,7 @@ var useCartStore = zustand.create((set) => ({
123
123
  updateCustomization: async (customizationInputs) => {
124
124
  set({ status: "loading" /* LOADING */ });
125
125
  try {
126
- await chunkHTFVROIV_cjs.updateOrderCustomization({ customization_inputs: customizationInputs });
126
+ await chunk7UK3E7SL_cjs.updateOrderCustomization({ customization_inputs: customizationInputs });
127
127
  } catch {
128
128
  } finally {
129
129
  set({ status: "idle" /* IDLE */ });
@@ -0,0 +1,32 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ // src/components/icons/share.tsx
4
+ function ShareIcon({
5
+ width = 20,
6
+ height = 23,
7
+ className
8
+ }) {
9
+ return /* @__PURE__ */ jsx(
10
+ "svg",
11
+ {
12
+ width,
13
+ height,
14
+ viewBox: "0 0 20 23",
15
+ fill: "none",
16
+ xmlns: "http://www.w3.org/2000/svg",
17
+ className,
18
+ children: /* @__PURE__ */ jsx(
19
+ "path",
20
+ {
21
+ d: "M5.0745 10.357C4.82568 9.90934 4.43524 9.55692 3.96446 9.35513C3.49369 9.15333 2.96923 9.11357 2.47341 9.24209C1.97759 9.37061 1.53848 9.66013 1.22501 10.0652C0.911539 10.4703 0.741455 10.968 0.741455 11.4802C0.741455 11.9924 0.911539 12.4901 1.22501 12.8952C1.53848 13.3003 1.97759 13.5898 2.47341 13.7183C2.96923 13.8469 3.49369 13.8071 3.96446 13.6053C4.43524 13.4035 4.82568 13.0511 5.0745 12.6034M5.0745 10.357C5.25947 10.69 5.36531 11.0723 5.36531 11.4802C5.36531 11.8882 5.25947 12.2715 5.0745 12.6034M5.0745 10.357L14.9045 4.89641M5.0745 12.6034L14.9045 18.064M14.9045 4.89641C15.0486 5.16783 15.2454 5.4078 15.4833 5.60229C15.7213 5.79678 15.9956 5.94187 16.2903 6.0291C16.585 6.11633 16.8941 6.14393 17.1996 6.1103C17.5051 6.07667 17.8008 5.98247 18.0694 5.83323C18.338 5.68398 18.5742 5.48267 18.7642 5.24108C18.9541 4.99948 19.094 4.72244 19.1756 4.42616C19.2572 4.12988 19.279 3.8203 19.2395 3.51552C19.2001 3.21074 19.1003 2.91687 18.946 2.65111C18.6419 2.12739 18.1445 1.74388 17.5606 1.58304C16.9768 1.4222 16.3531 1.49685 15.8237 1.79096C15.2943 2.08507 14.9014 2.57515 14.7295 3.15586C14.5577 3.73656 14.6205 4.36152 14.9045 4.89641ZM14.9045 18.064C14.757 18.3295 14.6632 18.6215 14.6286 18.9232C14.5939 19.225 14.619 19.5306 14.7025 19.8226C14.7859 20.1146 14.9261 20.3874 15.1149 20.6253C15.3038 20.8631 15.5376 21.0615 15.8031 21.209C16.0686 21.3565 16.3606 21.4502 16.6623 21.4849C16.9641 21.5196 17.2697 21.4944 17.5617 21.411C17.8537 21.3276 18.1265 21.1874 18.3644 20.9986C18.6022 20.8097 18.8006 20.5758 18.9481 20.3103C19.246 19.7741 19.3186 19.1415 19.1501 18.5517C18.9816 17.962 18.5857 17.4633 18.0494 17.1654C17.5132 16.8675 16.8806 16.7948 16.2908 16.9634C15.7011 17.1319 15.2024 17.5278 14.9045 18.064Z",
22
+ stroke: "currentColor",
23
+ strokeWidth: "1.5",
24
+ strokeLinecap: "round",
25
+ strokeLinejoin: "round"
26
+ }
27
+ )
28
+ }
29
+ );
30
+ }
31
+
32
+ export { ShareIcon };
@@ -15,6 +15,11 @@ async function getOrderDetailsByNumber(orderNumber) {
15
15
  params: { order_number: orderNumber }
16
16
  });
17
17
  }
18
+ async function getOrderDetailsByRef(orderRef) {
19
+ return http_service_default.get("/customer/order-detail/", {
20
+ params: { order_ref: orderRef }
21
+ });
22
+ }
18
23
  async function getPublicOrderDetailsByNumber(orderNumber) {
19
24
  return http_service_default.get("/customer/public_order/", {
20
25
  params: { order_number: orderNumber }
@@ -106,4 +111,4 @@ async function verifyTabbyPayment(orderNumber) {
106
111
  });
107
112
  }
108
113
 
109
- export { checkPhonepePaymentStatus, getOrderDetails, getOrderDetailsByNumber, getOrders, getPublicOrderDetailsByNumber, getStripePaymentStatus, getStripePaymentStatusPublic, makeCODOrder, phonepeOrderSuccess, phonepePublicOrderSuccess, placeOrder, publicMakeCODOrder, publicPlaceOrder, razorpayOrderFail, razorpayOrderSuccess, razorpayPublicOrderSuccess, stripeOrderFail, stripeOrderSuccess, stripePublicOrderSuccess, updateOrder, updateOrderCustomization, uploadCustomizationImage, verifyTabbyPayment };
114
+ export { checkPhonepePaymentStatus, getOrderDetails, getOrderDetailsByNumber, getOrderDetailsByRef, getOrders, getPublicOrderDetailsByNumber, getStripePaymentStatus, getStripePaymentStatusPublic, makeCODOrder, phonepeOrderSuccess, phonepePublicOrderSuccess, placeOrder, publicMakeCODOrder, publicPlaceOrder, razorpayOrderFail, razorpayOrderSuccess, razorpayPublicOrderSuccess, stripeOrderFail, stripeOrderSuccess, stripePublicOrderSuccess, updateOrder, updateOrderCustomization, uploadCustomizationImage, verifyTabbyPayment };
@@ -0,0 +1,308 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var clsx = require('clsx');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var clsx__default = /*#__PURE__*/_interopDefault(clsx);
10
+
11
+ // src/components/search-dropdown/search-dropdown.tsx
12
+
13
+ // src/components/search-dropdown/search-dropdown.module.css
14
+ var search_dropdown_default = {};
15
+ function DownChevron({
16
+ width = 24,
17
+ height = 24,
18
+ className
19
+ }) {
20
+ return /* @__PURE__ */ jsxRuntime.jsx(
21
+ "svg",
22
+ {
23
+ fill: "currentColor",
24
+ height,
25
+ width,
26
+ xmlns: "http://www.w3.org/2000/svg",
27
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
28
+ viewBox: "0 0 407.437 407.437",
29
+ xmlSpace: "preserve",
30
+ className,
31
+ children: /* @__PURE__ */ jsxRuntime.jsx(
32
+ "polygon",
33
+ {
34
+ points: "386.258,91.567 203.718,273.512 21.179,91.567 0,112.815 203.718,315.87 407.437,112.815 ",
35
+ strokeWidth: "2"
36
+ }
37
+ )
38
+ }
39
+ );
40
+ }
41
+ function SearchIcon({
42
+ width = 24,
43
+ height = 24,
44
+ className
45
+ }) {
46
+ return /* @__PURE__ */ jsxRuntime.jsxs(
47
+ "svg",
48
+ {
49
+ width,
50
+ height,
51
+ viewBox: "0 0 24 24",
52
+ fill: "none",
53
+ xmlns: "http://www.w3.org/2000/svg",
54
+ className,
55
+ children: [
56
+ /* @__PURE__ */ jsxRuntime.jsx(
57
+ "path",
58
+ {
59
+ d: "M17.5 17.5L22 22",
60
+ stroke: "currentColor",
61
+ strokeWidth: "1.5",
62
+ strokeLinecap: "round",
63
+ strokeLinejoin: "round"
64
+ }
65
+ ),
66
+ /* @__PURE__ */ jsxRuntime.jsx(
67
+ "path",
68
+ {
69
+ d: "M20 11C20 6.02944 15.9706 2 11 2C6.02944 2 2 6.02944 2 11C2 15.9706 6.02944 20 11 20C15.9706 20 20 15.9706 20 11Z",
70
+ stroke: "currentColor",
71
+ strokeWidth: "1.5",
72
+ strokeLinejoin: "round"
73
+ }
74
+ )
75
+ ]
76
+ }
77
+ );
78
+ }
79
+ var SearchDropdown = ({
80
+ options,
81
+ value,
82
+ onChange,
83
+ placeholder = "Select an option",
84
+ searchPlaceholder = "Search...",
85
+ className,
86
+ disabled = false,
87
+ error,
88
+ label,
89
+ name,
90
+ renderOption,
91
+ renderSelected,
92
+ filterFunction,
93
+ emptyMessage = "No options found",
94
+ maxHeight = "300px"
95
+ }) => {
96
+ const [isOpen, setIsOpen] = react.useState(false);
97
+ const [searchTerm, setSearchTerm] = react.useState("");
98
+ const [focusedIndex, setFocusedIndex] = react.useState(-1);
99
+ const dropdownRef = react.useRef(null);
100
+ const searchInputRef = react.useRef(null);
101
+ const optionsListRef = react.useRef(null);
102
+ const selectedOption = react.useMemo(
103
+ () => options.find((opt) => opt.value === value) || null,
104
+ [options, value]
105
+ );
106
+ const defaultFilter = react.useCallback(
107
+ (option, term) => {
108
+ return option.label.toLowerCase().includes(term.toLowerCase());
109
+ },
110
+ []
111
+ );
112
+ const filter = filterFunction || defaultFilter;
113
+ const filteredOptions = react.useMemo(() => {
114
+ if (!searchTerm.trim()) return options;
115
+ return options.filter((option) => filter(option, searchTerm));
116
+ }, [options, searchTerm, filter]);
117
+ react.useEffect(() => {
118
+ function handleClickOutside(event) {
119
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
120
+ setIsOpen(false);
121
+ setSearchTerm("");
122
+ setFocusedIndex(-1);
123
+ }
124
+ }
125
+ if (isOpen) {
126
+ document.addEventListener("mousedown", handleClickOutside);
127
+ setTimeout(() => {
128
+ searchInputRef.current?.focus();
129
+ }, 0);
130
+ }
131
+ return () => {
132
+ document.removeEventListener("mousedown", handleClickOutside);
133
+ };
134
+ }, [isOpen]);
135
+ const handleSelect = react.useCallback(
136
+ (option) => {
137
+ if (option.disabled) return;
138
+ onChange?.(option.value, option);
139
+ setIsOpen(false);
140
+ setSearchTerm("");
141
+ setFocusedIndex(-1);
142
+ },
143
+ [onChange]
144
+ );
145
+ react.useEffect(() => {
146
+ function handleKeyDown(event) {
147
+ if (!isOpen) return;
148
+ switch (event.key) {
149
+ case "ArrowDown":
150
+ event.preventDefault();
151
+ setFocusedIndex(
152
+ (prev) => prev < filteredOptions.length - 1 ? prev + 1 : prev
153
+ );
154
+ break;
155
+ case "ArrowUp":
156
+ event.preventDefault();
157
+ setFocusedIndex((prev) => prev > 0 ? prev - 1 : -1);
158
+ break;
159
+ case "Enter":
160
+ event.preventDefault();
161
+ if (focusedIndex >= 0 && focusedIndex < filteredOptions.length) {
162
+ handleSelect(filteredOptions[focusedIndex]);
163
+ }
164
+ break;
165
+ case "Escape":
166
+ event.preventDefault();
167
+ setIsOpen(false);
168
+ setSearchTerm("");
169
+ setFocusedIndex(-1);
170
+ break;
171
+ }
172
+ }
173
+ if (isOpen) {
174
+ document.addEventListener("keydown", handleKeyDown);
175
+ }
176
+ return () => {
177
+ document.removeEventListener("keydown", handleKeyDown);
178
+ };
179
+ }, [isOpen, filteredOptions, focusedIndex, handleSelect]);
180
+ react.useEffect(() => {
181
+ if (focusedIndex >= 0 && optionsListRef.current) {
182
+ const focusedElement = optionsListRef.current.children[focusedIndex];
183
+ if (focusedElement) {
184
+ focusedElement.scrollIntoView({
185
+ behavior: "smooth",
186
+ block: "nearest"
187
+ });
188
+ }
189
+ }
190
+ }, [focusedIndex]);
191
+ const handleToggle = () => {
192
+ if (disabled) return;
193
+ setIsOpen((prev) => !prev);
194
+ if (!isOpen) {
195
+ setSearchTerm("");
196
+ setFocusedIndex(-1);
197
+ }
198
+ };
199
+ const handleSearchChange = (e) => {
200
+ setSearchTerm(e.target.value);
201
+ setFocusedIndex(-1);
202
+ };
203
+ const handleOptionMouseEnter = (index) => {
204
+ setFocusedIndex(index);
205
+ };
206
+ return /* @__PURE__ */ jsxRuntime.jsxs(
207
+ "div",
208
+ {
209
+ ref: dropdownRef,
210
+ className: clsx__default.default(search_dropdown_default.searchDropdown, className, {
211
+ [search_dropdown_default.disabled]: disabled,
212
+ [search_dropdown_default.error]: error,
213
+ [search_dropdown_default.open]: isOpen
214
+ }),
215
+ children: [
216
+ label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: search_dropdown_default.label, htmlFor: name, children: label }),
217
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: search_dropdown_default.dropdownContainer, children: [
218
+ /* @__PURE__ */ jsxRuntime.jsxs(
219
+ "button",
220
+ {
221
+ type: "button",
222
+ className: search_dropdown_default.dropdownButton,
223
+ onClick: handleToggle,
224
+ disabled,
225
+ "aria-expanded": isOpen,
226
+ "aria-haspopup": "listbox",
227
+ "aria-label": label || placeholder,
228
+ id: name,
229
+ children: [
230
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: search_dropdown_default.selectedValue, children: selectedOption ? renderSelected ? renderSelected(selectedOption) : selectedOption.label : placeholder }),
231
+ /* @__PURE__ */ jsxRuntime.jsx(
232
+ DownChevron,
233
+ {
234
+ width: 16,
235
+ height: 16,
236
+ className: clsx__default.default(search_dropdown_default.chevron, {
237
+ [search_dropdown_default.chevronOpen]: isOpen
238
+ })
239
+ }
240
+ )
241
+ ]
242
+ }
243
+ ),
244
+ isOpen && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: search_dropdown_default.dropdownMenu, style: { maxHeight }, children: [
245
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: search_dropdown_default.searchContainer, children: [
246
+ /* @__PURE__ */ jsxRuntime.jsx(
247
+ SearchIcon,
248
+ {
249
+ width: 16,
250
+ height: 16,
251
+ className: search_dropdown_default.searchIcon
252
+ }
253
+ ),
254
+ /* @__PURE__ */ jsxRuntime.jsx(
255
+ "input",
256
+ {
257
+ ref: searchInputRef,
258
+ type: "text",
259
+ className: search_dropdown_default.searchInput,
260
+ placeholder: searchPlaceholder,
261
+ value: searchTerm,
262
+ onChange: handleSearchChange,
263
+ onClick: (e) => e.stopPropagation(),
264
+ onKeyDown: (e) => {
265
+ if (e.key === "Enter" && filteredOptions.length === 1) {
266
+ e.preventDefault();
267
+ handleSelect(filteredOptions[0]);
268
+ }
269
+ },
270
+ autoComplete: "off"
271
+ }
272
+ )
273
+ ] }),
274
+ /* @__PURE__ */ jsxRuntime.jsx(
275
+ "ul",
276
+ {
277
+ ref: optionsListRef,
278
+ className: search_dropdown_default.optionsList,
279
+ role: "listbox",
280
+ children: filteredOptions.length > 0 ? filteredOptions.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
281
+ "li",
282
+ {
283
+ className: clsx__default.default(search_dropdown_default.option, {
284
+ [search_dropdown_default.optionSelected]: option.value === value,
285
+ [search_dropdown_default.optionFocused]: index === focusedIndex,
286
+ [search_dropdown_default.optionDisabled]: option.disabled
287
+ }),
288
+ onClick: () => handleSelect(option),
289
+ onMouseEnter: () => handleOptionMouseEnter(index),
290
+ role: "option",
291
+ "aria-selected": option.value === value,
292
+ children: renderOption ? renderOption(option) : option.label
293
+ },
294
+ option.value
295
+ )) : /* @__PURE__ */ jsxRuntime.jsx("li", { className: search_dropdown_default.emptyMessage, children: emptyMessage })
296
+ }
297
+ )
298
+ ] })
299
+ ] }),
300
+ error && /* @__PURE__ */ jsxRuntime.jsx("span", { className: search_dropdown_default.errorMessage, children: error })
301
+ ]
302
+ }
303
+ );
304
+ };
305
+ var search_dropdown_default2 = SearchDropdown;
306
+
307
+ exports.DownChevron = DownChevron;
308
+ exports.search_dropdown_default = search_dropdown_default2;
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ var chunkBBRB475I_cjs = require('./chunk-BBRB475I.cjs');
4
+ var Modal = require('react-responsive-modal');
5
+ require('react-responsive-modal/styles.css');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var Modal__default = /*#__PURE__*/_interopDefault(Modal);
11
+
12
+ var checkIfLimitReached = (attribute) => {
13
+ return chunkBBRB475I_cjs.isExpired(attribute.expiry_date) || attribute.download_count === 0;
14
+ };
15
+ var DigitalProductDownloadModal = ({ open, onClose, product, downloadAttribute, onDownload, loading }) => {
16
+ return /* @__PURE__ */ jsxRuntime.jsx(
17
+ Modal__default.default,
18
+ {
19
+ classNames: {
20
+ modal: "modal modal-lg modal-confirm",
21
+ closeButton: "modal-close"
22
+ },
23
+ open,
24
+ onClose,
25
+ center: true,
26
+ closeIcon: null,
27
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "modal-body px-4 py-2", children: [
28
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-2xl block mb-2 fw-regular", children: [
29
+ "Download links for ",
30
+ product?.product_name
31
+ ] }),
32
+ /* @__PURE__ */ jsxRuntime.jsx("hr", { className: "mb-4 mt-2" }),
33
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "download-links", children: loading ? Array.from({ length: 3 }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-100 rounded-1 mb-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
34
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-100", children: [
35
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shine line w-75" }),
36
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shine line w-50 mt-2" })
37
+ ] }),
38
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shine w-160 h-32 rounded-1" })
39
+ ] }) }, index)) : downloadAttribute.map((attribute, index) => /* @__PURE__ */ jsxRuntime.jsxs(
40
+ "div",
41
+ {
42
+ className: "flex items-center justify-between mt-3",
43
+ children: [
44
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
45
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "block text-md lh-1", children: [
46
+ "Download link ",
47
+ index + 1
48
+ ] }),
49
+ checkIfLimitReached(attribute) ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-danger text-sm lh-1", children: "Download link expired." }) : /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-textSecondary text-sm lh-1", children: [
50
+ "Remaining tries: ",
51
+ attribute.download_count,
52
+ " ",
53
+ "\u2022\xA0 Expires",
54
+ " ",
55
+ chunkBBRB475I_cjs.timeFromNow(attribute.expiry_date)
56
+ ] })
57
+ ] }),
58
+ /* @__PURE__ */ jsxRuntime.jsx(
59
+ "button",
60
+ {
61
+ className: "btn btn-text btn-medium",
62
+ onClick: () => onDownload(attribute),
63
+ disabled: checkIfLimitReached(attribute),
64
+ children: "Download"
65
+ }
66
+ )
67
+ ]
68
+ },
69
+ `${attribute.download_link}-${index}`
70
+ )) }),
71
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-textSecondary text-sm fw-regular p-2 bg-warning-light rounded-2 mt-4", children: [
72
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { className: "text-textSecondary", children: "Warning:" }),
73
+ " The download link is time-sensitive and will expire after a set period. You are limited to a specific number of download attempts, with each attempt reducing the remaining tries. To avoid any disruptions, please ensure a stable internet connection before proceeding with the download."
74
+ ] })
75
+ ] })
76
+ }
77
+ );
78
+ };
79
+ var digital_product_download_modal_default = DigitalProductDownloadModal;
80
+
81
+ exports.digital_product_download_modal_default = digital_product_download_modal_default;