summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/ArrowButton.tsx4
-rw-r--r--src/components/Button.tsx2
-rw-r--r--src/components/Header.tsx4
-rw-r--r--src/components/TextInput.tsx4
-rw-r--r--src/components/index.ts35
-rw-r--r--src/components/nodes/Input.tsx5
-rw-r--r--src/components/nodes/Socket.tsx2
-rw-r--r--src/components/nodes/index.ts9
8 files changed, 42 insertions, 23 deletions
diff --git a/src/components/ArrowButton.tsx b/src/components/ArrowButton.tsx
index ce0c898..a95964e 100644
--- a/src/components/ArrowButton.tsx
+++ b/src/components/ArrowButton.tsx
@@ -1,7 +1,9 @@
import Button, { ButtonProps } from './Button.tsx';
import './ArrowButton.css';
-const ArrowButton = ({ children, ...props }: ButtonProps) => {
+export type ArrowButtonProps = ButtonProps;
+
+const ArrowButton = ({ children, ...props }: ArrowButtonProps) => {
return (
<Button {...props} class={(props.class || '') + ' __ArrowButton'}>
{children}
diff --git a/src/components/Button.tsx b/src/components/Button.tsx
index 60f42c7..8f094ce 100644
--- a/src/components/Button.tsx
+++ b/src/components/Button.tsx
@@ -4,7 +4,7 @@ import './Button.css';
export interface ButtonProps {
children: ComponentChildren;
kind?: 'primary' | 'outline' | 'ghost';
- props: Record<string, any>;
+ [prop: string]: any;
}
const Button = ({ children, kind = 'primary', ...props }: ButtonProps) => {
diff --git a/src/components/Header.tsx b/src/components/Header.tsx
index 95d5fef..a3b344d 100644
--- a/src/components/Header.tsx
+++ b/src/components/Header.tsx
@@ -5,13 +5,13 @@ import './Header.css';
export interface HeaderProps {
children: ComponentChildren;
class?: string;
- title: string;
+ title?: string;
}
const Header = ({ children, title, ...props }: HeaderProps) => {
return (
<header class={(props.class || '') + ' __Header'}>
- {title && <Button kind="ghost" class="title" href="/">{title}</Button>}
+ {!!title && <Button kind="ghost" class="title" href="/">{title}</Button>}
<nav>
{children}
</nav>
diff --git a/src/components/TextInput.tsx b/src/components/TextInput.tsx
index 026b062..c74828d 100644
--- a/src/components/TextInput.tsx
+++ b/src/components/TextInput.tsx
@@ -4,12 +4,12 @@ import './TextInput.css';
export interface TextInputProps {
signal?: Signal<string>;
- props: Record<string, any>;
+ [prop: string]: any;
}
const TextInput = ({ signal, ...props }: TextInputProps) => {
const onInputSignal = useCallback((event: InputEvent) => {
- signal.value = event.target.value;
+ if (signal) signal.value = (event.target as HTMLInputElement).value;
}, [signal]);
return (
diff --git a/src/components/index.ts b/src/components/index.ts
index c9c3625..badd32e 100644
--- a/src/components/index.ts
+++ b/src/components/index.ts
@@ -1,12 +1,25 @@
-export { default as ArrowButton } from './ArrowButton.tsx';
-export { default as Button } from './Button.tsx';
-export { default as ButtonMenu } from './ButtonMenu.tsx';
+export { default as ArrowButton } from './ArrowButton.tsx';
+export { default as Button } from './Button.tsx';
+export { default as ButtonMenu } from './ButtonMenu.tsx';
export { default as ContainedList } from './ContainedList.tsx';
-export { default as Content } from './Content.tsx';
-export { default as Form } from './Form.tsx';
-export { default as FormLabel } from './FormLabel.tsx';
-export { default as Header } from './Header.tsx';
-export { default as Menu } from './Menu.tsx';
-export { default as MenuItem } from './MenuItem.tsx';
-export { default as TextInput } from './TextInput.tsx';
-export { default as Toolbar } from './Toolbar.tsx';
+export { default as Content } from './Content.tsx';
+export { default as Form } from './Form.tsx';
+export { default as FormLabel } from './FormLabel.tsx';
+export { default as Header } from './Header.tsx';
+export { default as Menu } from './Menu.tsx';
+export { default as MenuItem } from './MenuItem.tsx';
+export { default as TextInput } from './TextInput.tsx';
+export { default as Toolbar } from './Toolbar.tsx';
+
+export type { ArrowButtonProps } from './ArrowButton.tsx';
+export type { ButtonMenuProps } from './ButtonMenu.tsx';
+export type { ButtonProps } from './Button.tsx';
+export type { ContainedListProps } from './ContainedList.tsx';
+export type { ContentProps } from './Content.tsx';
+export type { FormLabelProps } from './FormLabel.tsx';
+export type { FormProps } from './Form.tsx';
+export type { HeaderProps } from './Header.tsx';
+export type { MenuItemProps } from './MenuItem.tsx';
+export type { MenuProps } from './Menu.tsx';
+export type { TextInputProps } from './TextInput.tsx';
+export type { ToolbarProps } from './Toolbar.tsx';
diff --git a/src/components/nodes/Input.tsx b/src/components/nodes/Input.tsx
index c32b32d..4bd7751 100644
--- a/src/components/nodes/Input.tsx
+++ b/src/components/nodes/Input.tsx
@@ -1,3 +1,4 @@
+import type { ComponentChildren } from 'preact';
import { useCallback } from 'preact/hooks';
import { InputSocket } from '../../dataflow.ts';
import { InSocket } from './Socket.tsx';
@@ -37,7 +38,7 @@ export const InputArray = ({ name, label }: Omit<InputProps<any>, 'value'>) => {
);
};
-const InputNum = (parseFunc: (string) => number) => ({ name, label, value }: InputProps<number>) => {
+const InputNum = (parseFunc: (_: string) => number) => ({ name, label, value }: InputProps<number | any>) => {
const onInput = useCallback((event: InputEvent) => {
value.value = parseFunc((event.target as HTMLInputElement).value);
}, [value]);
@@ -77,7 +78,7 @@ export interface InputSelectProps extends InputProps<string> {
}
export const InputSelect = ({ name, label, value, options }: InputSelectProps) => {
- const onChange = useCallback((event: InputEvent) => {
+ const onChange = useCallback((event: Event) => {
value.value = (event.target as HTMLSelectElement).value;
}, [value]);
return (
diff --git a/src/components/nodes/Socket.tsx b/src/components/nodes/Socket.tsx
index a4f38e1..6a958c5 100644
--- a/src/components/nodes/Socket.tsx
+++ b/src/components/nodes/Socket.tsx
@@ -1,5 +1,5 @@
import { useContext } from 'preact/hooks';
-import { NodeId, SocketHandlers } from '../../node.ts';
+import { NodeId, SocketHandlers, SocketHandler } from '../../node.ts';
import './Socket.css';
interface SocketProps {
diff --git a/src/components/nodes/index.ts b/src/components/nodes/index.ts
index d29f39f..b5ca5fc 100644
--- a/src/components/nodes/index.ts
+++ b/src/components/nodes/index.ts
@@ -1,3 +1,6 @@
-export { default as NodeShell, NodeShellProps } from './NodeShell.tsx';
-export { OutputNumber, OutputVector, OutputProps } from './Output.tsx';
-export { InputAny, InputArray, InputInteger, InputNumber, InputVector, InputSelect, InputProps, InputSelectProps } from './Input.tsx';
+export { InputAny, InputArray, InputInteger, InputNumber, InputVector, InputSelect } from './Input.tsx';
+export { default as NodeShell } from './NodeShell.tsx';
+export { OutputNumber, OutputVector } from './Output.tsx';
+export type { InputProps, InputSelectProps } from './Input.tsx';
+export type { NodeShellProps } from './NodeShell.tsx';
+export type { OutputProps } from './Output.tsx';