@storepecker/storefront-core 2.4.0 → 2.4.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.
@@ -1,29 +1,69 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkBBRB475I_cjs = require('./chunk-BBRB475I.cjs');
4
- var Modal = require('react-responsive-modal');
5
- require('react-responsive-modal/styles.css');
4
+ var react = require('react');
5
+ var reactDom = require('react-dom');
6
+ var clsx = require('clsx');
6
7
  var jsxRuntime = require('react/jsx-runtime');
7
8
 
8
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
10
 
10
- var Modal__default = /*#__PURE__*/_interopDefault(Modal);
11
+ var clsx__default = /*#__PURE__*/_interopDefault(clsx);
11
12
 
13
+ function Modal({
14
+ open,
15
+ onClose,
16
+ className,
17
+ children
18
+ }) {
19
+ react.useEffect(() => {
20
+ if (!open) return;
21
+ const handleKey = (e) => {
22
+ if (e.key === "Escape") onClose();
23
+ };
24
+ document.addEventListener("keydown", handleKey);
25
+ const prevOverflow = document.body.style.overflow;
26
+ document.body.style.overflow = "hidden";
27
+ return () => {
28
+ document.removeEventListener("keydown", handleKey);
29
+ document.body.style.overflow = prevOverflow;
30
+ };
31
+ }, [open, onClose]);
32
+ if (!open || typeof document === "undefined") return null;
33
+ return reactDom.createPortal(
34
+ /* @__PURE__ */ jsxRuntime.jsx(
35
+ "div",
36
+ {
37
+ className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",
38
+ onClick: onClose,
39
+ role: "dialog",
40
+ "aria-modal": "true",
41
+ children: /* @__PURE__ */ jsxRuntime.jsx(
42
+ "div",
43
+ {
44
+ className: clsx__default.default(
45
+ "relative max-h-[90vh] w-full max-w-md overflow-y-auto rounded-lg bg-white shadow-xl",
46
+ className
47
+ ),
48
+ onClick: (e) => e.stopPropagation(),
49
+ children
50
+ }
51
+ )
52
+ }
53
+ ),
54
+ document.body
55
+ );
56
+ }
12
57
  var checkIfLimitReached = (attribute) => {
13
58
  return chunkBBRB475I_cjs.isExpired(attribute.expiry_date) || attribute.download_count === 0;
14
59
  };
