layerpro 3.1.1 → 3.2.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/FUNDING.yml +12 -0
- package/README.md +35 -3
- package/index.cjs +329 -302
- package/index.css +2 -1
- package/index.js +329 -304
- package/package.json +40 -12
- package/react.cjs +404 -0
- package/react.js +400 -0
- package/types/layerpro.d.ts +133 -132
package/FUNDING.yml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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/README.md
CHANGED
|
@@ -33,7 +33,7 @@ No more ugly popup boxes. No more blocking the main thread. Just clean, modern m
|
|
|
33
33
|
|
|
34
34
|
## Features
|
|
35
35
|
|
|
36
|
-
- **Zero runtime dependencies**: no jQuery — pure vanilla DOM helpers;
|
|
36
|
+
- **Zero runtime dependencies**: no jQuery — pure vanilla DOM helpers; `react`/`react-dom` are peer dependencies (only loaded when React bodies are used, powered by [`reattach`](https://npmjs.com/package/reattach))
|
|
37
37
|
- **Multiple modal types**: alert, confirm, prompt, message
|
|
38
38
|
- **Fully customizable**: appearance, behavior, and content
|
|
39
39
|
- **Dockable windows (taskbar style)**: click a dock icon to restore, focus, or minimize — just like an OS taskbar
|
|
@@ -131,7 +131,10 @@ popup.open({
|
|
|
131
131
|
|
|
132
132
|
### React Components
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
LayerPro's React adapter is powered by [`reattach`](https://npmjs.com/package/reattach) — a
|
|
135
|
+
zero-dependency library for mounting React components anywhere in the DOM. reattach handles
|
|
136
|
+
root creation, automatic root reuse on duplicate-id reopen, **Context Bridging** across
|
|
137
|
+
detached roots, and **Auto-healing DOM** recovery — all without you lifting a finger.
|
|
135
138
|
|
|
136
139
|
```jsx
|
|
137
140
|
popup.open({
|
|
@@ -143,6 +146,31 @@ popup.open({
|
|
|
143
146
|
});
|
|
144
147
|
```
|
|
145
148
|
|
|
149
|
+
#### Advanced Options (React)
|
|
150
|
+
|
|
151
|
+
| Prop | Type | Default | Description |
|
|
152
|
+
|------|------|---------|-------------|
|
|
153
|
+
| `inheritContext` | `boolean` | `false` | Replays captured host React Context into the popup's root. Use `captureContext()` in your app to capture contexts, then set `inheritContext: true` on the popup. |
|
|
154
|
+
| `resilient` | `boolean` | `false` | Enables a `MutationObserver` that auto-heals the React mount container if external DOM mutations (htmx, jQuery, CMS AJAX) remove or replace it. |
|
|
155
|
+
|
|
156
|
+
```jsx
|
|
157
|
+
// Host app: capture context
|
|
158
|
+
import { captureContext } from 'reattach'
|
|
159
|
+
function App() {
|
|
160
|
+
const theme = useContext(ThemeContext)
|
|
161
|
+
captureContext(ThemeContext, theme)
|
|
162
|
+
return <Toolbar />
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Popup: inherit host context
|
|
166
|
+
popup.open({
|
|
167
|
+
id: 'contextual',
|
|
168
|
+
body: <ThemedWidget />,
|
|
169
|
+
inheritContext: true, // ContextBridge: ThèmeContext is bridged
|
|
170
|
+
resilient: true, // Auto-heals if the container is replaced
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
146
174
|
### The `body` Parameter
|
|
147
175
|
|
|
148
176
|
The `body` property accepts different content types:
|
|
@@ -178,6 +206,10 @@ The `body` property accepts different content types:
|
|
|
178
206
|
// Remote content (same-origin only for security)
|
|
179
207
|
source: string, // URL to fetch HTML content from (same-origin enforced)
|
|
180
208
|
|
|
209
|
+
// React adapter (via reattach)
|
|
210
|
+
inheritContext: boolean, // reattach Context Bridge — replay host React Context into the popup root
|
|
211
|
+
resilient: boolean, // reattach Auto-healing DOM — MutationObserver recovery from external DOM mutations
|
|
212
|
+
|
|
181
213
|
// Position (numbers are px; strings applied as-is, e.g. "10%")
|
|
182
214
|
top: number | string,
|
|
183
215
|
left: number | string,
|
|
@@ -320,7 +352,7 @@ LayerPro includes several security measures:
|
|
|
320
352
|
|
|
321
353
|
- **HTML escaping**: All user-provided text content (button labels, body content, titles) is automatically escaped via `escapeHtml()` to prevent XSS. HTML entities like `<`, `>`, `&`, `"` are converted to their safe equivalents.
|
|
322
354
|
|
|
323
|
-
- **Content Security Policy friendly**: No inline scripts or `eval()` are used. React components are rendered via `createRoot()` with proper sanitization.
|
|
355
|
+
- **Content Security Policy friendly**: No inline scripts or `eval()` are used. React components are rendered via `reattach.mount()` (backed by `createRoot()`) with proper sanitization.
|
|
324
356
|
|
|
325
357
|
- **No global pollution option**: Call `layerpro.noGlobals()` after import to restore native `alert`, `confirm`, `prompt` and remove the `message` global if your codebase depends on synchronous return values.
|
|
326
358
|
|