codenotch-react 1.0.36 → 1.0.37
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/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -0
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -22,8 +22,25 @@ export interface ICodenotchApi {
|
|
|
22
22
|
dispose: () => void;
|
|
23
23
|
};
|
|
24
24
|
i18n: (key: string, ...args: any[]) => string;
|
|
25
|
+
showDialog: (node: React.DOMElement<React.DOMAttributes<Element>, Element>) => ICodenotchDialog;
|
|
26
|
+
}
|
|
27
|
+
export interface ICodenotchDialog {
|
|
28
|
+
id: string;
|
|
29
|
+
close: () => void;
|
|
25
30
|
}
|
|
26
31
|
declare const CODENOTCH_ENV: ICodenotchEnv;
|
|
32
|
+
/**
|
|
33
|
+
* Parse URL parameters and return them as an object
|
|
34
|
+
* @returns {Object} An object containing the URL parameters as key-value pairs
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseUrlParams(): {
|
|
37
|
+
[key: string]: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Setup Codenotch environment from the given object
|
|
41
|
+
* @param env An object containing the Codenotch environment variables as key-value pairs. This can be obtained from URL parameters or any other source.
|
|
42
|
+
* @returns {void}
|
|
43
|
+
*/
|
|
27
44
|
export declare function setupCodenotchEnv(env: any): void;
|
|
28
45
|
/**
|
|
29
46
|
* Return Codenotch API
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,C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AiB,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CA4ChD;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,aAAa,CA2I5C;AAGD,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.CODENOTCH_ENV = void 0;
|
|
7
|
+
exports.parseUrlParams = parseUrlParams;
|
|
4
8
|
exports.setupCodenotchEnv = setupCodenotchEnv;
|
|
5
9
|
exports.useCodenotch = useCodenotch;
|
|
10
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
|
6
11
|
const CODENOTCH_ENV = {};
|
|
7
12
|
exports.CODENOTCH_ENV = CODENOTCH_ENV;
|
|
13
|
+
/**
|
|
14
|
+
* Parse URL parameters and return them as an object
|
|
15
|
+
* @returns {Object} An object containing the URL parameters as key-value pairs
|
|
16
|
+
*/
|
|
17
|
+
function parseUrlParams() {
|
|
18
|
+
let result = {};
|
|
19
|
+
if (typeof window !== 'undefined') {
|
|
20
|
+
const params = new URL(window.location.href).searchParams;
|
|
21
|
+
params.forEach((value, key) => {
|
|
22
|
+
if (result[key] === undefined) {
|
|
23
|
+
result[key] = value;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Setup Codenotch environment from the given object
|
|
31
|
+
* @param env An object containing the Codenotch environment variables as key-value pairs. This can be obtained from URL parameters or any other source.
|
|
32
|
+
* @returns {void}
|
|
33
|
+
*/
|
|
8
34
|
function setupCodenotchEnv(env) {
|
|
9
35
|
if (env === undefined || env === null) {
|
|
10
36
|
console.warn("Codenotch environment is not defined. Please set it in the Codenotch configuration.");
|
|
@@ -131,6 +157,41 @@ function useCodenotch() {
|
|
|
131
157
|
console.log(`Stopped listening to signal ${signalId}`);
|
|
132
158
|
}
|
|
133
159
|
};
|
|
160
|
+
},
|
|
161
|
+
showDialog: (node) => {
|
|
162
|
+
let dialogId = "codenotch-dialog-" + Math.random().toString(36).substring(2, 9);
|
|
163
|
+
let result = {
|
|
164
|
+
id: dialogId,
|
|
165
|
+
close: () => {
|
|
166
|
+
let dialogElement = document.getElementById(dialogId);
|
|
167
|
+
if (dialogElement) {
|
|
168
|
+
dialogElement.remove();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
// Find "cn-dialog-container" element in the page
|
|
173
|
+
let container = document.getElementById("cn-dialog-container");
|
|
174
|
+
if (container === null) {
|
|
175
|
+
container = document.createElement("div");
|
|
176
|
+
container.id = "cn-dialog-container";
|
|
177
|
+
container.style.zIndex = "9999";
|
|
178
|
+
container.style.position = "fixed";
|
|
179
|
+
container.style.top = "0";
|
|
180
|
+
container.style.left = "0";
|
|
181
|
+
container.style.minWidth = "100vw";
|
|
182
|
+
container.style.minHeight = "100vh";
|
|
183
|
+
container.style.maxWidth = "100vw";
|
|
184
|
+
container.style.maxHeight = "100vh";
|
|
185
|
+
container.style.display = "flex";
|
|
186
|
+
container.style.alignItems = "center";
|
|
187
|
+
container.style.justifyContent = "center";
|
|
188
|
+
document.body.appendChild(container);
|
|
189
|
+
}
|
|
190
|
+
let dialogElement = document.createElement('dialog');
|
|
191
|
+
dialogElement.id = dialogId;
|
|
192
|
+
container.appendChild(dialogElement);
|
|
193
|
+
react_dom_1.default.render(node, dialogElement);
|
|
194
|
+
return result;
|
|
134
195
|
}
|
|
135
196
|
};
|
|
136
197
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codenotch-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.37",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"author": "Codenotch SA",
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/node": "^25.3.2",
|
|
21
21
|
"@types/react": "^16.14.69",
|
|
22
|
+
"@types/react-dom": "^16.9.25",
|
|
23
|
+
"react-dom": "^16.14.0",
|
|
22
24
|
"typescript": "^5.9.3"
|
|
23
25
|
},
|
|
24
26
|
"peerDependencies": {
|