@preact/signals-devtools-ui 0.1.0 → 0.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/CHANGELOG.md +19 -0
- package/README.md +3 -0
- package/dist/devtools-ui.js +1 -1
- package/dist/devtools-ui.js.map +1 -1
- package/dist/devtools-ui.min.js +1 -1
- package/dist/devtools-ui.min.js.map +1 -1
- package/dist/devtools-ui.mjs +1 -1
- package/dist/devtools-ui.mjs.map +1 -1
- package/dist/devtools-ui.module.js +1 -1
- package/dist/devtools-ui.module.js.map +1 -1
- package/package.json +8 -9
- package/src/components/Button.tsx +9 -2
- package/src/components/Header.tsx +2 -5
- package/src/components/SettingsPanel.tsx +32 -6
- package/src/context.ts +1 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@preact/signals-devtools-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "DevTools UI components for @preact/signals",
|
|
6
6
|
"keywords": [
|
|
@@ -44,21 +44,20 @@
|
|
|
44
44
|
"README.md"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@preact/signals-devtools-adapter": "0.
|
|
47
|
+
"@preact/signals-devtools-adapter": "0.2.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@types/node": "^
|
|
51
|
-
"@vitest/browser": "^
|
|
50
|
+
"@types/node": "^20.0.0",
|
|
51
|
+
"@vitest/browser": "^4.0.0",
|
|
52
52
|
"playwright": "^1.53.1",
|
|
53
53
|
"preact": "^10.26.9",
|
|
54
54
|
"typescript": "~5.8.3",
|
|
55
|
-
"vite": "^
|
|
56
|
-
"vitest": "^
|
|
57
|
-
"@preact/signals": "2.6.
|
|
55
|
+
"vite": "^7.0.0",
|
|
56
|
+
"vitest": "^4.0.17",
|
|
57
|
+
"@preact/signals": "2.6.1"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
|
-
"
|
|
61
|
-
"provenance": false
|
|
60
|
+
"provenance": true
|
|
62
61
|
},
|
|
63
62
|
"scripts": {
|
|
64
63
|
"test": "vitest run"
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ComponentChildren } from "preact";
|
|
2
2
|
|
|
3
3
|
interface ButtonProps {
|
|
4
|
-
onClick
|
|
4
|
+
onClick?: () => void;
|
|
5
5
|
className?: string;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
children: ComponentChildren;
|
|
8
8
|
variant?: "primary" | "secondary";
|
|
9
|
+
popovertarget?: string;
|
|
9
10
|
active?: boolean;
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -15,6 +16,7 @@ export function Button({
|
|
|
15
16
|
disabled = false,
|
|
16
17
|
children,
|
|
17
18
|
variant = "secondary",
|
|
19
|
+
popovertarget,
|
|
18
20
|
active = false,
|
|
19
21
|
}: ButtonProps) {
|
|
20
22
|
const baseClass = "btn";
|
|
@@ -24,7 +26,12 @@ export function Button({
|
|
|
24
26
|
`${baseClass} ${variantClass} ${activeClass} ${className}`.trim();
|
|
25
27
|
|
|
26
28
|
return (
|
|
27
|
-
<button
|
|
29
|
+
<button
|
|
30
|
+
popovertarget={popovertarget}
|
|
31
|
+
onClick={onClick}
|
|
32
|
+
className={combinedClassName}
|
|
33
|
+
disabled={disabled}
|
|
34
|
+
>
|
|
28
35
|
{children}
|
|
29
36
|
</button>
|
|
30
37
|
);
|
|
@@ -3,9 +3,8 @@ import { Button } from "./Button";
|
|
|
3
3
|
import { getContext } from "../context";
|
|
4
4
|
|
|
5
5
|
export function Header() {
|
|
6
|
-
const { connectionStore, updatesStore
|
|
6
|
+
const { connectionStore, updatesStore } = getContext();
|
|
7
7
|
|
|
8
|
-
const onToggleSettings = settingsStore.toggleSettings;
|
|
9
8
|
const onTogglePause = () => {
|
|
10
9
|
updatesStore.isPaused.value = !updatesStore.isPaused.value;
|
|
11
10
|
};
|
|
@@ -30,9 +29,7 @@ export function Header() {
|
|
|
30
29
|
{updatesStore.isPaused.value ? "Resume" : "Pause"}
|
|
31
30
|
</Button>
|
|
32
31
|
)}
|
|
33
|
-
|
|
34
|
-
<Button onClick={onToggleSettings}>Settings</Button>
|
|
35
|
-
)}
|
|
32
|
+
<Button popovertarget="settings-panel-popover">Settings</Button>
|
|
36
33
|
</div>
|
|
37
34
|
</header>
|
|
38
35
|
);
|
|
@@ -2,14 +2,14 @@ import { useSignal, useSignalEffect } from "@preact/signals";
|
|
|
2
2
|
import { Button } from "./Button";
|
|
3
3
|
import type { Settings } from "@preact/signals-devtools-adapter";
|
|
4
4
|
import { getContext } from "../context";
|
|
5
|
+
import { useRef } from "preact/hooks";
|
|
5
6
|
|
|
6
7
|
export function SettingsPanel() {
|
|
7
8
|
const { settingsStore } = getContext();
|
|
9
|
+
const popover = useRef<HTMLDivElement>(null);
|
|
8
10
|
|
|
9
|
-
const onCancel = settingsStore.hideSettings;
|
|
10
11
|
const onApply = settingsStore.applySettings;
|
|
11
12
|
const settings = settingsStore.settings;
|
|
12
|
-
const isVisible = settingsStore.showSettings;
|
|
13
13
|
|
|
14
14
|
const localSettings = useSignal<Settings>(settings);
|
|
15
15
|
|
|
@@ -21,12 +21,18 @@ export function SettingsPanel() {
|
|
|
21
21
|
onApply(localSettings.value);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const onCancel = () => {
|
|
25
|
+
// @ts-expect-error
|
|
26
|
+
popover.current?.hide();
|
|
27
|
+
};
|
|
27
28
|
|
|
28
29
|
return (
|
|
29
|
-
<div
|
|
30
|
+
<div
|
|
31
|
+
ref={popover}
|
|
32
|
+
popover="auto"
|
|
33
|
+
id="settings-panel-popover"
|
|
34
|
+
className="settings-panel"
|
|
35
|
+
>
|
|
30
36
|
<div className="settings-content">
|
|
31
37
|
<h3>Debug Configuration</h3>
|
|
32
38
|
|
|
@@ -62,6 +68,26 @@ export function SettingsPanel() {
|
|
|
62
68
|
</label>
|
|
63
69
|
</div>
|
|
64
70
|
|
|
71
|
+
<div className="setting-group">
|
|
72
|
+
<label>
|
|
73
|
+
<input
|
|
74
|
+
type="checkbox"
|
|
75
|
+
checked={localSettings.value.consoleLogging}
|
|
76
|
+
onChange={e =>
|
|
77
|
+
(localSettings.value = {
|
|
78
|
+
...localSettings.value,
|
|
79
|
+
consoleLogging: (e.target as HTMLInputElement).checked,
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
/>
|
|
83
|
+
Enable console logging
|
|
84
|
+
</label>
|
|
85
|
+
<p className="setting-description">
|
|
86
|
+
When disabled, signal updates will not be logged to the browser
|
|
87
|
+
console.
|
|
88
|
+
</p>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
65
91
|
<div className="setting-group">
|
|
66
92
|
<label htmlFor="maxUpdatesInput">Max updates per second:</label>
|
|
67
93
|
<input
|
package/src/context.ts
CHANGED
|
@@ -284,25 +284,16 @@ export function createSettingsStore(adapter: DevToolsAdapter) {
|
|
|
284
284
|
const settings = signal<Settings>({
|
|
285
285
|
enabled: true,
|
|
286
286
|
grouped: true,
|
|
287
|
+
consoleLogging: true,
|
|
287
288
|
maxUpdatesPerSecond: 60,
|
|
288
289
|
filterPatterns: [],
|
|
289
290
|
});
|
|
290
291
|
|
|
291
|
-
const showSettings = signal<boolean>(false);
|
|
292
292
|
const showDisposedSignals = signal<boolean>(false);
|
|
293
293
|
|
|
294
294
|
const applySettings = (newSettings: Settings) => {
|
|
295
295
|
settings.value = newSettings;
|
|
296
296
|
adapter.sendConfig(newSettings);
|
|
297
|
-
showSettings.value = false;
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
const toggleSettings = () => {
|
|
301
|
-
showSettings.value = !showSettings.value;
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
const hideSettings = () => {
|
|
305
|
-
showSettings.value = false;
|
|
306
297
|
};
|
|
307
298
|
|
|
308
299
|
const toggleShowDisposedSignals = () => {
|
|
@@ -320,9 +311,6 @@ export function createSettingsStore(adapter: DevToolsAdapter) {
|
|
|
320
311
|
get settings() {
|
|
321
312
|
return settings.value;
|
|
322
313
|
},
|
|
323
|
-
get showSettings() {
|
|
324
|
-
return showSettings.value;
|
|
325
|
-
},
|
|
326
314
|
get showDisposedSignals() {
|
|
327
315
|
return showDisposedSignals.value;
|
|
328
316
|
},
|
|
@@ -330,8 +318,6 @@ export function createSettingsStore(adapter: DevToolsAdapter) {
|
|
|
330
318
|
settings.value = newSettings;
|
|
331
319
|
},
|
|
332
320
|
applySettings,
|
|
333
|
-
toggleSettings,
|
|
334
|
-
hideSettings,
|
|
335
321
|
toggleShowDisposedSignals,
|
|
336
322
|
};
|
|
337
323
|
}
|