updates types

This commit is contained in:
Mose Müller 2024-02-20 16:38:44 +01:00
parent f0384b817c
commit 1c029e301b
4 changed files with 11 additions and 16 deletions

View File

@ -8,9 +8,9 @@ import {
LevelName
} from './components/NotificationsComponent';
import { ConnectionToast } from './components/ConnectionToast';
import { SerializedValue, setNestedValueByPath, State } from './utils/stateUtils';
import { setNestedValueByPath, State } from './utils/stateUtils';
import { WebSettingsContext, WebSetting } from './WebSettings';
import { Attribute, GenericComponent } from './components/GenericComponent';
import { SerializedValue, GenericComponent } from './components/GenericComponent';
type Action =
| { type: 'SET_DATA'; data: State }
@ -187,7 +187,7 @@ const App = () => {
<GenericComponent
name=""
parentPath=""
attribute={state as Attribute}
attribute={state as SerializedValue}
isInstantUpdate={isInstantUpdate}
addNotification={addNotification}
/>

View File

@ -28,8 +28,8 @@ type AttributeType =
| 'Image'
| 'ColouredEnum';
type ValueType = boolean | string | number | object;
export type Attribute = {
type ValueType = boolean | string | number | Record<string, unknown>;
export type SerializedValue = {
type: AttributeType;
value?: ValueType | ValueType[];
readonly: boolean;
@ -39,7 +39,7 @@ export type Attribute = {
enum?: Record<string, string>;
};
type GenericComponentProps = {
attribute: Attribute;
attribute: SerializedValue;
name: string;
parentPath: string;
isInstantUpdate: boolean;
@ -177,7 +177,7 @@ export const GenericComponent = React.memo(
return (
<ListComponent
name={name}
value={attribute.value as Attribute[]}
value={attribute.value as SerializedValue[]}
docString={attribute.doc}
parentPath={parentPath}
isInstantUpdate={isInstantUpdate}

View File

@ -5,11 +5,12 @@ import { Button, InputGroup, Form, Collapse } from 'react-bootstrap';
import { DocStringComponent } from './DocStringComponent';
import { getIdFromFullAccessPath } from '../utils/stringUtils';
import { LevelName } from './NotificationsComponent';
import { GenericComponent, SerializedValue } from './GenericComponent';
type MethodProps = {
name: string;
parentPath: string;
parameters: Record<string, string>;
parameters: Record<string, SerializedValue>;
docString?: string;
hideOutput?: boolean;
addNotification: (message: string, levelname?: LevelName) => void;

View File

@ -1,11 +1,5 @@
export interface SerializedValue {
type: string;
value: Record<string, unknown> | Array<Record<string, unknown>>;
readonly: boolean;
doc: string | null;
async?: boolean;
parameters?: unknown;
}
import { SerializedValue } from '../components/GenericComponent';
export type State = {
type: string;
value: Record<string, SerializedValue> | null;