@seamlessdocs/payment-modals 2.0.0-beta.2 → 2.0.0-beta.4
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.
- package/.babelrc +1 -1
- package/build/payment-modals.js +1 -1
- package/package.json +6 -7
- package/src/index.jsx +62 -4
- package/webpack.config.js +8 -14
- package/src/jsx-runtime-shim.js +0 -19
- package/src/react-with-polyfills.js +0 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seamlessdocs/payment-modals",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.4",
|
|
4
4
|
"description": "Payment modals for SeamlessDocs",
|
|
5
5
|
"main": "build/payment-modals.js",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"image-webpack-loader": "^6.0.0",
|
|
39
39
|
"mini-css-extract-plugin": "^2.7.6",
|
|
40
40
|
"prettier": "^1.17.0",
|
|
41
|
-
"react": "^
|
|
42
|
-
"react-dom": "^
|
|
41
|
+
"react": "^18.2.0",
|
|
42
|
+
"react-dom": "^18.2.0",
|
|
43
43
|
"sass": "^1.69.0",
|
|
44
44
|
"sass-loader": "^13.3.0",
|
|
45
45
|
"style-loader": "^3.3.3",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"webpack-dev-server": "^5.0.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"react": "^
|
|
54
|
-
"react-dom": "^
|
|
53
|
+
"react": "^18.0.0",
|
|
54
|
+
"react-dom": "^18.0.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@kofile/platform-react-payrix": "1.7.47",
|
|
@@ -65,7 +65,6 @@
|
|
|
65
65
|
"prop-types": "^15.7.2",
|
|
66
66
|
"react-inlinesvg": "^1.1.7",
|
|
67
67
|
"react-select": "^3.1.0",
|
|
68
|
-
"react-tippy": "^1.4.0"
|
|
69
|
-
"use-sync-external-store": "^1.2.0"
|
|
68
|
+
"react-tippy": "^1.4.0"
|
|
70
69
|
}
|
|
71
70
|
}
|
package/src/index.jsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Import createRoot - webpack will handle this correctly:
|
|
2
|
+
// - In development: bundled from react-dom/client
|
|
3
|
+
// - In production: external, resolved to ReactDOM global via webpack externals
|
|
4
|
+
import { createRoot as createRootFromModule } from 'react-dom/client';
|
|
3
5
|
|
|
4
6
|
import ChooseModal from './Components/ChooseModal';
|
|
5
7
|
import ProcessingModal from './Components/ProcessingModal';
|
|
@@ -17,14 +19,70 @@ import { restoreNativeEventConstructor, loadJQuery } from './shims';
|
|
|
17
19
|
import '../index.css';
|
|
18
20
|
import './OpenViewStyles.css';
|
|
19
21
|
|
|
20
|
-
//
|
|
22
|
+
// Store root instances to manage React 18 roots
|
|
23
|
+
const rootInstances = new Map();
|
|
24
|
+
|
|
25
|
+
// Helper function to get createRoot - handles both bundled (dev) and external (prod) scenarios
|
|
26
|
+
const getCreateRoot = () => {
|
|
27
|
+
// Strategy 1: Try the imported module (works in development when bundled)
|
|
28
|
+
if (createRootFromModule && typeof createRootFromModule === 'function') {
|
|
29
|
+
return createRootFromModule;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Strategy 2: Try to require react-dom/client directly (works in development)
|
|
33
|
+
try {
|
|
34
|
+
const reactDomClient = require('react-dom/client');
|
|
35
|
+
if (reactDomClient && reactDomClient.createRoot && typeof reactDomClient.createRoot === 'function') {
|
|
36
|
+
return reactDomClient.createRoot;
|
|
37
|
+
}
|
|
38
|
+
} catch (e) {
|
|
39
|
+
// Ignore require errors - module might not be available
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Strategy 3: Try to require react-dom and access createRoot (works in development)
|
|
43
|
+
try {
|
|
44
|
+
const ReactDOM = require('react-dom');
|
|
45
|
+
if (ReactDOM && typeof ReactDOM.createRoot === 'function') {
|
|
46
|
+
return ReactDOM.createRoot;
|
|
47
|
+
}
|
|
48
|
+
} catch (e) {
|
|
49
|
+
// Ignore require errors
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Strategy 4: Access ReactDOM from global scope (works in production with externals)
|
|
53
|
+
// Also works in development if React is loaded globally
|
|
54
|
+
const ReactDOM = (typeof window !== 'undefined' && window.ReactDOM)
|
|
55
|
+
|| (typeof global !== 'undefined' && global.ReactDOM)
|
|
56
|
+
|| (typeof self !== 'undefined' && self.ReactDOM);
|
|
57
|
+
|
|
58
|
+
if (ReactDOM && typeof ReactDOM.createRoot === 'function') {
|
|
59
|
+
return ReactDOM.createRoot;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
throw new Error(
|
|
63
|
+
'createRoot is not available. Make sure React 18 is loaded. ' +
|
|
64
|
+
'In development, react-dom should be bundled. ' +
|
|
65
|
+
'In production, ReactDOM should be available globally.'
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// Helper function to render with React 18 createRoot
|
|
21
70
|
const renderModal = (element, containerId) => {
|
|
22
71
|
const containerElement = document.getElementById(containerId);
|
|
23
72
|
if (!containerElement) {
|
|
24
73
|
console.warn(`Container element with id "${containerId}" not found`);
|
|
25
74
|
return;
|
|
26
75
|
}
|
|
27
|
-
|
|
76
|
+
|
|
77
|
+
// Get or create root instance
|
|
78
|
+
let root = rootInstances.get(containerId);
|
|
79
|
+
if (!root) {
|
|
80
|
+
const createRoot = getCreateRoot();
|
|
81
|
+
root = createRoot(containerElement);
|
|
82
|
+
rootInstances.set(containerId, root);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
root.render(element);
|
|
28
86
|
};
|
|
29
87
|
|
|
30
88
|
const handlePaymentModal = {};
|
package/webpack.config.js
CHANGED
|
@@ -34,6 +34,12 @@ module.exports = (_env, argv) => {
|
|
|
34
34
|
amd: 'react-dom',
|
|
35
35
|
root: 'ReactDOM'
|
|
36
36
|
},
|
|
37
|
+
'react-dom/client': {
|
|
38
|
+
commonjs: 'react-dom',
|
|
39
|
+
commonjs2: 'react-dom',
|
|
40
|
+
amd: 'react-dom',
|
|
41
|
+
root: 'ReactDOM'
|
|
42
|
+
}
|
|
37
43
|
} : {},
|
|
38
44
|
module: {
|
|
39
45
|
rules: [
|
|
@@ -95,18 +101,7 @@ module.exports = (_env, argv) => {
|
|
|
95
101
|
template: path.join(__dirname, 'index.html'),
|
|
96
102
|
inject: 'body',
|
|
97
103
|
scriptLoading: 'blocking'
|
|
98
|
-
})
|
|
99
|
-
// Replace 'react' imports from @kofile/platform-react-payrix with our polyfilled version
|
|
100
|
-
new webpack.NormalModuleReplacementPlugin(
|
|
101
|
-
/^react$/,
|
|
102
|
-
function(resource) {
|
|
103
|
-
const context = resource.context || '';
|
|
104
|
-
// Only replace for @kofile/platform-react-payrix
|
|
105
|
-
if (context.includes('@kofile') && context.includes('platform-react-payrix')) {
|
|
106
|
-
resource.request = path.resolve(__dirname, 'src/react-with-polyfills.js');
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
)
|
|
104
|
+
})
|
|
110
105
|
],
|
|
111
106
|
devServer: {
|
|
112
107
|
port: 9000,
|
|
@@ -126,8 +121,7 @@ module.exports = (_env, argv) => {
|
|
|
126
121
|
modules: [path.join(__dirname, 'src'), path.join(__dirname), 'node_modules'],
|
|
127
122
|
extensions: ['.js', '.jsx', '.scss', '.css'],
|
|
128
123
|
alias: {
|
|
129
|
-
'react-virtualized/List': 'react-virtualized/dist/es/List'
|
|
130
|
-
'react/jsx-runtime': path.resolve(__dirname, 'src/jsx-runtime-shim.js')
|
|
124
|
+
'react-virtualized/List': 'react-virtualized/dist/es/List'
|
|
131
125
|
}
|
|
132
126
|
}
|
|
133
127
|
};
|
package/src/jsx-runtime-shim.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Shim for react/jsx-runtime to support React 16
|
|
2
|
-
// This provides the jsx and jsxs functions that React 17+ uses
|
|
3
|
-
// but implemented using React.createElement for React 16 compatibility
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
// jsx function for single children
|
|
8
|
-
export function jsx(type, props, key) {
|
|
9
|
-
return React.createElement(type, { ...props, key });
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// jsxs function for multiple children
|
|
13
|
-
export function jsxs(type, props, key) {
|
|
14
|
-
return React.createElement(type, { ...props, key });
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Fragment support
|
|
18
|
-
export const Fragment = React.Fragment;
|
|
19
|
-
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// React wrapper that includes polyfills for React 16 compatibility
|
|
2
|
-
// This exports everything from React plus useSyncExternalStore polyfill
|
|
3
|
-
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
6
|
-
|
|
7
|
-
// Re-export everything from React
|
|
8
|
-
export * from 'react';
|
|
9
|
-
|
|
10
|
-
// Add useSyncExternalStore to the default export
|
|
11
|
-
export default {
|
|
12
|
-
...React,
|
|
13
|
-
useSyncExternalStore
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// Also export useSyncExternalStore as a named export
|
|
17
|
-
export { useSyncExternalStore };
|
|
18
|
-
|