@preact/signals-devtools-ui 0.1.0 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@preact/signals-devtools-ui",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "license": "MIT",
5
5
  "description": "DevTools UI components for @preact/signals",
6
6
  "keywords": [
@@ -57,8 +57,7 @@
57
57
  "@preact/signals": "2.6.0"
58
58
  },
59
59
  "publishConfig": {
60
- "access": "public",
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: () => void;
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 onClick={onClick} className={combinedClassName} disabled={disabled}>
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, settingsStore } = getContext();
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
- {onToggleSettings && (
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
- if (!isVisible) {
25
- return null;
26
- }
24
+ const onCancel = () => {
25
+ // @ts-expect-error
26
+ popover.current?.hide();
27
+ };
27
28
 
28
29
  return (
29
- <div className="settings-panel">
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
 
package/src/context.ts CHANGED
@@ -288,21 +288,11 @@ export function createSettingsStore(adapter: DevToolsAdapter) {
288
288
  filterPatterns: [],
289
289
  });
290
290
 
291
- const showSettings = signal<boolean>(false);
292
291
  const showDisposedSignals = signal<boolean>(false);
293
292
 
294
293
  const applySettings = (newSettings: Settings) => {
295
294
  settings.value = newSettings;
296
295
  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
296
  };
307
297
 
308
298
  const toggleShowDisposedSignals = () => {
@@ -320,9 +310,6 @@ export function createSettingsStore(adapter: DevToolsAdapter) {
320
310
  get settings() {
321
311
  return settings.value;
322
312
  },
323
- get showSettings() {
324
- return showSettings.value;
325
- },
326
313
  get showDisposedSignals() {
327
314
  return showDisposedSignals.value;
328
315
  },
@@ -330,8 +317,6 @@ export function createSettingsStore(adapter: DevToolsAdapter) {
330
317
  settings.value = newSettings;
331
318
  },
332
319
  applySettings,
333
- toggleSettings,
334
- hideSettings,
335
320
  toggleShowDisposedSignals,
336
321
  };
337
322
  }