layerpro 4.0.0 → 4.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 CHANGED
@@ -1,9 +1,13 @@
1
1
  # LayerPro
2
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.
3
+ > Browser window system: OS-style windows (draggable, resizable, maximizable,
4
+ > dockable) that host any content, including React components. Also provides
5
+ > Promise-based custom modals (alert, confirm, prompt, message) as a drop-in
6
+ > replacement for the browser's native ones. Vanilla DOM (no jQuery);
7
+ > React/react-dom are external and used only to render the modal body.
8
+ > Dockable, draggable, resizable, maximizable (pure CSS), with an OS-style
9
+ > taskbar. Fully themeable via CSS custom properties or the `layerpro` cascade
10
+ > layer - see "Overriding the CSS" in the README.
7
11
 
8
12
  ## Source
9
13
 
@@ -17,6 +21,7 @@
17
21
  - [core/mobile.ts](core/mobile.ts): Unified pointer/mouse/touch events (`getPointerDown`/`getPointerMove`/`getPointerUp`).
18
22
  - [core/window.ts](core/window.ts): Window-level helpers (scroll, size).
19
23
  - [core/credits.ts](core/credits.ts): Credits overlay helper.
24
+ - [core/version.ts](core/version.ts): `layerpro.version()` - reads the current version from `app.json`.
20
25
  - [core/namespace.ts](core/namespace.ts): Global namespace setup.
21
26
 
22
27
  ## Types
package/markdown/GUIDE.md CHANGED
@@ -1,7 +1,10 @@
1
1
  # LayerPro Guide
2
2
 
3
- > A practical, example-driven guide to LayerPro - the real custom modals
4
- > (alert, confirm, prompt, message) and advanced popups for the browser.
3
+ > A practical, example-driven guide to LayerPro - a browser window system that
4
+ > generates OS-style windows (draggable, resizable, maximizable, dockable) able
5
+ > to host any content, including React components, and that also provides
6
+ > Promise-based custom modals (alert, confirm, prompt, message) as a drop-in
7
+ > replacement for the browser's native ones.
5
8
 
6
9
  LayerPro is **dependency-free**: it no longer uses jQuery. All DOM work is done
7
10
  with small, chainable vanilla helpers. React and react-dom are the only
