layerpro 3.0.1 → 3.1.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 +116 -14
- package/index.cjs +346 -317
- package/index.css +63 -45
- package/index.js +346 -315
- package/llms.txt +2 -2
- package/markdown/GUIDE.md +72 -20
- package/package.json +1 -1
- package/types/layerpro.d.ts +36 -25
package/llms.txt
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
- [core/dom.ts](core/dom.ts): jQuery-free chainable DOM helper (`LpEl`, `lp`, `lpAll`, `lpCreate`, `lpDoc`, `lpWin`) — the replacement for jQuery.
|
|
12
12
|
- [core/properties.ts](core/properties.ts): The `popup` object — `open`, `close`, `center`, `maximize`, `iconize`, `index`, `zIndex`, `movable`, `resizable`, `cleanupEvents`, `unmount`.
|
|
13
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
|
|
14
|
+
- [core/message.ts](core/message.ts): `alert`/`confirm`/`message`/`prompt` implementations; overrides `window.alert`/`confirm`/`prompt` (callback-based, NOT synchronous) and provides `layerpro.noGlobals()` to restore natives.
|
|
15
15
|
- [core/mode.ts](core/mode.ts): Close popups on orientation/size mode switch.
|
|
16
16
|
- [core/mobile.ts](core/mobile.ts): Unified pointer/mouse/touch events (`getPointerDown`/`getPointerMove`/`getPointerUp`).
|
|
17
17
|
- [core/window.ts](core/window.ts): Window-level helpers (scroll, size).
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
- **Instant resize** — CSS `transition` disabled on the popup while resizing (no lag).
|
|
43
43
|
- **Maximize is pure CSS** — `position: fixed` + insets; follows viewport with no JS listeners.
|
|
44
44
|
- **Dock = OS taskbar** — click dock icon toggles restore / focus / minimize.
|
|
45
|
-
- **z-index** — set as unitless numbers;
|
|
45
|
+
- **z-index** — set as unitless numbers; the base is read from the `--popup-z-index` CSS variable (default `1000`). Clicking the body or title bar selects (brings to front).
|
|
46
46
|
|
|
47
47
|
## Contributing
|
|
48
48
|
|
package/markdown/GUIDE.md
CHANGED
|
@@ -51,7 +51,18 @@ import "layerpro";
|
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
That single import is enough — `window.layerpro` becomes available and the
|
|
54
|
-
global `alert`/`confirm`/`prompt` are replaced.
|
|
54
|
+
global `alert`/`confirm`/`prompt` are replaced, and a `message` global is added.
|
|
55
|
+
|
|
56
|
+
> **⚠️ Global override contract:** the overridden `confirm()` no longer returns a
|
|
57
|
+
> `boolean` and `prompt()` no longer returns a `string` — they are callback-based
|
|
58
|
+
> and return `undefined`. If your codebase (or a third-party dependency) relies on
|
|
59
|
+
> the native synchronous return values, call `layerpro.noGlobals()` right after
|
|
60
|
+
> importing to restore the originals:
|
|
61
|
+
>
|
|
62
|
+
> ```javascript
|
|
63
|
+
> import "layerpro";
|
|
64
|
+
> layerpro.noGlobals(); // restores native alert/confirm/prompt, drops `message`
|
|
65
|
+
> ```
|
|
55
66
|
|
|
56
67
|
---
|
|
57
68
|
|
|
@@ -123,13 +134,14 @@ layerpro.popup.open({
|
|
|
123
134
|
|
|
124
135
|
```typescript
|
|
125
136
|
{
|
|
126
|
-
id: string, // Unique id (
|
|
137
|
+
id: string, // Unique id (auto-generated as popup_1, popup_2, … if omitted)
|
|
127
138
|
body: any, // text | HTML string | HTMLElement | React element
|
|
128
139
|
name: string, // Title shown in the bar
|
|
129
|
-
icon: string, // Icon glyph
|
|
140
|
+
icon: string, // Icon glyph (HTML entity, e.g. "⚠") or HTML string
|
|
141
|
+
// (e.g. '<i class="fa fa-star"></i>')
|
|
130
142
|
class: string, // Extra CSS class on the window
|
|
131
143
|
|
|
132
|
-
// Dimensions
|
|
144
|
+
// Dimensions (defaults: width 340, height 220; minWidth 340, minHeight 220)
|
|
133
145
|
width?: number | string,
|
|
134
146
|
height?: number | string,
|
|
135
147
|
minWidth?: number,
|
|
@@ -142,10 +154,12 @@ layerpro.popup.open({
|
|
|
142
154
|
left?: number | string,
|
|
143
155
|
right?: number | string,
|
|
144
156
|
bottom?: number | string,
|
|
157
|
+
center?: boolean, // Center in the viewport (adds a small cascade
|
|
158
|
+
// offset per open window so stacks don't overlap)
|
|
145
159
|
|
|
146
160
|
// Timing
|
|
147
|
-
fadeIn?: number, // open fade duration (ms)
|
|
148
|
-
fadeOut?: number, // close fade duration (ms)
|
|
161
|
+
fadeIn?: number, // open fade duration (ms, default 100)
|
|
162
|
+
fadeOut?: number, // close fade duration (ms, default 100)
|
|
149
163
|
timer?: number, // auto-close after N ms
|
|
150
164
|
|
|
151
165
|
// Behavior flags
|
|
@@ -154,18 +168,21 @@ layerpro.popup.open({
|
|
|
154
168
|
maximize?: boolean, // double-click title bar to maximize
|
|
155
169
|
iconize?: boolean, // allow minimize to dock
|
|
156
170
|
dockable?: boolean, // show an icon in the dock bar
|
|
157
|
-
close?: boolean,
|
|
158
|
-
raised?: boolean, //
|
|
159
|
-
|
|
160
|
-
// Buttons
|
|
161
|
-
buttons?: {
|
|
162
|
-
confirm?: { text: string; cb?: () => void },
|
|
163
|
-
cancel?: { text: string; cb?: () => void }
|
|
164
|
-
}
|
|
171
|
+
close?: boolean, // show the close button
|
|
172
|
+
raised?: boolean, // alias: modal — show a full-screen overlay that
|
|
173
|
+
modal?: boolean, // blocks pointer events to the page underneath
|
|
165
174
|
}
|
|
166
175
|
```
|
|
167
176
|
|
|
168
|
-
If `top/left/right/bottom` are all `0` (or unset)
|
|
177
|
+
If `top/left/right/bottom` are all `0` (or unset) the popup is auto-centered.
|
|
178
|
+
Pass `center: true` to force centering regardless of the position props.
|
|
179
|
+
|
|
180
|
+
> **`raised` / `modal`** injects a full-viewport overlay (`popup_raised_<id>`)
|
|
181
|
+
> that intercepts every pointer event — the page underneath becomes unclickable
|
|
182
|
+
> until the popup closes. This is modal behavior; both names are accepted.
|
|
183
|
+
|
|
184
|
+
> **Duplicate id** — opening a popup whose `id` already exists brings that window
|
|
185
|
+
> to the front and refreshes its `body`/`buttons` instead of doing nothing.
|
|
169
186
|
|
|
170
187
|
---
|
|
171
188
|
|
|
@@ -284,17 +301,52 @@ layerpro.popup.index({ id: "myModal" });
|
|
|
284
301
|
|
|
285
302
|
| Method | Description |
|
|
286
303
|
|--------|-------------|
|
|
287
|
-
| `layerpro.popup.open(props)` | Open a modal; returns the props |
|
|
304
|
+
| `layerpro.popup.open(props)` | Open a modal; returns the props. Re-opening a same-id window brings it to front + refreshes body |
|
|
288
305
|
| `layerpro.popup.close(id)` | Close (and unmount) a modal |
|
|
289
|
-
| `layerpro.popup.center(id)` | Center a modal in the viewport |
|
|
290
|
-
| `layerpro.popup.maximize(
|
|
306
|
+
| `layerpro.popup.center(id, offset?)` | Center a modal in the viewport; optional pixel offset |
|
|
307
|
+
| `layerpro.popup.maximize(props)` | Toggle maximize (pure CSS) |
|
|
291
308
|
| `layerpro.popup.iconize(id)` | Toggle minimize to the dock |
|
|
292
309
|
| `layerpro.popup.index(id)` | Bring a modal to the front (select) |
|
|
293
310
|
| `layerpro.popup.zIndex()` | Get the next z-index counter value |
|
|
294
|
-
| `layerpro.popup.movable(
|
|
295
|
-
| `layerpro.popup.resizable(
|
|
311
|
+
| `layerpro.popup.movable(props)` | Enable dragging |
|
|
312
|
+
| `layerpro.popup.resizable(props)` | Enable resizing |
|
|
313
|
+
| `layerpro.popup.store(element)` | Store a reference (placeholder/extensibility) |
|
|
296
314
|
| `layerpro.popup.cleanupEvents(id)` | Remove dock/button/esc listeners |
|
|
297
315
|
| `layerpro.popup.unmount(id)` | Unmount the React root (memory cleanup) |
|
|
316
|
+
| `layerpro.noGlobals()` | Restore native `alert`/`confirm`/`prompt`; remove `message` |
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## Styling & z-index
|
|
321
|
+
|
|
322
|
+
Popup z-index starts from the `--popup-z-index` CSS variable (default `1000`).
|
|
323
|
+
Apps with their own stacking contexts (e.g. a tooltip at `z-index: 100000`) can
|
|
324
|
+
shift the whole stack by overriding the variable:
|
|
325
|
+
|
|
326
|
+
```scss
|
|
327
|
+
:root { --popup-z-index: 100000; }
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
The title bar, window surface, internal area, and body all read from CSS custom
|
|
331
|
+
properties, so theming needs no `!important` and no `[class^=popup_…]` selectors:
|
|
332
|
+
|
|
333
|
+
| Variable | Applies to |
|
|
334
|
+
|----------|-----------|
|
|
335
|
+
| `--bar-background` | title bar |
|
|
336
|
+
| `--bar-selected-background` | active/selected title bar |
|
|
337
|
+
| `--bar-color` | title bar text |
|
|
338
|
+
| `--window-background` | popup surface |
|
|
339
|
+
| `--window-shadow` | popup shadow |
|
|
340
|
+
| `--window-border-radius` | popup border radius |
|
|
341
|
+
| `--internal-background` | body wrapper |
|
|
342
|
+
| `--body-color` | body text color |
|
|
343
|
+
| `--raised-background` | modal overlay |
|
|
344
|
+
| `--popup-z-index` (in root.scss) | base z-index for the stack |
|
|
345
|
+
|
|
346
|
+
Stable class names (`.popup_bar`, `.popup_window`, `.popup_overflow`,
|
|
347
|
+
`.popup_internal`, `.popup_body`, `.popup_drag`, `.popup_icon`, `.popup_option`,
|
|
348
|
+
`.popup_raised`) are emitted alongside the per-id classes so themes can target
|
|
349
|
+
elements without attribute selectors.
|
|
298
350
|
|
|
299
351
|
---
|
|
300
352
|
|
package/package.json
CHANGED
package/types/layerpro.d.ts
CHANGED
|
@@ -4,16 +4,21 @@
|
|
|
4
4
|
/// <reference types="react" />
|
|
5
5
|
|
|
6
6
|
/** Generate custom alert using alert([text]) */
|
|
7
|
-
declare function alert(f1?: string):
|
|
7
|
+
declare function alert(f1?: string): void
|
|
8
8
|
|
|
9
|
-
/** Generate custom confirm using confirm([text],[callback for YES],[optional callback for NO])
|
|
10
|
-
|
|
9
|
+
/** Generate custom confirm using confirm([text],[callback for YES],[optional callback for NO])
|
|
10
|
+
* WARNING: This overrides the native confirm(). The return value is NOT a usable
|
|
11
|
+
* boolean — callbacks are invoked asynchronously instead. Never rely on the
|
|
12
|
+
* return value; use the yes/no callbacks. */
|
|
13
|
+
declare function confirm(message: string, func1: (yes: boolean) => void, func2?: (no: boolean) => void): void
|
|
11
14
|
|
|
12
15
|
/** Generate custom message using message([text],[callback]) and option callback */
|
|
13
|
-
declare function message(f1?: string, func1?:
|
|
16
|
+
declare function message(f1?: string, func1?: () => void): void
|
|
14
17
|
|
|
15
|
-
/** Generate custom
|
|
16
|
-
|
|
18
|
+
/** Generate custom prompt using prompt([text],[callback]) and option callback
|
|
19
|
+
* WARNING: This overrides the native prompt(). The return value is NOT a usable
|
|
20
|
+
* string — use the callback to receive the input. */
|
|
21
|
+
declare function prompt(f1?: string, func1?: (input: string) => void): void
|
|
17
22
|
|
|
18
23
|
///
|
|
19
24
|
|
|
@@ -62,7 +67,9 @@ interface GenLayerProps {
|
|
|
62
67
|
resizable?: boolean
|
|
63
68
|
close?: boolean
|
|
64
69
|
raised?: boolean
|
|
70
|
+
modal?: boolean
|
|
65
71
|
iconize?: boolean
|
|
72
|
+
center?: boolean
|
|
66
73
|
|
|
67
74
|
source?: string
|
|
68
75
|
store?: any
|
|
@@ -77,26 +84,29 @@ interface _layerpro {
|
|
|
77
84
|
[key: string]: any
|
|
78
85
|
|
|
79
86
|
readonly alert: (txt: string) => void
|
|
80
|
-
readonly prompt: (txt: string, callback: (input: string) => void
|
|
87
|
+
readonly prompt: (txt: string, callback: (input: string) => void) => void
|
|
81
88
|
readonly message: (txt: string, callback: () => void) => void
|
|
82
|
-
readonly confirm: (txt: string, yesCallback: () => void, noCallback
|
|
89
|
+
readonly confirm: (txt: string, yesCallback: () => void, noCallback?: () => void) => void
|
|
83
90
|
readonly credits: (txt: string) => void
|
|
84
91
|
|
|
85
|
-
setProps: (obj, options
|
|
92
|
+
setProps: (obj: Record<string, unknown>, options?: { enumerable?: boolean, writable?: boolean }) => void
|
|
93
|
+
|
|
94
|
+
/** Remove the global alert/confirm/prompt/message overrides and restore
|
|
95
|
+
* the native browser implementations. Call this right after importing
|
|
96
|
+
* LayerPro if your codebase depends on synchronous native globals. */
|
|
97
|
+
readonly noGlobals: () => void
|
|
86
98
|
|
|
87
99
|
readonly popup: {
|
|
88
100
|
open: (props: GenLayerProps) => GenLayerProps
|
|
89
|
-
center: (
|
|
90
|
-
maximize: (props:
|
|
91
|
-
iconize: (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
zIndex: (props?: any) => number
|
|
99
|
-
close: (props: any) => any
|
|
101
|
+
center: (id: string | number | GenLayerProps, offset?: number) => void
|
|
102
|
+
maximize: (props: GenLayerProps) => void
|
|
103
|
+
iconize: (id: string | number | GenLayerProps) => void
|
|
104
|
+
movable: (props: GenLayerProps) => void
|
|
105
|
+
resizable: (props: GenLayerProps) => void
|
|
106
|
+
store: (element: unknown) => void
|
|
107
|
+
index: (id: string | number | GenLayerProps) => void
|
|
108
|
+
zIndex: (props?: GenLayerProps) => number
|
|
109
|
+
close: (id: string | number | GenLayerProps) => void
|
|
100
110
|
// React root management for memory cleanup
|
|
101
111
|
unmount: (id: string) => void
|
|
102
112
|
getReactRoot: (id: string) => any
|
|
@@ -106,12 +116,13 @@ interface _layerpro {
|
|
|
106
116
|
|
|
107
117
|
}
|
|
108
118
|
|
|
119
|
+
/**
|
|
120
|
+
* LayerPro overrides the native alert/confirm/prompt globals and adds a
|
|
121
|
+
* `message` global. They are callback-based and do NOT return native values.
|
|
122
|
+
* Call `layerpro.noGlobals()` to restore the synchronous natives.
|
|
123
|
+
*/
|
|
109
124
|
interface Window {
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
interface globalThis {
|
|
114
|
-
[key: string]: any
|
|
125
|
+
layerpro: _layerpro
|
|
115
126
|
}
|
|
116
127
|
|
|
117
128
|
declare var layerpro: _layerpro
|