layerpro 1.5.1 → 2.0.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.
- package/README.md +138 -160
- package/index.cjs +537 -0
- package/index.d.ts +1 -6
- package/index.global.js +545 -0
- package/index.js +537 -1
- package/package.json +20 -37
- package/types/files.d.ts +42 -0
- package/types/jquery.d.ts +1 -6
- package/types/layerpro.d.ts +22 -19
package/README.md
CHANGED
|
@@ -1,206 +1,184 @@
|
|
|
1
|
-
#
|
|
1
|
+
# LayerPro 🚀
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Drop-in replacement for browser modals with superpowers.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
[](https://npmjs.org/package/layerpro)
|
|
5
|
+
---
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## What is LayerPro?
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
LayerPro replaces the boring browser `alert()`, `confirm()`, and `prompt()` with beautiful, customizable modals that work everywhere.
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
No more ugly popup boxes. No more blocking the main thread. Just clean, modern modals that your users will love.
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
---
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
## Features
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
- **Multiple modal types**: alert, confirm, prompt, message
|
|
18
|
+
- **Fully customizable**: appearance, behavior, animations
|
|
19
|
+
- **Dockable windows**: minimize modals to a dock bar
|
|
20
|
+
- **Draggable & Resizable**: users can move and resize
|
|
21
|
+
- **Smooth animations**: fade in/out transitions
|
|
22
|
+
- **XSS protection**: built-in HTML sanitization
|
|
23
|
+
- **TypeScript support**: full type definitions
|
|
19
24
|
|
|
20
25
|
---
|
|
21
26
|
|
|
22
|
-
##
|
|
27
|
+
## Installation
|
|
23
28
|
|
|
24
|
-
```
|
|
25
|
-
npm
|
|
29
|
+
```bash
|
|
30
|
+
npm install layerpro
|
|
26
31
|
```
|
|
27
32
|
|
|
28
|
-
|
|
33
|
+
Or use directly in HTML:
|
|
29
34
|
|
|
30
|
-
```
|
|
31
|
-
npm
|
|
35
|
+
```html
|
|
36
|
+
<script src="https://cdn.jsdelivr.net/npm/layerpro"></script>
|
|
32
37
|
```
|
|
33
38
|
|
|
34
|
-
|
|
39
|
+
---
|
|
35
40
|
|
|
36
|
-
|
|
37
|
-
import "layerpro";
|
|
38
|
-
```
|
|
41
|
+
## Quick Start
|
|
39
42
|
|
|
40
|
-
|
|
43
|
+
Import LayerPro once in your app entry point:
|
|
41
44
|
|
|
42
|
-
```
|
|
43
|
-
|
|
45
|
+
```javascript
|
|
46
|
+
import "layerpro";
|
|
44
47
|
```
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
```html
|
|
49
|
-
<script src="https://cdn.jsdelivr.net/npm/layerpro"></script>
|
|
50
|
-
```
|
|
49
|
+
That's it. Now you have `alert()`, `confirm()`, `prompt()`, and `message()` globally.
|
|
51
50
|
|
|
52
51
|
---
|
|
53
52
|
|
|
54
|
-
##
|
|
53
|
+
## Usage
|
|
55
54
|
|
|
56
|
-
|
|
55
|
+
### Basic Modals
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
```javascript
|
|
58
|
+
alert("Hello World!");
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
confirm("Are you sure?", () => {
|
|
61
|
+
console.log("User clicked YES");
|
|
62
|
+
});
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
prompt("What's your name?", (name) => {
|
|
65
|
+
console.log("User entered:", name);
|
|
66
|
+
});
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
confirm(
|
|
68
|
-
"Hello world",
|
|
69
|
-
()=>console.log("hello"), // callback for YES / OK
|
|
70
|
-
()=>console.log("bye") // callback for NO / CANCEL (you can use null if you don't want CB)
|
|
71
|
-
);
|
|
68
|
+
message("Operation complete!");
|
|
69
|
+
```
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
### Custom Popups
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
layerpro.popup.open({
|
|
75
|
+
id: 'myModal',
|
|
76
|
+
name: 'My Modal',
|
|
77
|
+
body: '<p>Your content here</p>',
|
|
78
|
+
width: 450,
|
|
79
|
+
height: 350,
|
|
80
|
+
buttons: {
|
|
81
|
+
confirm: { text: "OK", cb: () => {} },
|
|
82
|
+
cancel: { text: "Cancel", cb: () => {} }
|
|
83
|
+
}
|
|
84
|
+
});
|
|
77
85
|
```
|
|
78
86
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
```js
|
|
82
|
-
import 'layerpro'
|
|
83
|
-
|
|
84
|
-
// EXAMPLE WITH ALL OPTIONS
|
|
85
|
-
function App() {
|
|
86
|
-
|
|
87
|
-
layerpro.popup.open(
|
|
88
|
-
{
|
|
89
|
-
id: 'exampleModal',
|
|
90
|
-
body: 'Example',
|
|
91
|
-
name: 'example',
|
|
92
|
-
icon: '⚠',
|
|
93
|
-
|
|
94
|
-
buttons: {
|
|
95
|
-
confirm: {
|
|
96
|
-
text: "accept",
|
|
97
|
-
cb: (e) => message("confirmed")
|
|
98
|
-
},
|
|
99
|
-
cancel: {
|
|
100
|
-
text: "cancel"
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
width: 400,
|
|
105
|
-
height: 300,
|
|
106
|
-
maxWidth: 500,
|
|
107
|
-
maxHeight: 350,
|
|
108
|
-
minWidth: 200,
|
|
109
|
-
minHeight: 150,
|
|
110
|
-
top: '10%',
|
|
111
|
-
left: '10%',
|
|
112
|
-
right: 'auto',
|
|
113
|
-
bottom: 'auto',
|
|
114
|
-
|
|
115
|
-
fadeIn: 500,
|
|
116
|
-
fadeOut: 500,
|
|
117
|
-
timer: 0,
|
|
118
|
-
|
|
119
|
-
iconize: true,
|
|
120
|
-
maximize: true,
|
|
121
|
-
close: true,
|
|
122
|
-
isMaximize: false,
|
|
123
|
-
dockable: false,
|
|
124
|
-
raised: true,
|
|
125
|
-
movable: true,
|
|
126
|
-
resizable: false,
|
|
127
|
-
store: false
|
|
128
|
-
}
|
|
129
|
-
)
|
|
130
|
-
}
|
|
87
|
+
### React Components
|
|
131
88
|
|
|
132
|
-
|
|
89
|
+
In a React environment, you can pass React components directly:
|
|
133
90
|
|
|
91
|
+
```jsx
|
|
92
|
+
layerpro.popup.open({
|
|
93
|
+
id: 'reactModal',
|
|
94
|
+
name: 'React Modal',
|
|
95
|
+
body: <MyComponent />, // React element
|
|
96
|
+
width: 500,
|
|
97
|
+
height: 400
|
|
98
|
+
});
|
|
134
99
|
```
|
|
135
100
|
|
|
136
|
-
|
|
101
|
+
### The `body` Parameter
|
|
137
102
|
|
|
138
|
-
|
|
103
|
+
The `body` property accepts different content types:
|
|
139
104
|
|
|
140
|
-
|
|
105
|
+
| Type | Example |
|
|
106
|
+
|------|---------|
|
|
107
|
+
| Plain text | `body: "Hello"` |
|
|
108
|
+
| HTML string | `body: "<p>Hello</p>"` |
|
|
109
|
+
| React element | `body: <Component />` |
|
|
141
110
|
|
|
142
|
-
|
|
143
|
-
import 'layerpro'
|
|
111
|
+
> **Note**: In React, always use elements (`<Component />`), not function calls (`Component()`).
|
|
144
112
|
|
|
145
|
-
|
|
113
|
+
---
|
|
146
114
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
115
|
+
## Options
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
{
|
|
119
|
+
id: string, // Unique ID
|
|
120
|
+
body: any, // Content (text, HTML, or React)
|
|
121
|
+
name: string, // Modal title
|
|
122
|
+
icon: string, // Icon (HTML entity)
|
|
123
|
+
|
|
124
|
+
// Dimensions
|
|
125
|
+
width: number,
|
|
126
|
+
height: number,
|
|
127
|
+
minWidth: number,
|
|
128
|
+
minHeight: number,
|
|
129
|
+
maxWidth: number,
|
|
130
|
+
maxHeight: number,
|
|
131
|
+
|
|
132
|
+
// Position
|
|
133
|
+
top: number | string,
|
|
134
|
+
left: number | string,
|
|
135
|
+
right: number | string,
|
|
136
|
+
bottom: number | string,
|
|
137
|
+
|
|
138
|
+
// Animation
|
|
139
|
+
fadeIn: number,
|
|
140
|
+
fadeOut: number,
|
|
141
|
+
timer: number,
|
|
142
|
+
|
|
143
|
+
// Features
|
|
144
|
+
movable: boolean,
|
|
145
|
+
resizable: boolean,
|
|
146
|
+
maximize: boolean,
|
|
147
|
+
iconize: boolean,
|
|
148
|
+
dockable: boolean,
|
|
149
|
+
close: boolean,
|
|
150
|
+
raised: boolean,
|
|
151
|
+
|
|
152
|
+
// Buttons
|
|
153
|
+
buttons: {
|
|
154
|
+
confirm?: { text: string; cb?: () => void },
|
|
155
|
+
cancel?: { text: string; cb?: () => void }
|
|
157
156
|
}
|
|
158
|
-
|
|
159
|
-
// Run into layerpro
|
|
160
|
-
layerpro.popup.open(
|
|
161
|
-
{
|
|
162
|
-
id: 'exampleModal',
|
|
163
|
-
body: TestApp(),
|
|
164
|
-
buttons: {
|
|
165
|
-
confirm: {
|
|
166
|
-
text: "accept",
|
|
167
|
-
cb: () => {
|
|
168
|
-
message("confirmed")
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
cancel: {
|
|
172
|
-
text: "cancel",
|
|
173
|
-
cb: () => {
|
|
174
|
-
alert("cancelled")
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
width: 350,
|
|
179
|
-
height: 300,
|
|
180
|
-
name: 'example',
|
|
181
|
-
icon: '⚠',
|
|
182
|
-
iconize: true,
|
|
183
|
-
maximize: true,
|
|
184
|
-
close: true,
|
|
185
|
-
isMaximize: false,
|
|
186
|
-
dockable: false,
|
|
187
|
-
raised: true,
|
|
188
|
-
movable: true,
|
|
189
|
-
resizable: false,
|
|
190
|
-
store: false,
|
|
191
|
-
top: '10%',
|
|
192
|
-
left: '10%',
|
|
193
|
-
right: 'auto',
|
|
194
|
-
bottom: 'auto',
|
|
195
|
-
minWidth: 200,
|
|
196
|
-
minHeight: 150,
|
|
197
|
-
fadeIn: 500,
|
|
198
|
-
fadeOut: 500,
|
|
199
|
-
timer: 0
|
|
200
|
-
}
|
|
201
|
-
)
|
|
202
|
-
|
|
203
157
|
}
|
|
204
158
|
```
|
|
205
159
|
|
|
206
|
-
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Methods
|
|
163
|
+
|
|
164
|
+
| Method | Description |
|
|
165
|
+
|--------|-------------|
|
|
166
|
+
| `layerpro.popup.open(props)` | Open a modal |
|
|
167
|
+
| `layerpro.popup.close(id)` | Close a modal |
|
|
168
|
+
| `layerpro.popup.center(id)` | Center modal |
|
|
169
|
+
| `layerpro.popup.maximize(id)` | Maximize modal |
|
|
170
|
+
| `layerpro.popup.iconize(id)` | Minimize to dock |
|
|
171
|
+
| `layerpro.popup.movable(id)` | Enable drag |
|
|
172
|
+
| `layerpro.popup.resizable(id)` | Enable resize |
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Browser Support
|
|
177
|
+
|
|
178
|
+
Chrome 80+ • Firefox 75+ • Safari 13+ • Edge 80+
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
MIT
|