@@ -16,14 +19,16 @@ body when you pass a React element.
16
19
  2. [Quick Start](#quick-start)
17
20
  3. [Basic Modals](#basic-modals)
18
21
  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)
22
+ 5. [OS-style Windows](#os-style-windows)
23
+ 6. [Options Reference](#options-reference)
24
+ 7. [Dock & Taskbar](#dock--taskbar)
25
+ 8. [Maximize & Minimize](#maximize--minimize)
26
+ 9. [Dragging & Resizing](#dragging--resizing)
27
+ 10. [React Body](#react-body)
28
+ 11. [Selection & z-index](#selection--z-index)
29
+ 12. [API Methods](#api-methods)
30
+ 13. [Styling & z-index](#styling--z-index)
31
+ 14. [Notes & Migration](#notes--migration)
27
32
 
28
33
  ---
29
34
 
@@ -129,6 +134,55 @@ layerpro.popup.open({
129
134
 
130
135
  ---
131
136
 
137
+ ## OS-style Windows
138
+
139
+ A popup is not limited to a modal dialog. With `movable`, `resizable`,
140
+ `maximize`, `iconize` and `dockable` enabled it becomes a real OS-style
141
+ window: draggable by its title bar, resizable from the edges, maximizable,
142
+ minimizable into the dock, and stackable with the other windows on the page.
143
+
144
+ ```javascript
145
+ layerpro.popup.open({
146
+ id: "dashboard",
147
+ name: "Dashboard",
148
+ icon: "📊",
149
+ body: "<h2>Live metrics</h2><p>Anything you want inside.</p>",
150
+ width: 640,
151
+ height: 420,
152
+ movable: true,
153
+ resizable: true,
154
+ maximize: true,
155
+ iconize: true,
156
+ dockable: true,
157
+ close: true
158
+ });
159
+ ```
160
+
161
+ With a React component inside, this becomes a real application window rendered
162
+ in the page with native-looking chrome:
163
+
164
+ ```jsx
165
+ layerpro.popup.open({
166
+ id: "settingsWindow",
167
+ name: "Settings",
168
+ icon: "&#9881;",
169
+ body: <SettingsPanel />,
170
+ width: 720,
171
+ height: 480,
172
+ movable: true,
173
+ resizable: true,
174
+ maximize: true,
175
+ iconize: true,
176
+ dockable: true,
177
+ close: true
178
+ });
179
+ ```
180
+
181
+ > `modal: true` is what turns a window into a blocking dialog. Leave it off for
182
+ > windows the user should be able to move around while working on the page.
183
+
184
+ ---
185
+
132
186
  ## Options Reference
133
187
 
134
188
  ```typescript
@@ -347,6 +401,102 @@ Stable class names (`.popup_bar`, `.popup_window`, `.popup_overflow`,
347
401
  `.popup_modal`) are emitted alongside the per-id classes so themes can target
348
402
  elements without attribute selectors.
349
403
 
404
+ ### Overriding the CSS
405
+
406
+ LayerPro never writes a plain inline style: every declaration lives in the
407
+ stylesheet and is driven by a **class** (the state) or by a **CSS custom
408
+ property** (the value). That means any part of a window can be restyled with
409
+ a plain CSS rule - nothing needs `!important` to win over an inline style.
410
+
411
+ There are three ways to restyle LayerPro, from the most recommended to the most
412
+ surgical.
413
+
414
+ **1. CSS custom properties (recommended).** Every visual detail is driven by a
415
+ variable on `:root`, so theming needs no selectors and no `!important`:
416
+
417
+ ```css
418
+ :root {
419
+ --bar-background: #1f2937;
420
+ --bar-selected-background: #2563eb;
421
+ --bar-color: #f9fafb;
422
+ --window-background: #111827;
423
+ --window-border-radius: 4px;
424
+ --internal-background: #0b1220;
425
+ --body-color: #e5e7eb;
426
+ --button-background-color: #2563eb;
427
+ --button-color: #ffffff;
428
+ }
429
+ ```
430
+
431
+ Variables can also be scoped per popup, because every window lives inside
432
+ `#popup`:
433
+
434
+ ```css
435
+ #popup .popup_window_myDarkPopup {
436
+ --window-background: #000;
437
+ --bar-background: #000;
438
+ }
439
+ ```
440
+
441
+ **2. Target the generated classes.** Each element carries a stable class alias
442
+ next to its id-suffixed class:
443
+
444
+ ```css
445
+ #popup .popup_window { border-radius: 0; }
446
+ #popup .buttons button { background: #2563eb; }
447
+ #popup .popup_option .close:hover { background: #dc2626; }
448
+ #popup_dock { background: #111827; }
449
+ ```
450
+
451
+ The visual **states** are classes too, so they can be restyled like any other
452
+ element:
453
+
454
+ | Class | Applied when |
455
+ |-------|--------------|
456
+ | `.popup_maximized` | the window is maximized |
457
+ | `.popup_iconized` | the window is minimized to the dock |
458
+ | `.popup_dimmed` | another window has the focus |
459
+ | `.popup_content_hidden` | another window has the focus |
460
+ | `.popup_content_visible` | the window has the focus |
461
+ | `.lp_hidden` | the element is hidden |
462
+ | `.lp_fade_in` / `.lp_fade_out` | during a fade |
463
+ | `.lp_no_pointer` | while dragging/resizing |
464
+ | `.lp_no_touch` | on the drag/resize handles |
465
+ | `.lp_no_transition` | while resizing |
466
+
467
+ ```css
468
+ #popup .popup_maximized { inset: 0; bottom: 0; }
469
+ #popup .popup_dimmed { opacity: .8; }
470
+ ```
471
+
472
+ The geometry of a window is carried by custom properties, so it can be
473
+ overridden as well: `--lp-top`, `--lp-left`, `--lp-right`, `--lp-bottom`,
474
+ `--lp-width`, `--lp-height`, `--lp-min-width`, `--lp-min-height`,
475
+ `--lp-max-width`, `--lp-max-height`, `--lp-z-index`.
476
+
477
+ ```css
478
+ #popup .popup_overflow { --lp-left: 50%; --lp-top: 100px; }
479
+ ```
480
+
481
+ **3. Cascade layers (full control).** All LayerPro styles live inside the CSS
482
+ cascade layer `layerpro`. Unlayered host rules always win, so a host stylesheet
483
+ can restyle the popups without `!important`:
484
+
485
+ ```css
486
+ #popup { border-radius: 4px; }
487
+ ```
488
+
489
+ If the host declares its own layer, it must be declared **before** `layerpro`,
490
+ otherwise it loses:
491
+
492
+ ```css
493
+ @layer app, layerpro;
494
+ ```
495
+
496
+ > Do **not** rely on `!important` to override LayerPro: LayerPro's `!important`
497
+ > rules live inside a layer and are stronger than unlayered host `!important`
498
+ > rules. Use plain rules or a host layer declared before `layerpro`.
499
+
350
500
  ---
351
501
 
352
502
  ## Notes & Migration
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "layerpro",
3
3
  "codeName": "layerpro",
4
- "version": "4.0.0",
4
+ "version": "4.0.1",
5
5
  "description": "The real custom modals, alert, confirm, prompt... for your browser",
6
6
  "main": "./index.cjs",
7
7
  "module": "./index.js",
@@ -61,6 +61,23 @@ interface GenLayerProps {
61
61
  store?: unknown
62
62
  inheritContext?: boolean
63
63
  resilient?: boolean
64
+
65
+ /**
66
+ * Open the layer inside a real browser window (`window.open`) instead of
67
+ * the in-page overlay. The window keeps the layer information: name, icon,
68
+ * dimensions, position, body and buttons.
69
+ */
70
+ native?: boolean
71
+ /**
72
+ * Save the position and the size of the window and restore them on the
73
+ * next open with the same id (stored in `localStorage`).
74
+ */
75
+ persist?: boolean
76
+ /**
77
+ * Close the native window when the page that opened it is closed.
78
+ * A reload/refresh of the opener does NOT close the native window.
79
+ */
80
+ closeWithOpener?: boolean
64
81
  }
65
82
 
66
83
  /**
@@ -107,6 +124,8 @@ interface GenLayerProps {
107
124
  index: (id: string | number | GenLayerProps) => void
108
125
  close: (id: string | number | GenLayerProps | null | undefined) => void
109
126
  unmount: (id: string) => void
127
+ /** Remove a popup and its DOM synchronously. */
128
+ destroy: (id: string) => void
110
129
  cleanupEvents: (id: string) => void
111
130
  abortSource: (id: string) => void
112
131
  /** @internal - managed internally for stacking order; do not call. */