layerpro 2.0.0 → 2.0.2

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,296 +1,184 @@
1
1
  # LayerPro 🚀
2
2
 
3
- <div align="center">
4
-
5
- ![LayerPro](https://raw.githubusercontent.com/passariello/container/be0611e9bead336dcec32d522d103e7e3661f502/layerpro/assets/logos/logo.svg)
6
-
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) -->
12
-
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)
15
-
16
- </div>
3
+ Drop-in replacement for browser modals with superpowers.
17
4
 
18
5
  ---
19
6
 
20
7
  ## What is LayerPro?
21
8
 
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.
9
+ LayerPro replaces the boring browser `alert()`, `confirm()`, and `prompt()` with beautiful, customizable modals that work everywhere.
23
10
 
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.
11
+ No more ugly popup boxes. No more blocking the main thread. Just clean, modern modals that your users will love.
25
12
 
26
13
  ---
27
14
 
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 |
15
+ ## Features
42
16
 
43
- ---
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
44
24
 
45
- ## 📦 Installation
25
+ ---
46
26
 
47
- ### For React / Vue / Webpack Projects
27
+ ## Installation
48
28
 
49
29
  ```bash
50
- npm install layerpro --save-dev
51
- # or
52
- npm install layerpro@latest --save-dev
30
+ npm install layerpro
53
31
  ```
54
32
 
55
- Then import in your entry file:
56
-
57
- ```javascript
58
- // index.js or index.ts
59
- import "layerpro";
33
+ Or use directly in HTML:
60
34
 
61
- // That's it! Now you can use alert(), confirm(), prompt(), message() globally
35
+ ```html
36
+ <script src="https://cdn.jsdelivr.net/npm/layerpro"></script>
62
37
  ```
63
38
 
64
- ### For Plain HTML / EJS Projects
39
+ ---
40
+
41
+ ## Quick Start
65
42
 
66
- ```html
67
- <script src="https://cdn.jsdelivr.net/npm/layerpro"></script>
43
+ Import LayerPro once in your app entry point:
44
+
45
+ ```javascript
46
+ import "layerpro";
68
47
  ```
69
48
 
49
+ That's it. Now you have `alert()`, `confirm()`, `prompt()`, and `message()` globally.
50
+
70
51
  ---
71
52
 
72
- ## 🚀 Quick Start
53
+ ## Usage
73
54
 
74
- ### Basic Usage
55
+ ### Basic Modals
75
56
 
76
57
  ```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);
58
+ alert("Hello World!");
59
+
60
+ confirm("Are you sure?", () => {
61
+ console.debug("User clicked YES");
90
62
  });
91
63
 
92
- // Notification message
93
- message("Operation completed successfully!");
64
+ prompt("What's your name?", (name) => {
65
+ console.debug("User entered:", name);
66
+ });
67
+
68
+ message("Operation complete!");
94
69
  ```
95
70
 
96
- ### Advanced Popup
71
+ ### Custom Popups
97
72
 
98
73
  ```javascript
99
74
  layerpro.popup.open({
100
75
  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
76
+ name: 'My Modal',
77
+ body: '<p>Your content here</p>',
106
78
  width: 450,
107
79
  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
80
  buttons: {
129
- confirm: {
130
- text: "Accept",
131
- cb: () => handleAccept()
132
- },
133
- cancel: {
134
- text: "Cancel",
135
- cb: () => handleCancel()
136
- }
81
+ confirm: { text: "OK", cb: () => {} },
82
+ cancel: { text: "Cancel", cb: () => {} }
137
83
  }
138
84
  });
139
85
  ```
140
86
 
141
- ### React Integration
87
+ ### React Components
88
+
89
+ In a React environment, you can pass React components directly:
142
90
 
143
91
  ```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
- };
163
-
164
- return (
165
- <button onClick={handleClick}>Open Modal</button>
166
- );
167
- }
92
+ layerpro.popup.open({
93
+ id: 'reactModal',
94
+ name: 'React Modal',
95
+ body: <MyComponent />, // React element
96
+ width: 500,
97
+ height: 400
98
+ });
168
99
  ```
169
100
 
170
- ---
171
-
172
- ## 🎯 API Reference
101
+ ### The `body` Parameter
173
102
 
174
- ### Global Functions
103
+ The `body` property accepts different content types:
175
104
 
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 |
105
+ | Type | Example |
106
+ |------|---------|
107
+ | Plain text | `body: "Hello"` |
108
+ | HTML string | `body: "<p>Hello</p>"` |
109
+ | React element | `body: <Component />` |
182
110
 
183
- ### Popup Methods
184
-
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 |
111
+ > **Note**: In React, always use elements (`<Component />`), not function calls (`Component()`).
196
112
 
197
113
  ---
198
114
 
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.
115
+ ## Options
208
116
 
209
117
  ```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
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)
215
123
 
216
124
  // 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
125
+ width: number,
126
+ height: number,
127
+ minWidth: number,
128
+ minHeight: number,
129
+ maxWidth: number,
130
+ maxHeight: number,
223
131
 
224
132
  // 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
133
+ top: number | string,
134
+ left: number | string,
135
+ right: number | string,
136
+ bottom: number | string,
229
137
 
230
138
  // Animation
231
- fadeIn?: number; // Fade in duration (ms)
232
- fadeOut?: number; // Fade out duration (ms)
233
- timer?: number; // Auto-close timer
139
+ fadeIn: number,
140
+ fadeOut: number,
141
+ timer: number,
234
142
 
235
143
  // 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
- };
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 }
156
+ }
254
157
  }
255
158
  ```
256
159
 
257
160
  ---
258
161
 
259
- ## 🌍 Browser Support
162
+ ## Methods
260
163
 
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
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 |
283
173
 
284
174
  ---
285
175
 
286
- ## 🤝 Contributing
176
+ ## Browser Support
287
177
 
288
- Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
178
+ Chrome 80+ Firefox 75+ Safari 13+ Edge 80+
289
179
 
290
180
  ---
291
181
 
292
- <div align="center">
293
-
294
- Made with ❤️ by [Dario Passariello](https://dario.passariello.ca) with a lot of caffe' espresso!
182
+ ## License
295
183
 
296
- </div>
184
+ MIT