15
60
  var DigitalProductDownloadModal = ({ open, onClose, product, downloadAttribute, onDownload, loading }) => {
16
61
  return /* @__PURE__ */ jsxRuntime.jsx(
17
- Modal__default.default,
62
+ Modal,
18
63
  {
19
- classNames: {
20
- modal: "modal modal-lg modal-confirm",
21
- closeButton: "modal-close"
22
- },
23
64
  open,
24
65
  onClose,
25
- center: true,
26
- closeIcon: null,
66
+ className: "modal modal-lg modal-confirm max-w-2xl",
27
67
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "modal-body px-4 py-2", children: [
28
68
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-2xl block mb-2 fw-regular", children: [
29
69
  "Download links for ",
@@ -1,8 +1,53 @@
1
1
  import { timeFromNow, isExpired } from './chunk-HSF2D56O.js';
2
- import Modal from 'react-responsive-modal';
3
- import 'react-responsive-modal/styles.css';
2
+ import { useEffect } from 'react';
3
+ import { createPortal } from 'react-dom';
4
+ import clsx from 'clsx';
4
5
  import { jsx, jsxs } from 'react/jsx-runtime';
5
6
 
7
+ function Modal({
8
+ open,
9
+ onClose,
10
+ className,
11
+ children
12
+ }) {
13
+ useEffect(() => {
14
+ if (!open) return;
15
+ const handleKey = (e) => {
16
+ if (e.key === "Escape") onClose();
17
+ };
18
+ document.addEventListener("keydown", handleKey);
19
+ const prevOverflow = document.body.style.overflow;
20
+ document.body.style.overflow = "hidden";
21
+ return () => {
22
+ document.removeEventListener("keydown", handleKey);
23
+ document.body.style.overflow = prevOverflow;
24
+ };
25
+ }, [open, onClose]);
26
+ if (!open || typeof document === "undefined") return null;
27
+ return createPortal(
28
+ /* @__PURE__ */ jsx(
29
+ "div",
30
+ {
31
+ className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",
32
+ onClick: onClose,
33
+ role: "dialog",
34
+ "aria-modal": "true",
35
+ children: /* @__PURE__ */ jsx(
36
+ "div",
37
+ {
38
+ className: clsx(
39
+ "relative max-h-[90vh] w-full max-w-md overflow-y-auto rounded-lg bg-white shadow-xl",
40
+ className
41
+ ),
42
+ onClick: (e) => e.stopPropagation(),
43
+ children
44
+ }
45
+ )
46
+ }
47
+ ),
48
+ document.body
49
+ );
50
+ }
6
51
  var checkIfLimitReached = (attribute) => {
7
52
  return isExpired(attribute.expiry_date) || attribute.download_count === 0;
8
53
  };
@@ -10,14 +55,9 @@ var DigitalProductDownloadModal = ({ open, onClose, product, downloadAttribute,
10
55
  return /* @__PURE__ */ jsx(
11
56
  Modal,
12
57
  {
13
- classNames: {
14
- modal: "modal modal-lg modal-confirm",
15
- closeButton: "modal-close"
16
- },
17
58
  open,
18
59
  onClose,
19
- center: true,
20
- closeIcon: null,
60
+ className: "modal modal-lg modal-confirm max-w-2xl",
21
61
  children: /* @__PURE__ */ jsxs("div", { className: "modal-body px-4 py-2", children: [
22
62
  /* @__PURE__ */ jsxs("span", { className: "text-2xl block mb-2 fw-regular", children: [
23
63
  "Download links for ",
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkVWQR3A7V_cjs = require('../chunk-VWQR3A7V.cjs');
3
+ var chunk6DXB4O6P_cjs = require('../chunk-6DXB4O6P.cjs');
4
4
  require('../chunk-BBRB475I.cjs');
5
5
 
6
6
 
7
7
 
8
- module.exports = chunkVWQR3A7V_cjs.digital_product_download_modal_default;
8
+ module.exports = chunk6DXB4O6P_cjs.digital_product_download_modal_default;
@@ -1,2 +1,2 @@
1
- export { digital_product_download_modal_default as default } from '../chunk-NA5GT4D3.js';
1
+ export { digital_product_download_modal_default as default } from '../chunk-LLRSKDH5.js';
2
2
  import '../chunk-HSF2D56O.js';
@@ -4,7 +4,7 @@ var chunkB3BXKMQA_cjs = require('../chunk-B3BXKMQA.cjs');
4
4
  var chunkV447PVRV_cjs = require('../chunk-V447PVRV.cjs');
5
5
  var chunkHAQWCNDY_cjs = require('../chunk-HAQWCNDY.cjs');
6
6
  var chunk3YRSHPM6_cjs = require('../chunk-3YRSHPM6.cjs');
7
- var chunkVWQR3A7V_cjs = require('../chunk-VWQR3A7V.cjs');
7
+ var chunk6DXB4O6P_cjs = require('../chunk-6DXB4O6P.cjs');
8
8
  var chunkLHF5BSWO_cjs = require('../chunk-LHF5BSWO.cjs');
9
9
  require('../chunk-BBRB475I.cjs');
10
10
  require('../chunk-KLNKIQQM.cjs');
@@ -38,7 +38,7 @@ Object.defineProperty(exports, "ShareIcon", {
38
38
  });
39
39
  Object.defineProperty(exports, "DigitalProductDownloadModal", {
40
40
  enumerable: true,
41
- get: function () { return chunkVWQR3A7V_cjs.digital_product_download_modal_default; }
41
+ get: function () { return chunk6DXB4O6P_cjs.digital_product_download_modal_default; }
42
42
  });
43
43
  Object.defineProperty(exports, "ThemeDataInitializer", {
44
44
  enumerable: true,
@@ -2,7 +2,7 @@ export { address_form_default as AddressForm } from '../chunk-L43KF3AC.js';
2
2
  export { search_dropdown_default as SearchDropdown } from '../chunk-YK4M3SFP.js';
3
3
  export { share_button_default as ShareButton } from '../chunk-EGFOTJPC.js';
4
4
  export { ShareIcon } from '../chunk-U7EXLQCT.js';
5
- export { digital_product_download_modal_default as DigitalProductDownloadModal } from '../chunk-NA5GT4D3.js';
5
+ export { digital_product_download_modal_default as DigitalProductDownloadModal } from '../chunk-LLRSKDH5.js';
6
6
  export { ThemeDataInitializer } from '../chunk-BTR3HLL4.js';
7
7
  import '../chunk-HSF2D56O.js';
8
8
  import '../chunk-6Q7QMPOQ.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storepecker/storefront-core",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Shared logic and utilities for Snapstore themes",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -149,7 +149,6 @@
149
149
  "libphonenumber-js": "^1.10.0",
150
150
  "react": "^18.0.0 || ^19.0.0",
151
151
  "react-dom": "^18.0.0 || ^19.0.0",
152
- "react-responsive-modal": "^6.0.0",
153
152
  "typescript-cookie": "^1.0.0",
154
153
  "yup": "^1.0.0",
155
154
  "zustand": "^5.0.0"
@@ -169,15 +168,13 @@
169
168
  },
170
169
  "jwt-decode": {
171
170
  "optional": true
172
- },
173
- "react-responsive-modal": {
174
- "optional": true
175
171
  }
176
172
  },
177
173
  "devDependencies": {
178
174
  "@testing-library/react": "^16.3.2",
179
175
  "@types/node": "^25.3.3",
180
176
  "@types/react": "^18.0.0",
177
+ "@types/react-dom": "^18.3.7",
181
178
  "axios": "^1.7.0",
182
179
  "clsx": "^2.1.1",
183
180
  "esbuild-css-modules-plugin": "^3.1.5",
@@ -189,7 +186,6 @@
189
186
  "react": "^18.3.1",
190
187
  "react-dom": "^18.3.1",
191
188
  "react-easy-crop": "^5.5.6",
192
- "react-responsive-modal": "^6.4.0",
193
189
  "react-toastify": "^11.0.5",
194
190
  "sass": "^1.97.3",
195
191
  "tsup": "^8.0.0",