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 CHANGED
@@ -1,49 +1,67 @@
1
- # [LayerPro](https://npmjs.com/package/layerpro)
1
+ # LayerPro 🚀
2
2
 
3
- ![layerpro](https://raw.githubusercontent.com/passariello/container/be0611e9bead336dcec32d522d103e7e3661f502/layerpro/assets/logos/logo.svg)
3
+ <div align="center">
4
4
 
5
- [![version](https://img.shields.io/npm/v/layerpro.svg)](https://npmjs.org/package/layerpro)
6
- [![downloads](https://img.shields.io/npm/dm/layerpro.svg)](https://npmjs.org/package/layerpro)
5
+ ![LayerPro](https://raw.githubusercontent.com/passariello/container/be0611e9bead336dcec32d522d103e7e3661f502/layerpro/assets/logos/logo.svg)
7
6
 
8
- [![GitBook](https://img.shields.io/static/v1?message=Documented%20on%20GitBook&logo=gitbook&logoColor=ffffff&label=%20&labelColor=5c5c5c&color=3F89A1)](https://a51.gitbook.io/layerpro)
7
+ [![Version](https://img.shields.io/npm/v/layerpro.svg)](https://npmjs.com/package/layerpro)
8
+ [![Downloads](https://img.shields.io/npm/dm/layerpro.svg)](https://npmjs.com/package/layerpro)
9
+ [![License](https://img.shields.io/npm/l/layerpro.svg)](https://github.com/passariello/layerpro/blob/main/LICENSE)
10
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
11
+ <!-- [![Test Status](https://img.shields.io/github/actions/workflow/status/passariello/layerpro/test.yml)](https://github.com/passariello/layerpro/actions) -->
9
12
 
10
- ## About
13
+ <!-- [![GitBook Documentation](https://img.shields.io/static/v1?message=Documented%20on%20GitBook&logo=gitbook&logoColor=ffffff&label=%20&labelColor=5c5c5c&color=3F89A1)](https://a51.gitbook.io/layerpro) -->
14
+ [![Patreon](https://img.shields.io/badge/Support-Patreon-orange.svg)](https://www.patreon.com/passariello)
11
15
 
12
- LayerPro offers a completely new way to customize web modals in your application. With LayerPro, you can create custom alerts, prompts, confirmations, and messages, effectively replacing the default browser modals.
16
+ </div>
13
17
 
14
- ## Live demo
18
+ ---
19
+
20
+ ## What is LayerPro?
15
21
 
16
- [https://tests.a51.dev/](https://tests.a51.dev/)
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
- You can view an HTML version demonstrating how dpHelper and LayerPro work together. These tools can be used with HTML, React, Vue, or any other frontend framework/library.
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
- ## Install for react + webpack projects
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
- ```js
25
- npm i layerpro --save-dev
26
- ```
43
+ ---
27
44
 
28
- or update:
45
+ ## 📦 Installation
29
46
 
30
- ```js
31
- npm i layerpro@latest --save-dev
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
- in the index (and only there):
55
+ Then import in your entry file:
35
56
 
36
- ```js
57
+ ```javascript
58
+ // index.js or index.ts
37
59
  import "layerpro";
38
- ```
39
-
40
- or
41
60
 
42
- ```js
43
- require("layerpro");
61
+ // That's it! Now you can use alert(), confirm(), prompt(), message() globally
44
62
  ```
45
63
 
46
- ## Install for ejs or other type of projects (like html)
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
- ## How to use it
72
+ ## 🚀 Quick Start
55
73
 
56
- 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).
74
+ ### Basic Usage
57
75
 
58
- For example, if you type **alert("hello, world!")**, you can see the result.
59
-
60
- You can also use these tools as messages directly from the console.
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
- "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)
82
+ "Are you sure?",
83
+ () => console.log("User clicked YES"),
84
+ () => console.log("User clicked NO")
71
85
  );
72
86
 
73
- message(
74
- "Hello world",
75
- ()=>console.log("This happen after OK") // callback for YES / OK)
76
- );
77
- ```
87
+ // Input prompt
88
+ prompt("What's your name?", (value) => {
89
+ console.log("User entered:", value);
90
+ });
78
91
 
79
- Example:
92
+ // Notification message
93
+ message("Operation completed successfully!");
94
+ ```
80
95
 
81
- ```js
82
- import 'layerpro'
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: '&#9888;', // 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
- // EXAMPLE WITH ALL OPTIONS
85
- function App() {
141
+ ### React Integration
86
142
 
87
- layerpro.popup.open(
88
- {
89
- id: 'exampleModal',
90
- body: 'Example',
91
- name: 'example',
92
- icon: '&#9888;',
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: "accept",
97
- cb: (e) => message("confirmed")
98
- },
99
- cancel: {
100
- text: "cancel"
157
+ text: "Save",
158
+ cb: () => console.log("Saved!")
101
159
  }
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
- }
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
- Example with a React component:
170
+ ---
137
171
 
138
- ```js
172
+ ## 🎯 API Reference
139
173
 
140
- // Example using React Component
174
+ ### Global Functions
141
175
 
142
- import React from "react"
143
- import 'layerpro'
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
- export default () => {
183
+ ### Popup Methods
146
184
 
147
- // Custom Component6
148
- const TestApp = () => {
149
- return (
150
- <div>
151
- Hello
152
- <label>
153
- Alert: <input type="button" value="Alert" onClick={() => alert("Hello")} />
154
- </label>
155
- </div>
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
- // 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: '&#9888;',
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
- copyright (c) 2019 - 2025 by Dario Passariello
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>