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 CHANGED
@@ -1,206 +1,184 @@
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
+ Drop-in replacement for browser modals with superpowers.
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
+ ---
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
+ ## What is LayerPro?
9
8
 
10
- ## About
9
+ LayerPro replaces the boring browser `alert()`, `confirm()`, and `prompt()` with beautiful, customizable modals that work everywhere.
11
10
 
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.
11
+ No more ugly popup boxes. No more blocking the main thread. Just clean, modern modals that your users will love.
13
12
 
14
- ## Live demo
13
+ ---
15
14
 
16
- [https://tests.a51.dev/](https://tests.a51.dev/)
15
+ ## Features
17
16
 
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.
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
- ## Install for react + webpack projects
27
+ ## Installation
23
28
 
24
- ```js
25
- npm i layerpro --save-dev
29
+ ```bash
30
+ npm install layerpro
26
31
  ```
27
32
 
28
- or update:
33
+ Or use directly in HTML:
29
34
 
30
- ```js
31
- npm i layerpro@latest --save-dev
35
+ ```html
36
+ <script src="https://cdn.jsdelivr.net/npm/layerpro"></script>
32
37
  ```
33
38
 
34
- in the index (and only there):
39
+ ---
35
40
 
36
- ```js
37
- import "layerpro";
38
- ```
41
+ ## Quick Start
39
42
 
40
- or
43
+ Import LayerPro once in your app entry point:
41
44
 
42
- ```js
43
- require("layerpro");
45
+ ```javascript
46
+ import "layerpro";
44
47
  ```
45
48
 
46
- ## Install for ejs or other type of projects (like html)
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
- ## How to use it
53
+ ## Usage
55
54
 
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).
55
+ ### Basic Modals
57
56
 
58
- For example, if you type **alert("hello, world!")**, you can see the result.
57
+ ```javascript
58
+ alert("Hello World!");
59
59
 
60
- You can also use these tools as messages directly from the console.
60
+ confirm("Are you sure?", () => {
61
+ console.log("User clicked YES");
62
+ });
61
63
 
62
- ```js
63
- alert("Hello world"); // Normal alert
64
+ prompt("What's your name?", (name) => {
65
+ console.log("User entered:", name);
66
+ });
64
67
 
65
- prompt("Your Name"); // Ask for input
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
- message(
74
- "Hello world",
75
- ()=>console.log("This happen after OK") // callback for YES / OK)
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
- Example:
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: '&#9888;',
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
- export default App
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
- Example with a React component:
101
+ ### The `body` Parameter
137
102
 
138
- ```js
103
+ The `body` property accepts different content types:
139
104
 
140
- // Example using React Component
105
+ | Type | Example |
106
+ |------|---------|
107
+ | Plain text | `body: "Hello"` |
108
+ | HTML string | `body: "<p>Hello</p>"` |
109
+ | React element | `body: <Component />` |
141
110
 
142
- import React from "react"
143
- import 'layerpro'
111
+ > **Note**: In React, always use elements (`<Component />`), not function calls (`Component()`).
144
112
 
145
- export default () => {
113
+ ---
146
114
 
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
- )
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: '&#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
- )
202
-
203
157
  }
204
158
  ```
205
159
 
206
- copyright (c) 2019 - 2025 by Dario Passariello
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