layerpro 2.8.0 → 3.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/llms.txt ADDED
@@ -0,0 +1,55 @@
1
+ # LayerPro
2
+
3
+ > Dependency-free custom modals (alert, confirm, prompt, message) and advanced
4
+ > popups for the browser. Vanilla DOM (no jQuery); React/react-dom are external
5
+ > and used only to render the modal body. Dockable, draggable, resizable,
6
+ > maximizable (pure CSS), with an OS-style taskbar.
7
+
8
+ ## Source
9
+
10
+ - [index.ts](index.ts): Entry point. Sets `window.layerpro` (frozen, non-enumerable), imports SCSS, initializes mode.
11
+ - [core/dom.ts](core/dom.ts): jQuery-free chainable DOM helper (`LpEl`, `lp`, `lpAll`, `lpCreate`, `lpDoc`, `lpWin`) — the replacement for jQuery.
12
+ - [core/properties.ts](core/properties.ts): The `popup` object — `open`, `close`, `center`, `maximize`, `iconize`, `index`, `zIndex`, `movable`, `resizable`, `cleanupEvents`, `unmount`.
13
+ - [core/genLayer.ts](core/genLayer.ts): DOM builder for a popup, dock/buttons wiring, pointer/click/dblclick handlers.
14
+ - [core/message.ts](core/message.ts): `alert`/`confirm`/`message`/`prompt` implementations; overrides `window.alert`/`confirm`/`prompt`.
15
+ - [core/mode.ts](core/mode.ts): Close popups on orientation/size mode switch.
16
+ - [core/mobile.ts](core/mobile.ts): Unified pointer/mouse/touch events (`getPointerDown`/`getPointerMove`/`getPointerUp`).
17
+ - [core/window.ts](core/window.ts): Window-level helpers (scroll, size).
18
+ - [core/credits.ts](core/credits.ts): Credits overlay helper.
19
+ - [core/namespace.ts](core/namespace.ts): Global namespace setup.
20
+
21
+ ## Types
22
+
23
+ - [types/layerpro.d.ts](types/layerpro.d.ts): Public TypeScript definitions (`GenLayerProps`, the `layerpro` global, `Window`/`globalThis` augmentations).
24
+
25
+ ## Docs
26
+
27
+ - [docs/README.md](docs/README.md): Project README (features, install, quick start).
28
+ - [docs/markdown/GUIDE.md](docs/markdown/GUIDE.md): Example-driven usage guide (modals, popups, dock, maximize, resize, React body, API).
29
+ - [docs/llms.txt](docs/llms.txt): This file.
30
+
31
+ ## Build & Config
32
+
33
+ - [package.json](package.json): Manifest. React/react-dom are `devDependencies` (external at runtime); **jQuery removed**. `main`/`browser` → `index.js` (ESM), `exports.import` → `index.js`.
34
+ - [tsup.config.ts](tsup.config.ts): Build (CJS + ESM, terser minify, esbuild-sass-plugin). Externalizes devDependencies.
35
+ - [tsup.plugin.copyStatic.ts](tsup.plugin.copyStatic.ts): Copies static files (README, types, license) into `dist`.
36
+ - [tsup.plugin.injectCss.ts](tsup.plugin.injectCss.ts): Injects compiled SCSS into the bundle.
37
+
38
+ ## Key behaviors
39
+
40
+ - **jQuery removed** — all DOM via `core/dom.ts`; public API unchanged.
41
+ - **React external** — only the modal `body` is rendered with `react-dom` `createRoot`.
42
+ - **Instant resize** — CSS `transition` disabled on the popup while resizing (no lag).
43
+ - **Maximize is pure CSS** — `position: fixed` + insets; follows viewport with no JS listeners.
44
+ - **Dock = OS taskbar** — click dock icon toggles restore / focus / minimize.
45
+ - **z-index** — set as unitless numbers; clicking body or title bar selects (brings to front).
46
+
47
+ ## Contributing
48
+
49
+ LayerPro is **open source** and free to use. The current codebase is private, but
50
+ **anyone is welcome to join**. If you would like to contribute, suggest changes,
51
+ or just chat about the project, contact the author:
52
+
53
+ - **Dario Passariello** — https://dario.passariello.ca/ — dariopassariello@gmail.com
54
+
55
+ Participation is voluntary and free; everyone is free to take part.
@@ -0,0 +1,315 @@
1
+ # LayerPro Guide
2
+
3
+ > A practical, example-driven guide to LayerPro — the real custom modals
4
+ > (alert, confirm, prompt, message) and advanced popups for the browser.
5
+
6
+ LayerPro is **dependency-free**: it no longer uses jQuery. All DOM work is done
7
+ with small, chainable vanilla helpers. React and react-dom are the only
8
+ external runtime dependencies, and they are used **only** to render the modal
9
+ body when you pass a React element.
10
+
11
+ ---
12
+
13
+ ## Table of Contents
14
+
15
+ 1. [Installation](#installation)
16
+ 2. [Quick Start](#quick-start)
17
+ 3. [Basic Modals](#basic-modals)
18
+ 4. [Custom Popups](#custom-popups)
19
+ 5. [Options Reference](#options-reference)
20
+ 6. [Dock & Taskbar](#dock--taskbar)
21
+ 7. [Maximize & Minimize](#maximize--minimize)
22
+ 8. [Dragging & Resizing](#dragging--resizing)
23
+ 9. [React Body](#react-body)
24
+ 10. [Selection & z-index](#selection--z-index)
25
+ 11. [API Methods](#api-methods)
26
+ 12. [Notes & Migration](#notes--migration)
27
+
28
+ ---
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ npm install layerpro
34
+ ```
35
+
36
+ Or drop it straight into HTML (UMD build):
37
+
38
+ ```html
39
+ <script src="https://cdn.jsdelivr.net/npm/layerpro"></script>
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Quick Start
45
+
46
+ Import LayerPro once at your app entry point. It overrides the global
47
+ `alert`, `confirm`, `prompt`, and exposes `message` and `layerpro`:
48
+
49
+ ```javascript
50
+ import "layerpro";
51
+ ```
52
+
53
+ That single import is enough — `window.layerpro` becomes available and the
54
+ global `alert`/`confirm`/`prompt` are replaced.
55
+
56
+ ---
57
+
58
+ ## Basic Modals
59
+
60
+ ```javascript
61
+ // Simple alert
62
+ alert("Hello World!");
63
+
64
+ // Confirm with YES / NO callbacks
65
+ confirm(
66
+ "Are you sure?",
67
+ () => console.debug("User clicked YES"),
68
+ () => console.debug("User clicked NO")
69
+ );
70
+
71
+ // Prompt with the typed value
72
+ prompt("What is your name?", (name) => {
73
+ console.debug("User entered:", name);
74
+ });
75
+
76
+ // Plain message (auto-styled info box)
77
+ message("Operation complete!", () => console.debug("message closed"));
78
+ ```
79
+
80
+ > The global functions keep the same signatures you already know, so legacy
81
+ > code keeps working.
82
+
83
+ ---
84
+
85
+ ## Custom Popups
86
+
87
+ Use `layerpro.popup.open(props)` for full control.
88
+
89
+ ```javascript
90
+ layerpro.popup.open({
91
+ id: "myModal",
92
+ name: "My Modal",
93
+ body: "<p>Your <b>content</b> here</p>",
94
+ width: 450,
95
+ height: 350,
96
+ movable: true,
97
+ resizable: true,
98
+ maximize: true,
99
+ iconize: true,
100
+ dockable: true,
101
+ close: true,
102
+ buttons: {
103
+ confirm: { text: "OK", cb: () => layerpro.popup.close("myModal") },
104
+ cancel: { text: "Cancel", cb: () => layerpro.popup.close("myModal") }
105
+ }
106
+ });
107
+ ```
108
+
109
+ ### The `body` parameter
110
+
111
+ | Type | Example |
112
+ |------|---------|
113
+ | Plain text | `body: "Hello"` |
114
+ | HTML string | `body: "<p>Hello</p>"` |
115
+ | React element | `body: <MyComponent />` |
116
+
117
+ > In React, always pass an **element** (`<Component />`), never a call
118
+ > (`Component()`).
119
+
120
+ ---
121
+
122
+ ## Options Reference
123
+
124
+ ```typescript
125
+ {
126
+ id: string, // Unique id (required)
127
+ body: any, // text | HTML string | HTMLElement | React element
128
+ name: string, // Title shown in the bar
129
+ icon: string, // Icon glyph / HTML entity
130
+ class: string, // Extra CSS class on the window
131
+
132
+ // Dimensions
133
+ width?: number | string,
134
+ height?: number | string,
135
+ minWidth?: number,
136
+ minHeight?: number,
137
+ maxWidth?: number,
138
+ maxHeight?: number,
139
+
140
+ // Position (numbers are px; strings are applied as-is, e.g. "10%")
141
+ top?: number | string,
142
+ left?: number | string,
143
+ right?: number | string,
144
+ bottom?: number | string,
145
+
146
+ // Timing
147
+ fadeIn?: number, // open fade duration (ms)
148
+ fadeOut?: number, // close fade duration (ms)
149
+ timer?: number, // auto-close after N ms
150
+
151
+ // Behavior flags
152
+ movable?: boolean, // draggable by the title bar
153
+ resizable?: boolean, // resize handles
154
+ maximize?: boolean, // double-click title bar to maximize
155
+ iconize?: boolean, // allow minimize to dock
156
+ dockable?: boolean, // show an icon in the dock bar
157
+ close?: boolean, // show the close button
158
+ raised?: boolean, // start raised / focused
159
+
160
+ // Buttons
161
+ buttons?: {
162
+ confirm?: { text: string; cb?: () => void },
163
+ cancel?: { text: string; cb?: () => void }
164
+ }
165
+ }
166
+ ```
167
+
168
+ If `top/left/right/bottom` are all `0` (or unset), the popup is auto-centered.
169
+
170
+ ---
171
+
172
+ ## Dock & Taskbar
173
+
174
+ When `dockable` and `iconize` are enabled, a minimized popup becomes an icon in
175
+ the bottom dock bar — exactly like an OS taskbar:
176
+
177
+ ```javascript
178
+ layerpro.popup.open({
179
+ id: "editor",
180
+ name: "Editor",
181
+ body: "<p>Edit something…</p>",
182
+ dockable: true,
183
+ iconize: true
184
+ });
185
+ ```
186
+
187
+ **Dock interactions (taskbar style):**
188
+
189
+ - Click a dock icon of a **minimized** popup → it is restored and focused.
190
+ - Click a dock icon of a popup that is open but **not focused** → it is brought
191
+ to the front.
192
+ - Click a dock icon of the **focused** popup → it is minimized back to the dock.
193
+
194
+ The close `✕` on the dock icon closes the popup completely.
195
+
196
+ ---
197
+
198
+ ## Maximize & Minimize
199
+
200
+ Maximize is implemented with **pure CSS** (`position: fixed` + `inset`), so the
201
+ popup fills the viewport and follows window resizing automatically — no JS
202
+ resize listeners are involved.
203
+
204
+ ```javascript
205
+ layerpro.popup.open({
206
+ id: "viewer",
207
+ name: "Viewer",
208
+ body: "<p>Big content</p>",
209
+ maximize: true,
210
+ iconize: true
211
+ });
212
+ ```
213
+
214
+ - **Double-click the title bar** → toggle maximize / restore.
215
+ - **Click the dock icon** of a maximized popup → restore it.
216
+
217
+ Because maximize is CSS-driven, resizing the browser window keeps the maximized
218
+ popup perfectly aligned with no lag.
219
+
220
+ ---
221
+
222
+ ## Dragging & Resizing
223
+
224
+ Dragging and resizing are **instant**: the CSS `transition` is disabled on the
225
+ popup while you drag a resize handle, so the popup tracks the pointer with no
226
+ lag (especially on the bottom edge).
227
+
228
+ ```javascript
229
+ layerpro.popup.open({
230
+ id: "panel",
231
+ name: "Panel",
232
+ body: "<p>Move and resize me</p>",
233
+ movable: true,
234
+ resizable: true
235
+ });
236
+ ```
237
+
238
+ - Drag the **title bar** to move.
239
+ - Drag the **edges/corners** to resize.
240
+ - These interactions are disabled automatically while a popup is maximized.
241
+
242
+ ---
243
+
244
+ ## React Body
245
+
246
+ Pass a React element as `body` and LayerPro mounts it with `react-dom`
247
+ `createRoot` inside the modal:
248
+
249
+ ```jsx
250
+ import { useState } from "react";
251
+
252
+ function Counter() {
253
+ const [n, setN] = useState(0);
254
+ return <button onClick={() => setN(n + 1)}>Clicked {n} times</button>;
255
+ }
256
+
257
+ layerpro.popup.open({
258
+ id: "reactModal",
259
+ name: "React Modal",
260
+ body: <Counter />,
261
+ width: 400,
262
+ height: 300
263
+ });
264
+ ```
265
+
266
+ React state, effects, and context all work normally inside the body.
267
+
268
+ ---
269
+
270
+ ## Selection & z-index
271
+
272
+ Clicking anywhere on a popup (the body **or** the title bar) brings it to the
273
+ front and gives it the `zHigh` highlight. The dock icon is also marked as
274
+ selected. z-index values are unitless (set as raw numbers, never `px`).
275
+
276
+ ```javascript
277
+ // Bring a popup to the front programmatically
278
+ layerpro.popup.index({ id: "myModal" });
279
+ ```
280
+
281
+ ---
282
+
283
+ ## API Methods
284
+
285
+ | Method | Description |
286
+ |--------|-------------|
287
+ | `layerpro.popup.open(props)` | Open a modal; returns the props |
288
+ | `layerpro.popup.close(id)` | Close (and unmount) a modal |
289
+ | `layerpro.popup.center(id)` | Center a modal in the viewport |
290
+ | `layerpro.popup.maximize(id)` | Toggle maximize (pure CSS) |
291
+ | `layerpro.popup.iconize(id)` | Toggle minimize to the dock |
292
+ | `layerpro.popup.index(id)` | Bring a modal to the front (select) |
293
+ | `layerpro.popup.zIndex()` | Get the next z-index counter value |
294
+ | `layerpro.popup.movable(id)` | Enable dragging |
295
+ | `layerpro.popup.resizable(id)` | Enable resizing |
296
+ | `layerpro.popup.cleanupEvents(id)` | Remove dock/button/esc listeners |
297
+ | `layerpro.popup.unmount(id)` | Unmount the React root (memory cleanup) |
298
+
299
+ ---
300
+
301
+ ## Notes & Migration
302
+
303
+ - **jQuery removed.** LayerPro no longer depends on jQuery. All DOM access uses
304
+ the internal `core/dom.ts` vanilla helper (`lp`, `lpAll`, `lpCreate`, `lpDoc`,
305
+ `lpWin`). Public behavior is unchanged.
306
+ - **React is external.** `react` and `react-dom` must be provided by the host
307
+ app and are used only to render the modal body.
308
+ - **Instant resize / maximize.** Transitions are disabled during resize, and
309
+ maximize is CSS-only, for a snappy, lag-free feel.
310
+ - **Vanilla pages still work.** No framework is required unless you pass a React
311
+ body.
312
+
313
+ ---
314
+
315
+ © [Dario Passariello](https://dario.passariello.ca/) — MIT License
File without changes
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "layerpro",
3
3
  "codeName": "layerpro",
4
- "version": "2.8.0",
4
+ "version": "3.0.1",
5
5
  "description": "The real custom modals, alert, confirm, prompt... for your browser",
6
6
  "main": "./index.cjs",
7
- "browser": "./index.cjs",
7
+ "browser": "./index.js",
8
8
  "types": "./index.d.ts",
9
9
  "typing": "./types/*",
10
10
  "license": "MIT",
@@ -48,23 +48,6 @@
48
48
  "url": "https://dario.passariello.ca/",
49
49
  "email": "dariopassariello@gmail.com"
50
50
  },
51
- "dependencies": {
52
- "caniuse-lite": "1.0.30001803"
53
- },
54
- "overrides": {
55
- "function-bind": "npm:@socketregistry/function-bind@^1",
56
- "hasown": "npm:@socketregistry/hasown@^1",
57
- "is-core-module": "npm:@socketregistry/is-core-module@^1",
58
- "object-assign": "npm:@socketregistry/object-assign@^1",
59
- "path-parse": "npm:@socketregistry/path-parse@^1"
60
- },
61
- "resolutions": {
62
- "function-bind": "npm:@socketregistry/function-bind@^1",
63
- "hasown": "npm:@socketregistry/hasown@^1",
64
- "is-core-module": "npm:@socketregistry/is-core-module@^1",
65
- "object-assign": "npm:@socketregistry/object-assign@^1",
66
- "path-parse": "npm:@socketregistry/path-parse@^1"
67
- },
68
51
  "module": "./index.js",
69
52
  "exports": {
70
53
  ".": {
package/types/files.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright: © 2019 Dario Passariello <dariopassariello@gmail.com>
2
+ Copyright: © 2026 Dario Passariello <dariopassariello@gmail.com>
3
3
  */
4
4
 
5
5
  declare module '*.js' {
@@ -19,7 +19,7 @@ declare function prompt(f1?: string, func1?: Function): any
19
19
 
20
20
  interface GenLayerProps {
21
21
 
22
- id: string
22
+ id: string | number
23
23
  body?: React.ReactElement | string | HTMLElement
24
24
  name?: string
25
25
  style?: any
package/FUNDING.yml DELETED
@@ -1,12 +0,0 @@
1
- # These are supported funding model platforms
2
-
3
- github: passariello
4
- patreon: passariello
5
- ko_fi: passariello
6
- liberapay: passariello
7
- issuehunt: passariello
8
- custom:
9
- [
10
- "https://dario.passariello.ca",
11
- "https://www.indiegogo.com/individuals/28513718",
12
- ]
package/types/jquery.d.ts DELETED
@@ -1,17 +0,0 @@
1
-
2
-
3
-
4
- declare module 'jquery'
5
-
6
- declare var $: any
7
- declare var jQuery: any
8
-
9
- // ///
10
-
11
- interface window {
12
- $: any
13
- jQuery: any
14
- }
15
-
16
- type $ = {}
17
- type jQuery = {}