layerpro 1.5.1 → 2.0.0
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 +241 -151
- 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,49 +1,67 @@
|
|
|
1
|
-
#
|
|
1
|
+
# LayerPro 🚀
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<div align="center">
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
[](https://npmjs.org/package/layerpro)
|
|
5
|
+

|
|
7
6
|
|
|
8
|
-
[](https://npmjs.com/package/layerpro)
|
|
8
|
+
[](https://npmjs.com/package/layerpro)
|
|
9
|
+
[](https://github.com/passariello/layerpro/blob/main/LICENSE)
|
|
10
|
+
[](https://www.typescriptlang.org/)
|
|
11
|
+
<!-- [](https://github.com/passariello/layerpro/actions) -->
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
<!-- [](https://a51.gitbook.io/layerpro) -->
|
|
14
|
+
[](https://www.patreon.com/passariello)
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
</div>
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## What is LayerPro?
|
|
15
21
|
|
|
16
|
-
|
|
22
|
+
LayerPro is a powerful, lightweight modal and dialog library for modern web applications. It provides a seamless way to create custom alerts, confirmations, prompts, and messages that completely replace the default browser modals.
|
|
17
23
|
|
|
18
|
-
|
|
24
|
+
Built with TypeScript and designed to work with any frontend framework (React, Vue, Vanilla JS, or plain HTML), LayerPro brings a premium user experience to your web interactions.
|
|
19
25
|
|
|
20
26
|
---
|
|
21
27
|
|
|
22
|
-
##
|
|
28
|
+
## ✨ Features
|
|
29
|
+
|
|
30
|
+
| Feature | Description |
|
|
31
|
+
|---------|-------------|
|
|
32
|
+
| **🪟 Multiple Modal Types** | Alert, Confirm, Prompt, Message - all customizable |
|
|
33
|
+
| **🎨 Fully Customizable** | Control appearance, behavior, animations |
|
|
34
|
+
| **📍 Dockable Windows** | Minimize modals to a dock bar |
|
|
35
|
+
| **🖱️ Draggable & Resizable** | Users can move and resize modals |
|
|
36
|
+
| **⚡ Smooth Animations** | Built-in fade in/out transitions |
|
|
37
|
+
| **🔒 Security First** | XSS protection with HTML sanitization |
|
|
38
|
+
| **🧠 Memory Safe** | Proper cleanup of React roots and event listeners |
|
|
39
|
+
| **🌐 Universal** | Works with React, Vue, Angular, Vanilla JS |
|
|
40
|
+
| **📱 Responsive** | Adapts to any screen size |
|
|
41
|
+
| **🎯 TypeScript** | Full type definitions included |
|
|
23
42
|
|
|
24
|
-
|
|
25
|
-
npm i layerpro --save-dev
|
|
26
|
-
```
|
|
43
|
+
---
|
|
27
44
|
|
|
28
|
-
|
|
45
|
+
## 📦 Installation
|
|
29
46
|
|
|
30
|
-
|
|
31
|
-
|
|
47
|
+
### For React / Vue / Webpack Projects
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install layerpro --save-dev
|
|
51
|
+
# or
|
|
52
|
+
npm install layerpro@latest --save-dev
|
|
32
53
|
```
|
|
33
54
|
|
|
34
|
-
|
|
55
|
+
Then import in your entry file:
|
|
35
56
|
|
|
36
|
-
```
|
|
57
|
+
```javascript
|
|
58
|
+
// index.js or index.ts
|
|
37
59
|
import "layerpro";
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
or
|
|
41
60
|
|
|
42
|
-
|
|
43
|
-
require("layerpro");
|
|
61
|
+
// That's it! Now you can use alert(), confirm(), prompt(), message() globally
|
|
44
62
|
```
|
|
45
63
|
|
|
46
|
-
|
|
64
|
+
### For Plain HTML / EJS Projects
|
|
47
65
|
|
|
48
66
|
```html
|
|
49
67
|
<script src="https://cdn.jsdelivr.net/npm/layerpro"></script>
|
|
@@ -51,156 +69,228 @@ require("layerpro");
|
|
|
51
69
|
|
|
52
70
|
---
|
|
53
71
|
|
|
54
|
-
##
|
|
72
|
+
## 🚀 Quick Start
|
|
55
73
|
|
|
56
|
-
|
|
74
|
+
### Basic Usage
|
|
57
75
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
```js
|
|
63
|
-
alert("Hello world"); // Normal alert
|
|
64
|
-
|
|
65
|
-
prompt("Your Name"); // Ask for input
|
|
76
|
+
```javascript
|
|
77
|
+
// Simple alert
|
|
78
|
+
alert("Hello, World!");
|
|
66
79
|
|
|
80
|
+
// Confirmation dialog with callbacks
|
|
67
81
|
confirm(
|
|
68
|
-
"
|
|
69
|
-
()=>console.log("
|
|
70
|
-
()=>console.log("
|
|
82
|
+
"Are you sure?",
|
|
83
|
+
() => console.log("User clicked YES"),
|
|
84
|
+
() => console.log("User clicked NO")
|
|
71
85
|
);
|
|
72
86
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
);
|
|
77
|
-
```
|
|
87
|
+
// Input prompt
|
|
88
|
+
prompt("What's your name?", (value) => {
|
|
89
|
+
console.log("User entered:", value);
|
|
90
|
+
});
|
|
78
91
|
|
|
79
|
-
|
|
92
|
+
// Notification message
|
|
93
|
+
message("Operation completed successfully!");
|
|
94
|
+
```
|
|
80
95
|
|
|
81
|
-
|
|
82
|
-
|
|
96
|
+
### Advanced Popup
|
|
97
|
+
|
|
98
|
+
```javascript
|
|
99
|
+
layerpro.popup.open({
|
|
100
|
+
id: 'myModal',
|
|
101
|
+
name: 'My Custom Modal',
|
|
102
|
+
body: '<p>Your custom HTML content here</p>',
|
|
103
|
+
icon: '⚠', // Warning icon HTML entity
|
|
104
|
+
|
|
105
|
+
// Dimensions
|
|
106
|
+
width: 450,
|
|
107
|
+
height: 350,
|
|
108
|
+
minWidth: 300,
|
|
109
|
+
minHeight: 200,
|
|
110
|
+
|
|
111
|
+
// Position
|
|
112
|
+
top: '20%',
|
|
113
|
+
left: '50%',
|
|
114
|
+
|
|
115
|
+
// Features
|
|
116
|
+
movable: true,
|
|
117
|
+
resizable: true,
|
|
118
|
+
maximize: true,
|
|
119
|
+
iconize: true,
|
|
120
|
+
dockable: true,
|
|
121
|
+
close: true,
|
|
122
|
+
|
|
123
|
+
// Animation
|
|
124
|
+
fadeIn: 300,
|
|
125
|
+
fadeOut: 300,
|
|
126
|
+
|
|
127
|
+
// Custom buttons
|
|
128
|
+
buttons: {
|
|
129
|
+
confirm: {
|
|
130
|
+
text: "Accept",
|
|
131
|
+
cb: () => handleAccept()
|
|
132
|
+
},
|
|
133
|
+
cancel: {
|
|
134
|
+
text: "Cancel",
|
|
135
|
+
cb: () => handleCancel()
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
```
|
|
83
140
|
|
|
84
|
-
|
|
85
|
-
function App() {
|
|
141
|
+
### React Integration
|
|
86
142
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
body: 'Example',
|
|
91
|
-
name: 'example',
|
|
92
|
-
icon: '⚠',
|
|
143
|
+
```jsx
|
|
144
|
+
import 'layerpro';
|
|
145
|
+
import React from 'react';
|
|
93
146
|
|
|
147
|
+
function App() {
|
|
148
|
+
const handleClick = () => {
|
|
149
|
+
layerpro.popup.open({
|
|
150
|
+
id: 'react-modal',
|
|
151
|
+
name: 'React Modal',
|
|
152
|
+
body: <MyReactComponent />,
|
|
153
|
+
width: 500,
|
|
154
|
+
height: 400,
|
|
94
155
|
buttons: {
|
|
95
156
|
confirm: {
|
|
96
|
-
text: "
|
|
97
|
-
cb: (
|
|
98
|
-
},
|
|
99
|
-
cancel: {
|
|
100
|
-
text: "cancel"
|
|
157
|
+
text: "Save",
|
|
158
|
+
cb: () => console.log("Saved!")
|
|
101
159
|
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
}
|
|
131
|
-
|
|
132
|
-
export default App
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
};
|
|
133
163
|
|
|
164
|
+
return (
|
|
165
|
+
<button onClick={handleClick}>Open Modal</button>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
134
168
|
```
|
|
135
169
|
|
|
136
|
-
|
|
170
|
+
---
|
|
137
171
|
|
|
138
|
-
|
|
172
|
+
## 🎯 API Reference
|
|
139
173
|
|
|
140
|
-
|
|
174
|
+
### Global Functions
|
|
141
175
|
|
|
142
|
-
|
|
143
|
-
|
|
176
|
+
| Function | Description |
|
|
177
|
+
|----------|-------------|
|
|
178
|
+
| `alert(text)` | Display a simple alert dialog |
|
|
179
|
+
| `confirm(text, yesCallback, noCallback)` | Display confirmation with callbacks |
|
|
180
|
+
| `prompt(text, callback)` | Display input prompt with callback |
|
|
181
|
+
| `message(text, callback)` | Display notification message |
|
|
144
182
|
|
|
145
|
-
|
|
183
|
+
### Popup Methods
|
|
146
184
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
185
|
+
| Method | Description |
|
|
186
|
+
|--------|-------------|
|
|
187
|
+
| `layerpro.popup.open(props)` | Open a new modal |
|
|
188
|
+
| `layerpro.popup.close(id)` | Close a modal |
|
|
189
|
+
| `layerpro.popup.center(id)` | Center modal on screen |
|
|
190
|
+
| `layerpro.popup.maximize(id)` | Maximize modal |
|
|
191
|
+
| `layerpro.popup.iconize(id)` | Minimize to dock |
|
|
192
|
+
| `layerpro.popup.movable(id)` | Enable drag functionality |
|
|
193
|
+
| `layerpro.popup.resizable(id)` | Enable resize functionality |
|
|
194
|
+
| `layerpro.popup.dockable(id)` | Enable dock functionality |
|
|
195
|
+
| `layerpro.popup.zIndex()` | Get next z-index value |
|
|
158
196
|
|
|
159
|
-
|
|
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
|
-
)
|
|
197
|
+
---
|
|
202
198
|
|
|
199
|
+
## ⚙️ Configuration Options
|
|
200
|
+
|
|
201
|
+
**Note on `body` parameter:**
|
|
202
|
+
The `body` property supports multiple content types:
|
|
203
|
+
- **Plain text**: `body: "Hello World"`
|
|
204
|
+
- **HTML string**: `body: "<p>Your HTML here</p>"`
|
|
205
|
+
- **React element** (React environment): `body: <MyComponent />`
|
|
206
|
+
|
|
207
|
+
> ⚠️ **Important**: When using React, always pass components as elements (`<MyComponent />`), not as function calls (`MyComponent()`). Passing a function will show an error message.
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
interface GenLayerProps {
|
|
211
|
+
id: string; // Unique identifier
|
|
212
|
+
body?: any; // Modal content (HTML string or React component)
|
|
213
|
+
name?: string; // Modal title
|
|
214
|
+
icon?: string; // Icon HTML entity
|
|
215
|
+
|
|
216
|
+
// Dimensions
|
|
217
|
+
width?: number | string; // Width in px or %
|
|
218
|
+
height?: number | string; // Height in px or %
|
|
219
|
+
minWidth?: number; // Minimum width
|
|
220
|
+
minHeight?: number; // Minimum height
|
|
221
|
+
maxWidth?: number; // Maximum width
|
|
222
|
+
maxHeight?: number; // Maximum height
|
|
223
|
+
|
|
224
|
+
// Position
|
|
225
|
+
top?: number | string; // Top position
|
|
226
|
+
left?: number | string; // Left position
|
|
227
|
+
right?: number | string; // Right position
|
|
228
|
+
bottom?: number | string; // Bottom position
|
|
229
|
+
|
|
230
|
+
// Animation
|
|
231
|
+
fadeIn?: number; // Fade in duration (ms)
|
|
232
|
+
fadeOut?: number; // Fade out duration (ms)
|
|
233
|
+
timer?: number; // Auto-close timer
|
|
234
|
+
|
|
235
|
+
// Features
|
|
236
|
+
maximize?: boolean; // Show maximize button
|
|
237
|
+
isMaximize?: boolean; // Start maximized
|
|
238
|
+
dockable?: boolean; // Enable dock feature
|
|
239
|
+
movable?: boolean; // Enable drag
|
|
240
|
+
resizable?: boolean; // Enable resize
|
|
241
|
+
close?: boolean; // Show close button
|
|
242
|
+
raised?: boolean; // Show raised overlay
|
|
243
|
+
iconize?: boolean; // Show minimize button
|
|
244
|
+
|
|
245
|
+
// Behavior
|
|
246
|
+
source?: string; // Content source URL
|
|
247
|
+
store?: boolean; // Store state
|
|
248
|
+
|
|
249
|
+
// Custom Buttons
|
|
250
|
+
buttons?: {
|
|
251
|
+
confirm?: { text: string; cb?: () => void };
|
|
252
|
+
cancel?: { text: string; cb?: () => void };
|
|
253
|
+
};
|
|
203
254
|
}
|
|
204
255
|
```
|
|
205
256
|
|
|
206
|
-
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## 🌍 Browser Support
|
|
260
|
+
|
|
261
|
+
| Browser | Version |
|
|
262
|
+
|---------|---------|
|
|
263
|
+
| Chrome | 80+ |
|
|
264
|
+
| Firefox | 75+ |
|
|
265
|
+
| Safari | 13+ |
|
|
266
|
+
| Edge | 80+ |
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## 📄 License
|
|
271
|
+
|
|
272
|
+
MIT License - see [LICENSE.md](LICENSE.md) for details.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## 👤 Author
|
|
277
|
+
|
|
278
|
+
**Dario Passariello**
|
|
279
|
+
|
|
280
|
+
- GitHub: [@passariello](https://github.com/passariello)
|
|
281
|
+
- Email: dariopassariello@gmail.com
|
|
282
|
+
- Website: https://dario.passariello.ca
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## 🤝 Contributing
|
|
287
|
+
|
|
288
|
+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
<div align="center">
|
|
293
|
+
|
|
294
|
+
Made with ❤️ by [Dario Passariello](https://dario.passariello.ca) with a lot of caffe' espresso!
|
|
295
|
+
|
|
296
|
+
</div>
|