layerpro 3.1.0 → 3.1.5
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/FUNDING.yml +12 -0
- package/README.md +44 -19
- package/index.cjs +338 -306
- package/index.js +336 -308
- package/markdown/GUIDE.md +367 -367
- package/package.json +35 -13
- package/react.cjs +18 -0
- package/react.js +18 -0
- package/types/layerpro.d.ts +132 -129
package/package.json
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "layerpro",
|
|
3
3
|
"codeName": "layerpro",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.5",
|
|
5
5
|
"description": "The real custom modals, alert, confirm, prompt... for your browser",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
|
-
"
|
|
7
|
+
"module": "./index.js",
|
|
8
|
+
"browser": "./dist/index.js",
|
|
8
9
|
"types": "./index.d.ts",
|
|
9
|
-
"
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./index.js",
|
|
13
|
+
"require": "./index.cjs",
|
|
14
|
+
"types": "./index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./react": {
|
|
17
|
+
"import": "./react.js",
|
|
18
|
+
"require": "./react.cjs",
|
|
19
|
+
"types": "./react.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./types/*": "./types/*"
|
|
22
|
+
},
|
|
10
23
|
"license": "MIT",
|
|
11
24
|
"copyright": "Dario Passariello",
|
|
12
25
|
"author": "Dario Passariello",
|
|
@@ -41,21 +54,30 @@
|
|
|
41
54
|
"node": ">=18.0.0"
|
|
42
55
|
},
|
|
43
56
|
"files": [
|
|
44
|
-
"
|
|
57
|
+
"markdown/**/*",
|
|
58
|
+
"types/**/*",
|
|
59
|
+
"COPYRIGHT.md",
|
|
60
|
+
"FUNDING.yml",
|
|
61
|
+
"index.cjs",
|
|
62
|
+
"index.css",
|
|
63
|
+
"index.d.ts",
|
|
64
|
+
"index.js",
|
|
65
|
+
"LICENSE.md",
|
|
66
|
+
"llms.txt",
|
|
67
|
+
"package.json",
|
|
68
|
+
"react.cjs",
|
|
69
|
+
"react.js",
|
|
70
|
+
"README.md",
|
|
71
|
+
"SECURITY.md"
|
|
45
72
|
],
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"react": ">=18",
|
|
75
|
+
"react-dom": ">=18"
|
|
76
|
+
},
|
|
46
77
|
"support": {
|
|
47
78
|
"name": "Dario Passariello",
|
|
48
79
|
"url": "https://dario.passariello.ca/",
|
|
49
80
|
"email": "dariopassariello@gmail.com"
|
|
50
81
|
},
|
|
51
|
-
"module": "./index.js",
|
|
52
|
-
"exports": {
|
|
53
|
-
".": {
|
|
54
|
-
"import": "./index.js",
|
|
55
|
-
"require": "./index.cjs",
|
|
56
|
-
"types": "./index.d.ts"
|
|
57
|
-
},
|
|
58
|
-
"./types/*": "./types/*"
|
|
59
|
-
},
|
|
60
82
|
"typings": "./index.d.ts"
|
|
61
83
|
}
|
package/react.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var e = require("react-dom/client"), o = (o, n, r) => {
|
|
4
|
+
const t = String(o.id);
|
|
5
|
+
try {
|
|
6
|
+
if (r) {
|
|
7
|
+
const e = r.get(t);
|
|
8
|
+
if (e) return void e.render(o.body);
|
|
9
|
+
}
|
|
10
|
+
const s = e.createRoot(n);
|
|
11
|
+
s.render(o.body), r && r.set(t, s);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
const o = e instanceof Error ? e.message : String(e);
|
|
14
|
+
o.includes("Invalid hook call") || o.includes("hooks") ? console.error("LayerPro Error: React hooks error detected. This usually happens when:\n1. Multiple copies of React are loaded on the page\n2. The component is called as a function instead of being passed as JSX\n3. React version mismatch between the app and LayerPro\n\nMake sure body is passed as <Component /> not <Component />()") : console.error("Error rendering React component:", e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
module.exports = o;
|
package/react.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createRoot as e } from "react-dom/client";
|
|
2
|
+
|
|
3
|
+
var o = (o, n, r) => {
|
|
4
|
+
const t = String(o.id);
|
|
5
|
+
try {
|
|
6
|
+
if (r) {
|
|
7
|
+
const e = r.get(t);
|
|
8
|
+
if (e) return void e.render(o.body);
|
|
9
|
+
}
|
|
10
|
+
const a = e(n);
|
|
11
|
+
a.render(o.body), r && r.set(t, a);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
const o = e instanceof Error ? e.message : String(e);
|
|
14
|
+
o.includes("Invalid hook call") || o.includes("hooks") ? console.error("LayerPro Error: React hooks error detected. This usually happens when:\n1. Multiple copies of React are loaded on the page\n2. The component is called as a function instead of being passed as JSX\n3. React version mismatch between the app and LayerPro\n\nMake sure body is passed as <Component /> not <Component />()") : console.error("Error rendering React component:", e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { o as default };
|
package/types/layerpro.d.ts
CHANGED
|
@@ -1,129 +1,132 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/** Generate custom
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
declare function
|
|
14
|
-
|
|
15
|
-
/** Generate custom
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
open: (props: GenLayerProps) => GenLayerProps
|
|
101
|
-
center: (id: string | number | GenLayerProps, offset?: number) => void
|
|
102
|
-
maximize: (props: GenLayerProps) => void
|
|
103
|
-
iconize: (id: string | number | GenLayerProps) => void
|
|
104
|
-
movable: (props: GenLayerProps) => void
|
|
105
|
-
resizable: (props: GenLayerProps) => void
|
|
106
|
-
store: (element: unknown) => void
|
|
107
|
-
index: (id: string | number | GenLayerProps) => void
|
|
108
|
-
zIndex: (props?: GenLayerProps) => number
|
|
109
|
-
close: (id: string | number | GenLayerProps) => void
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* LayerPro overrides the native alert/confirm/prompt globals and adds a
|
|
121
|
-
* `message` global. They are callback-based and do NOT return native values.
|
|
122
|
-
* Call `layerpro.noGlobals()` to restore the synchronous natives.
|
|
123
|
-
*/
|
|
124
|
-
interface Window {
|
|
125
|
-
layerpro: _layerpro
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
declare var layerpro: _layerpro
|
|
129
|
-
type layerpro = _layerpro
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
|
|
3
|
+
/** Generate custom alert using alert([text]) */
|
|
4
|
+
declare function alert(f1?: string): void
|
|
5
|
+
|
|
6
|
+
/** Generate custom confirm using confirm([text],[callback for YES],[optional callback for NO])
|
|
7
|
+
* WARNING: This overrides the native confirm(). The return value is NOT a usable
|
|
8
|
+
* boolean — callbacks are invoked asynchronously instead. Never rely on the
|
|
9
|
+
* return value; use the yes/no callbacks. */
|
|
10
|
+
declare function confirm(message: string, func1: (yes: boolean) => void, func2?: (no: boolean) => void): void
|
|
11
|
+
|
|
12
|
+
/** Generate custom message using message([text],[callback]) and option callback */
|
|
13
|
+
declare function message(f1?: string, func1?: () => void): void
|
|
14
|
+
|
|
15
|
+
/** Generate custom prompt using prompt([text],[callback]) and option callback
|
|
16
|
+
* WARNING: This overrides the native prompt(). The return value is NOT a usable
|
|
17
|
+
* string — use the callback to receive the input. */
|
|
18
|
+
declare function prompt(f1?: string, func1?: (input: string) => void): void
|
|
19
|
+
|
|
20
|
+
///
|
|
21
|
+
|
|
22
|
+
interface LayerButtonConfig {
|
|
23
|
+
text: string
|
|
24
|
+
cb?: () => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface LayerButtonsConfig {
|
|
28
|
+
confirm?: LayerButtonConfig
|
|
29
|
+
cancel?: LayerButtonConfig
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface GenLayerProps {
|
|
33
|
+
id: string | number
|
|
34
|
+
body?: React.ReactElement | string | HTMLElement
|
|
35
|
+
name?: string
|
|
36
|
+
style?: Record<string, string | number>
|
|
37
|
+
class?: string
|
|
38
|
+
icon?: string
|
|
39
|
+
|
|
40
|
+
buttons?: LayerButtonsConfig
|
|
41
|
+
|
|
42
|
+
top?: number | string
|
|
43
|
+
left?: number | string
|
|
44
|
+
right?: number | string
|
|
45
|
+
bottom?: number | string
|
|
46
|
+
|
|
47
|
+
width?: number | string
|
|
48
|
+
height?: number | string
|
|
49
|
+
|
|
50
|
+
minWidth?: number
|
|
51
|
+
minHeight?: number
|
|
52
|
+
maxWidth?: number
|
|
53
|
+
maxHeight?: number
|
|
54
|
+
|
|
55
|
+
fadeIn?: number
|
|
56
|
+
fadeOut?: number
|
|
57
|
+
timer?: number
|
|
58
|
+
|
|
59
|
+
maximize?: boolean
|
|
60
|
+
isMaximize?: boolean
|
|
61
|
+
dockable?: boolean
|
|
62
|
+
movable?: boolean
|
|
63
|
+
|
|
64
|
+
resizable?: boolean
|
|
65
|
+
close?: boolean
|
|
66
|
+
raised?: boolean
|
|
67
|
+
modal?: boolean
|
|
68
|
+
iconize?: boolean
|
|
69
|
+
center?: boolean
|
|
70
|
+
|
|
71
|
+
source?: string
|
|
72
|
+
store?: unknown
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Interface for the layerpro object
|
|
77
|
+
*/
|
|
78
|
+
interface _layerpro {
|
|
79
|
+
|
|
80
|
+
readonly alert: (txt: string) => void
|
|
81
|
+
readonly prompt: (txt: string, callback: (input: string) => void) => void
|
|
82
|
+
readonly message: (txt: string, callback: () => void) => void
|
|
83
|
+
readonly confirm: (txt: string, yesCallback: () => void, noCallback?: () => void) => void
|
|
84
|
+
readonly credits: (props: { name: string, version: string, description: string, license: string, author: { name: string, email: string } }) => void
|
|
85
|
+
|
|
86
|
+
setProps: (obj: Record<string, unknown>, options?: { enumerable?: boolean, writable?: boolean }) => void
|
|
87
|
+
|
|
88
|
+
/** Remove the global alert/confirm/prompt/message overrides and restore
|
|
89
|
+
* the native browser implementations. Call this right after importing
|
|
90
|
+
* LayerPro if your codebase depends on synchronous native globals. */
|
|
91
|
+
readonly noGlobals: () => void
|
|
92
|
+
|
|
93
|
+
/** Opt-in to override the browser's native alert/confirm/prompt/message
|
|
94
|
+
* globals with LayerPro's callback-based versions. This is opt-in so
|
|
95
|
+
* libraries embedded in other applications do not silently change
|
|
96
|
+
* global behavior. */
|
|
97
|
+
readonly installGlobals: () => void
|
|
98
|
+
|
|
99
|
+
readonly popup: {
|
|
100
|
+
open: (props: GenLayerProps) => GenLayerProps
|
|
101
|
+
center: (id: string | number | GenLayerProps, offset?: number) => void
|
|
102
|
+
maximize: (props: GenLayerProps) => void
|
|
103
|
+
iconize: (id: string | number | GenLayerProps) => void
|
|
104
|
+
movable: (props: GenLayerProps) => void
|
|
105
|
+
resizable: (props: GenLayerProps) => void
|
|
106
|
+
store: (element: unknown) => void
|
|
107
|
+
index: (id: string | number | GenLayerProps) => void
|
|
108
|
+
zIndex: (props?: GenLayerProps) => number
|
|
109
|
+
close: (id: string | number | GenLayerProps | null | undefined) => void
|
|
110
|
+
unmount: (id: string) => void
|
|
111
|
+
getReactRoots: () => Map<string, { unmount: () => void }> | null
|
|
112
|
+
cleanupEvents: (id: string) => void
|
|
113
|
+
abortSource: (id: string) => void
|
|
114
|
+
useReactAdapter?: (props: GenLayerProps, container: HTMLElement) => void
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* LayerPro overrides the native alert/confirm/prompt globals and adds a
|
|
121
|
+
* `message` global. They are callback-based and do NOT return native values.
|
|
122
|
+
* Call `layerpro.noGlobals()` to restore the synchronous natives.
|
|
123
|
+
*/
|
|
124
|
+
interface Window {
|
|
125
|
+
layerpro: _layerpro
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
declare var layerpro: _layerpro
|
|
129
|
+
type layerpro = _layerpro
|
|
130
|
+
|
|
131
|
+
declare var popup: layerpro
|
|
132
|
+
type popup = layerpro
|