layerpro 1.5.0 → 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 +236 -165
- 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 -34
- 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,175 +69,228 @@ require("layerpro");
|
|
|
51
69
|
|
|
52
70
|
---
|
|
53
71
|
|
|
54
|
-
|
|
55
|
-
> Your project need to have jquery as dependencies
|
|
56
|
-
> Use this on core config
|
|
72
|
+
## 🚀 Quick Start
|
|
57
73
|
|
|
58
|
-
###
|
|
74
|
+
### Basic Usage
|
|
59
75
|
|
|
60
|
-
```
|
|
61
|
-
|
|
76
|
+
```javascript
|
|
77
|
+
// Simple alert
|
|
78
|
+
alert("Hello, World!");
|
|
79
|
+
|
|
80
|
+
// Confirmation dialog with callbacks
|
|
81
|
+
confirm(
|
|
82
|
+
"Are you sure?",
|
|
83
|
+
() => console.log("User clicked YES"),
|
|
84
|
+
() => console.log("User clicked NO")
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// Input prompt
|
|
88
|
+
prompt("What's your name?", (value) => {
|
|
89
|
+
console.log("User entered:", value);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Notification message
|
|
93
|
+
message("Operation completed successfully!");
|
|
62
94
|
```
|
|
63
95
|
|
|
64
|
-
###
|
|
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
|
+
```
|
|
140
|
+
|
|
141
|
+
### React Integration
|
|
142
|
+
|
|
143
|
+
```jsx
|
|
144
|
+
import 'layerpro';
|
|
145
|
+
import React from 'react';
|
|
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,
|
|
155
|
+
buttons: {
|
|
156
|
+
confirm: {
|
|
157
|
+
text: "Save",
|
|
158
|
+
cb: () => console.log("Saved!")
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
};
|
|
65
163
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
164
|
+
return (
|
|
165
|
+
<button onClick={handleClick}>Open Modal</button>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
69
168
|
```
|
|
70
169
|
|
|
71
170
|
---
|
|
72
171
|
|
|
73
|
-
##
|
|
74
|
-
|
|
75
|
-
ype layerpro in your console to explore all the available tools you can use globally! You can call these tools from anywhere without needing to import them (just include the import once in your index file).
|
|
172
|
+
## 🎯 API Reference
|
|
76
173
|
|
|
77
|
-
|
|
174
|
+
### Global Functions
|
|
78
175
|
|
|
79
|
-
|
|
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 |
|
|
80
182
|
|
|
81
|
-
|
|
82
|
-
alert("Hello world"); // Normal alert
|
|
183
|
+
### Popup Methods
|
|
83
184
|
|
|
84
|
-
|
|
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 |
|
|
85
196
|
|
|
86
|
-
|
|
87
|
-
"Hello world",
|
|
88
|
-
()=>console.log("hello"), // callback for YES / OK
|
|
89
|
-
()=>console.log("bye") // callback for NO / CANCEL (you can use null if you don't want CB)
|
|
90
|
-
);
|
|
197
|
+
---
|
|
91
198
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
+
};
|
|
254
|
+
}
|
|
96
255
|
```
|
|
97
256
|
|
|
98
|
-
|
|
257
|
+
---
|
|
99
258
|
|
|
100
|
-
|
|
101
|
-
import 'layerpro'
|
|
259
|
+
## 🌍 Browser Support
|
|
102
260
|
|
|
103
|
-
|
|
104
|
-
|
|
261
|
+
| Browser | Version |
|
|
262
|
+
|---------|---------|
|
|
263
|
+
| Chrome | 80+ |
|
|
264
|
+
| Firefox | 75+ |
|
|
265
|
+
| Safari | 13+ |
|
|
266
|
+
| Edge | 80+ |
|
|
105
267
|
|
|
106
|
-
|
|
107
|
-
{
|
|
108
|
-
id: 'exampleModal',
|
|
109
|
-
body: 'Example',
|
|
110
|
-
name: 'example',
|
|
111
|
-
icon: '⚠',
|
|
268
|
+
---
|
|
112
269
|
|
|
113
|
-
|
|
114
|
-
confirm: {
|
|
115
|
-
text: "accept",
|
|
116
|
-
cb: (e) => message("confirmed")
|
|
117
|
-
},
|
|
118
|
-
cancel: {
|
|
119
|
-
text: "cancel"
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
width: 400,
|
|
124
|
-
height: 300,
|
|
125
|
-
maxWidth: 500,
|
|
126
|
-
maxHeight: 350,
|
|
127
|
-
minWidth: 200,
|
|
128
|
-
minHeight: 150,
|
|
129
|
-
top: '10%',
|
|
130
|
-
left: '10%',
|
|
131
|
-
right: 'auto',
|
|
132
|
-
bottom: 'auto',
|
|
133
|
-
|
|
134
|
-
fadeIn: 500,
|
|
135
|
-
fadeOut: 500,
|
|
136
|
-
timer: 0,
|
|
137
|
-
|
|
138
|
-
iconize: true,
|
|
139
|
-
maximize: true,
|
|
140
|
-
close: true,
|
|
141
|
-
isMaximize: false,
|
|
142
|
-
dockable: false,
|
|
143
|
-
raised: true,
|
|
144
|
-
movable: true,
|
|
145
|
-
resizable: false,
|
|
146
|
-
store: false
|
|
147
|
-
}
|
|
148
|
-
)
|
|
149
|
-
}
|
|
270
|
+
## 📄 License
|
|
150
271
|
|
|
151
|
-
|
|
272
|
+
MIT License - see [LICENSE.md](LICENSE.md) for details.
|
|
152
273
|
|
|
153
|
-
|
|
274
|
+
---
|
|
154
275
|
|
|
155
|
-
|
|
276
|
+
## 👤 Author
|
|
156
277
|
|
|
157
|
-
|
|
278
|
+
**Dario Passariello**
|
|
158
279
|
|
|
159
|
-
|
|
280
|
+
- GitHub: [@passariello](https://github.com/passariello)
|
|
281
|
+
- Email: dariopassariello@gmail.com
|
|
282
|
+
- Website: https://dario.passariello.ca
|
|
160
283
|
|
|
161
|
-
|
|
162
|
-
import 'layerpro'
|
|
284
|
+
---
|
|
163
285
|
|
|
164
|
-
|
|
286
|
+
## 🤝 Contributing
|
|
165
287
|
|
|
166
|
-
|
|
167
|
-
const TestApp = () => {
|
|
168
|
-
return (
|
|
169
|
-
<div>
|
|
170
|
-
Hello
|
|
171
|
-
<label>
|
|
172
|
-
Alert: <input type="button" value="Alert" onClick={() => alert("Hello")} />
|
|
173
|
-
</label>
|
|
174
|
-
</div>
|
|
175
|
-
)
|
|
176
|
-
}
|
|
288
|
+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
177
289
|
|
|
178
|
-
|
|
179
|
-
layerpro.popup.open(
|
|
180
|
-
{
|
|
181
|
-
id: 'exampleModal',
|
|
182
|
-
body: TestApp(),
|
|
183
|
-
buttons: {
|
|
184
|
-
confirm: {
|
|
185
|
-
text: "accept",
|
|
186
|
-
cb: () => {
|
|
187
|
-
message("confirmed")
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
cancel: {
|
|
191
|
-
text: "cancel",
|
|
192
|
-
cb: () => {
|
|
193
|
-
alert("cancelled")
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
width: 350,
|
|
198
|
-
height: 300,
|
|
199
|
-
name: 'example',
|
|
200
|
-
icon: '⚠',
|
|
201
|
-
iconize: true,
|
|
202
|
-
maximize: true,
|
|
203
|
-
close: true,
|
|
204
|
-
isMaximize: false,
|
|
205
|
-
dockable: false,
|
|
206
|
-
raised: true,
|
|
207
|
-
movable: true,
|
|
208
|
-
resizable: false,
|
|
209
|
-
store: false,
|
|
210
|
-
top: '10%',
|
|
211
|
-
left: '10%',
|
|
212
|
-
right: 'auto',
|
|
213
|
-
bottom: 'auto',
|
|
214
|
-
minWidth: 200,
|
|
215
|
-
minHeight: 150,
|
|
216
|
-
fadeIn: 500,
|
|
217
|
-
fadeOut: 500,
|
|
218
|
-
timer: 0
|
|
219
|
-
}
|
|
220
|
-
)
|
|
290
|
+
---
|
|
221
291
|
|
|
222
|
-
|
|
223
|
-
|
|
292
|
+
<div align="center">
|
|
293
|
+
|
|
294
|
+
Made with ❤️ by [Dario Passariello](https://dario.passariello.ca) with a lot of caffe' espresso!
|
|
224
295
|
|
|
225
|
-
|
|
296
|
+
</div>
|