mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-21 00:40:01 +02:00
Merge pull request #137 from tiqi-group/chore/update_eslint
chore: update eslint config
This commit is contained in:
commit
b83e241b32
@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"root": true,
|
|
||||||
"parser": "@typescript-eslint/parser",
|
|
||||||
"plugins": [
|
|
||||||
"@typescript-eslint",
|
|
||||||
"prettier"
|
|
||||||
],
|
|
||||||
"extends": [
|
|
||||||
"eslint:recommended",
|
|
||||||
"plugin:@typescript-eslint/recommended",
|
|
||||||
"prettier",
|
|
||||||
"plugin:react/recommended"
|
|
||||||
],
|
|
||||||
"rules": {
|
|
||||||
"prettier/prettier": "error",
|
|
||||||
"react/react-in-jsx-scope": "off",
|
|
||||||
"react/prop-types": "off"
|
|
||||||
}
|
|
||||||
}
|
|
21
frontend/eslint.config.js
Normal file
21
frontend/eslint.config.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import eslint from "@eslint/js";
|
||||||
|
import tseslint from "typescript-eslint";
|
||||||
|
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
|
||||||
|
import reactRecommended from "eslint-plugin-react/configs/recommended.js";
|
||||||
|
|
||||||
|
export default [
|
||||||
|
eslint.configs.recommended,
|
||||||
|
...tseslint.configs.recommended,
|
||||||
|
...tseslint.configs.stylistic,
|
||||||
|
{
|
||||||
|
files: ["**/*.{js,jsx,ts,tsx}"],
|
||||||
|
...reactRecommended,
|
||||||
|
rules: {
|
||||||
|
"prettier/prettier": "error",
|
||||||
|
"react/react-in-jsx-scope": "off",
|
||||||
|
"react/prop-types": "off",
|
||||||
|
"@typescript-eslint/no-empty-function": "off",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
eslintPluginPrettierRecommended,
|
||||||
|
];
|
1718
frontend/package-lock.json
generated
1718
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc -b && vite build --emptyOutDir",
|
"build": "tsc -b && vite build --emptyOutDir",
|
||||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -19,16 +19,21 @@
|
|||||||
"socket.io-client": "^4.7.1"
|
"socket.io-client": "^4.7.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^9.6.0",
|
||||||
|
"@types/eslint__js": "^8.42.3",
|
||||||
|
"@types/node": "^20.14.10",
|
||||||
"@types/react": "^18.3.3",
|
"@types/react": "^18.3.3",
|
||||||
"@types/react-dom": "^18.3.0",
|
"@types/react-dom": "^18.3.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.13.1",
|
"@typescript-eslint/eslint-plugin": "^7.13.1",
|
||||||
"@typescript-eslint/parser": "^7.13.1",
|
"@typescript-eslint/parser": "^7.13.1",
|
||||||
"@vitejs/plugin-react-swc": "^3.5.0",
|
"@vitejs/plugin-react-swc": "^3.5.0",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-config-prettier": "^9.0.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-prettier": "^5.0.1",
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
"prettier": "^3.0.3",
|
"eslint-plugin-react": "^7.34.3",
|
||||||
"typescript": "^5.2.2",
|
"prettier": "3.3.2",
|
||||||
|
"typescript": "^5.5.3",
|
||||||
|
"typescript-eslint": "^7.15.0",
|
||||||
"vite": "^5.3.1"
|
"vite": "^5.3.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,13 @@ type Action =
|
|||||||
fullAccessPath: string;
|
fullAccessPath: string;
|
||||||
newValue: SerializedObject;
|
newValue: SerializedObject;
|
||||||
};
|
};
|
||||||
type UpdateMessage = {
|
interface UpdateMessage {
|
||||||
data: { full_access_path: string; value: SerializedObject };
|
data: { full_access_path: string; value: SerializedObject };
|
||||||
};
|
}
|
||||||
type LogMessage = {
|
interface LogMessage {
|
||||||
levelname: LevelName;
|
levelname: LevelName;
|
||||||
message: string;
|
message: string;
|
||||||
};
|
}
|
||||||
|
|
||||||
const reducer = (state: State | null, action: Action): State | null => {
|
const reducer = (state: State | null, action: Action): State | null => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
@ -2,8 +2,8 @@ import { createContext } from "react";
|
|||||||
|
|
||||||
export const WebSettingsContext = createContext<Record<string, WebSetting>>({});
|
export const WebSettingsContext = createContext<Record<string, WebSetting>>({});
|
||||||
|
|
||||||
export type WebSetting = {
|
export interface WebSetting {
|
||||||
displayName: string;
|
displayName: string;
|
||||||
display: boolean;
|
display: boolean;
|
||||||
index: number;
|
index: number;
|
||||||
};
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { Form, Button, InputGroup, Spinner } from "react-bootstrap";
|
|||||||
import { DocStringComponent } from "./DocStringComponent";
|
import { DocStringComponent } from "./DocStringComponent";
|
||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
|
|
||||||
type AsyncMethodProps = {
|
interface AsyncMethodProps {
|
||||||
fullAccessPath: string;
|
fullAccessPath: string;
|
||||||
value: "RUNNING" | null;
|
value: "RUNNING" | null;
|
||||||
docString: string | null;
|
docString: string | null;
|
||||||
@ -13,7 +13,7 @@ type AsyncMethodProps = {
|
|||||||
displayName: string;
|
displayName: string;
|
||||||
id: string;
|
id: string;
|
||||||
render: boolean;
|
render: boolean;
|
||||||
};
|
}
|
||||||
|
|
||||||
export const AsyncMethodComponent = React.memo((props: AsyncMethodProps) => {
|
export const AsyncMethodComponent = React.memo((props: AsyncMethodProps) => {
|
||||||
const {
|
const {
|
||||||
|
@ -4,7 +4,7 @@ import { DocStringComponent } from "./DocStringComponent";
|
|||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
import { SerializedObject } from "../types/SerializedObject";
|
import { SerializedObject } from "../types/SerializedObject";
|
||||||
|
|
||||||
type ButtonComponentProps = {
|
interface ButtonComponentProps {
|
||||||
fullAccessPath: string;
|
fullAccessPath: string;
|
||||||
value: boolean;
|
value: boolean;
|
||||||
readOnly: boolean;
|
readOnly: boolean;
|
||||||
@ -14,7 +14,7 @@ type ButtonComponentProps = {
|
|||||||
changeCallback?: (value: SerializedObject, callback?: (ack: unknown) => void) => void;
|
changeCallback?: (value: SerializedObject, callback?: (ack: unknown) => void) => void;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
id: string;
|
id: string;
|
||||||
};
|
}
|
||||||
|
|
||||||
export const ButtonComponent = React.memo((props: ButtonComponentProps) => {
|
export const ButtonComponent = React.memo((props: ButtonComponentProps) => {
|
||||||
const {
|
const {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Toast, Button, ToastContainer } from "react-bootstrap";
|
import { Toast, Button, ToastContainer } from "react-bootstrap";
|
||||||
|
|
||||||
type ConnectionToastProps = {
|
interface ConnectionToastProps {
|
||||||
connectionStatus: string;
|
connectionStatus: string;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ConnectionToast Component
|
* ConnectionToast Component
|
||||||
|
@ -6,13 +6,13 @@ import { GenericComponent } from "./GenericComponent";
|
|||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
import { SerializedObject } from "../types/SerializedObject";
|
import { SerializedObject } from "../types/SerializedObject";
|
||||||
|
|
||||||
type DataServiceProps = {
|
interface DataServiceProps {
|
||||||
props: DataServiceJSON;
|
props: DataServiceJSON;
|
||||||
isInstantUpdate: boolean;
|
isInstantUpdate: boolean;
|
||||||
addNotification: (message: string, levelname?: LevelName) => void;
|
addNotification: (message: string, levelname?: LevelName) => void;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
id: string;
|
id: string;
|
||||||
};
|
}
|
||||||
|
|
||||||
export type DataServiceJSON = Record<string, SerializedObject>;
|
export type DataServiceJSON = Record<string, SerializedObject>;
|
||||||
|
|
||||||
|
@ -3,14 +3,14 @@ import { LevelName } from "./NotificationsComponent";
|
|||||||
import { DataServiceComponent, DataServiceJSON } from "./DataServiceComponent";
|
import { DataServiceComponent, DataServiceJSON } from "./DataServiceComponent";
|
||||||
import { MethodComponent } from "./MethodComponent";
|
import { MethodComponent } from "./MethodComponent";
|
||||||
|
|
||||||
type DeviceConnectionProps = {
|
interface DeviceConnectionProps {
|
||||||
fullAccessPath: string;
|
fullAccessPath: string;
|
||||||
props: DataServiceJSON;
|
props: DataServiceJSON;
|
||||||
isInstantUpdate: boolean;
|
isInstantUpdate: boolean;
|
||||||
addNotification: (message: string, levelname?: LevelName) => void;
|
addNotification: (message: string, levelname?: LevelName) => void;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
id: string;
|
id: string;
|
||||||
};
|
}
|
||||||
|
|
||||||
export const DeviceConnectionComponent = React.memo(
|
export const DeviceConnectionComponent = React.memo(
|
||||||
({
|
({
|
||||||
|
@ -4,13 +4,13 @@ import { GenericComponent } from "./GenericComponent";
|
|||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
import { SerializedObject } from "../types/SerializedObject";
|
import { SerializedObject } from "../types/SerializedObject";
|
||||||
|
|
||||||
type DictComponentProps = {
|
interface DictComponentProps {
|
||||||
value: Record<string, SerializedObject>;
|
value: Record<string, SerializedObject>;
|
||||||
docString: string | null;
|
docString: string | null;
|
||||||
isInstantUpdate: boolean;
|
isInstantUpdate: boolean;
|
||||||
addNotification: (message: string, levelname?: LevelName) => void;
|
addNotification: (message: string, levelname?: LevelName) => void;
|
||||||
id: string;
|
id: string;
|
||||||
};
|
}
|
||||||
|
|
||||||
export const DictComponent = React.memo((props: DictComponentProps) => {
|
export const DictComponent = React.memo((props: DictComponentProps) => {
|
||||||
const { value, docString, isInstantUpdate, addNotification, id } = props;
|
const { value, docString, isInstantUpdate, addNotification, id } = props;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { Badge, Tooltip, OverlayTrigger } from "react-bootstrap";
|
import { Badge, Tooltip, OverlayTrigger } from "react-bootstrap";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
type DocStringProps = {
|
interface DocStringProps {
|
||||||
docString?: string | null;
|
docString?: string | null;
|
||||||
};
|
}
|
||||||
|
|
||||||
export const DocStringComponent = React.memo((props: DocStringProps) => {
|
export const DocStringComponent = React.memo((props: DocStringProps) => {
|
||||||
const { docString } = props;
|
const { docString } = props;
|
||||||
|
@ -4,7 +4,7 @@ import { DocStringComponent } from "./DocStringComponent";
|
|||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
import { SerializedObject } from "../types/SerializedObject";
|
import { SerializedObject } from "../types/SerializedObject";
|
||||||
|
|
||||||
export type EnumSerialization = {
|
export interface EnumSerialization {
|
||||||
type: "Enum" | "ColouredEnum";
|
type: "Enum" | "ColouredEnum";
|
||||||
full_access_path: string;
|
full_access_path: string;
|
||||||
name: string;
|
name: string;
|
||||||
@ -12,15 +12,15 @@ export type EnumSerialization = {
|
|||||||
readonly: boolean;
|
readonly: boolean;
|
||||||
doc: string | null;
|
doc: string | null;
|
||||||
enum: Record<string, string>;
|
enum: Record<string, string>;
|
||||||
};
|
}
|
||||||
|
|
||||||
type EnumComponentProps = {
|
interface EnumComponentProps {
|
||||||
attribute: EnumSerialization;
|
attribute: EnumSerialization;
|
||||||
addNotification: (message: string, levelname?: LevelName) => void;
|
addNotification: (message: string, levelname?: LevelName) => void;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
id: string;
|
id: string;
|
||||||
changeCallback?: (value: SerializedObject, callback?: (ack: unknown) => void) => void;
|
changeCallback?: (value: SerializedObject, callback?: (ack: unknown) => void) => void;
|
||||||
};
|
}
|
||||||
|
|
||||||
export const EnumComponent = React.memo((props: EnumComponentProps) => {
|
export const EnumComponent = React.memo((props: EnumComponentProps) => {
|
||||||
const { attribute, addNotification, displayName, id } = props;
|
const { attribute, addNotification, displayName, id } = props;
|
||||||
|
@ -18,11 +18,11 @@ import { DictComponent } from "./DictComponent";
|
|||||||
import { parseFullAccessPath } from "../utils/stateUtils";
|
import { parseFullAccessPath } from "../utils/stateUtils";
|
||||||
import { SerializedObject } from "../types/SerializedObject";
|
import { SerializedObject } from "../types/SerializedObject";
|
||||||
|
|
||||||
type GenericComponentProps = {
|
interface GenericComponentProps {
|
||||||
attribute: SerializedObject;
|
attribute: SerializedObject;
|
||||||
isInstantUpdate: boolean;
|
isInstantUpdate: boolean;
|
||||||
addNotification: (message: string, levelname?: LevelName) => void;
|
addNotification: (message: string, levelname?: LevelName) => void;
|
||||||
};
|
}
|
||||||
|
|
||||||
const getPathFromPathParts = (pathParts: string[]): string => {
|
const getPathFromPathParts = (pathParts: string[]): string => {
|
||||||
let path = "";
|
let path = "";
|
||||||
|
@ -4,7 +4,7 @@ import { DocStringComponent } from "./DocStringComponent";
|
|||||||
import { ChevronDown, ChevronRight } from "react-bootstrap-icons";
|
import { ChevronDown, ChevronRight } from "react-bootstrap-icons";
|
||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
|
|
||||||
type ImageComponentProps = {
|
interface ImageComponentProps {
|
||||||
fullAccessPath: string;
|
fullAccessPath: string;
|
||||||
value: string;
|
value: string;
|
||||||
docString: string | null;
|
docString: string | null;
|
||||||
@ -12,7 +12,7 @@ type ImageComponentProps = {
|
|||||||
addNotification: (message: string, levelname?: LevelName) => void;
|
addNotification: (message: string, levelname?: LevelName) => void;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
id: string;
|
id: string;
|
||||||
};
|
}
|
||||||
|
|
||||||
export const ImageComponent = React.memo((props: ImageComponentProps) => {
|
export const ImageComponent = React.memo((props: ImageComponentProps) => {
|
||||||
const { fullAccessPath, value, docString, format, addNotification, displayName, id } =
|
const { fullAccessPath, value, docString, format, addNotification, displayName, id } =
|
||||||
|
@ -4,13 +4,13 @@ import { GenericComponent } from "./GenericComponent";
|
|||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
import { SerializedObject } from "../types/SerializedObject";
|
import { SerializedObject } from "../types/SerializedObject";
|
||||||
|
|
||||||
type ListComponentProps = {
|
interface ListComponentProps {
|
||||||
value: SerializedObject[];
|
value: SerializedObject[];
|
||||||
docString: string | null;
|
docString: string | null;
|
||||||
isInstantUpdate: boolean;
|
isInstantUpdate: boolean;
|
||||||
addNotification: (message: string, levelname?: LevelName) => void;
|
addNotification: (message: string, levelname?: LevelName) => void;
|
||||||
id: string;
|
id: string;
|
||||||
};
|
}
|
||||||
|
|
||||||
export const ListComponent = React.memo((props: ListComponentProps) => {
|
export const ListComponent = React.memo((props: ListComponentProps) => {
|
||||||
const { value, docString, isInstantUpdate, addNotification, id } = props;
|
const { value, docString, isInstantUpdate, addNotification, id } = props;
|
||||||
|
@ -4,14 +4,14 @@ import { Button, Form } from "react-bootstrap";
|
|||||||
import { DocStringComponent } from "./DocStringComponent";
|
import { DocStringComponent } from "./DocStringComponent";
|
||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
|
|
||||||
type MethodProps = {
|
interface MethodProps {
|
||||||
fullAccessPath: string;
|
fullAccessPath: string;
|
||||||
docString: string | null;
|
docString: string | null;
|
||||||
addNotification: (message: string, levelname?: LevelName) => void;
|
addNotification: (message: string, levelname?: LevelName) => void;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
id: string;
|
id: string;
|
||||||
render: boolean;
|
render: boolean;
|
||||||
};
|
}
|
||||||
|
|
||||||
export const MethodComponent = React.memo((props: MethodProps) => {
|
export const MethodComponent = React.memo((props: MethodProps) => {
|
||||||
const { fullAccessPath, docString, addNotification, displayName, id } = props;
|
const { fullAccessPath, docString, addNotification, displayName, id } = props;
|
||||||
|
@ -2,18 +2,18 @@ import React from "react";
|
|||||||
import { ToastContainer, Toast } from "react-bootstrap";
|
import { ToastContainer, Toast } from "react-bootstrap";
|
||||||
|
|
||||||
export type LevelName = "CRITICAL" | "ERROR" | "WARNING" | "INFO" | "DEBUG";
|
export type LevelName = "CRITICAL" | "ERROR" | "WARNING" | "INFO" | "DEBUG";
|
||||||
export type Notification = {
|
export interface Notification {
|
||||||
id: number;
|
id: number;
|
||||||
timeStamp: string;
|
timeStamp: string;
|
||||||
message: string;
|
message: string;
|
||||||
levelname: LevelName;
|
levelname: LevelName;
|
||||||
};
|
}
|
||||||
|
|
||||||
type NotificationProps = {
|
interface NotificationProps {
|
||||||
showNotification: boolean;
|
showNotification: boolean;
|
||||||
notifications: Notification[];
|
notifications: Notification[];
|
||||||
removeNotificationById: (id: number) => void;
|
removeNotificationById: (id: number) => void;
|
||||||
};
|
}
|
||||||
|
|
||||||
export const Notifications = React.memo((props: NotificationProps) => {
|
export const Notifications = React.memo((props: NotificationProps) => {
|
||||||
const { showNotification, notifications, removeNotificationById } = props;
|
const { showNotification, notifications, removeNotificationById } = props;
|
||||||
|
@ -8,27 +8,27 @@ import { QuantityMap } from "../types/QuantityMap";
|
|||||||
|
|
||||||
// TODO: add button functionality
|
// TODO: add button functionality
|
||||||
|
|
||||||
export type QuantityObject = {
|
export interface QuantityObject {
|
||||||
type: "Quantity";
|
type: "Quantity";
|
||||||
readonly: boolean;
|
readonly: boolean;
|
||||||
value: QuantityMap;
|
value: QuantityMap;
|
||||||
doc: string | null;
|
doc: string | null;
|
||||||
};
|
}
|
||||||
export type IntObject = {
|
export interface IntObject {
|
||||||
type: "int";
|
type: "int";
|
||||||
readonly: boolean;
|
readonly: boolean;
|
||||||
value: number;
|
value: number;
|
||||||
doc: string | null;
|
doc: string | null;
|
||||||
};
|
}
|
||||||
export type FloatObject = {
|
export interface FloatObject {
|
||||||
type: "float";
|
type: "float";
|
||||||
readonly: boolean;
|
readonly: boolean;
|
||||||
value: number;
|
value: number;
|
||||||
doc: string | null;
|
doc: string | null;
|
||||||
};
|
}
|
||||||
export type NumberObject = IntObject | FloatObject | QuantityObject;
|
export type NumberObject = IntObject | FloatObject | QuantityObject;
|
||||||
|
|
||||||
type NumberComponentProps = {
|
interface NumberComponentProps {
|
||||||
type: "float" | "int" | "Quantity";
|
type: "float" | "int" | "Quantity";
|
||||||
fullAccessPath: string;
|
fullAccessPath: string;
|
||||||
value: number;
|
value: number;
|
||||||
@ -40,7 +40,7 @@ type NumberComponentProps = {
|
|||||||
changeCallback?: (value: SerializedObject, callback?: (ack: unknown) => void) => void;
|
changeCallback?: (value: SerializedObject, callback?: (ack: unknown) => void) => void;
|
||||||
displayName?: string;
|
displayName?: string;
|
||||||
id: string;
|
id: string;
|
||||||
};
|
}
|
||||||
|
|
||||||
// TODO: highlight the digit that is being changed by setting both selectionStart and
|
// TODO: highlight the digit that is being changed by setting both selectionStart and
|
||||||
// selectionEnd
|
// selectionEnd
|
||||||
|
@ -7,7 +7,7 @@ import { LevelName } from "./NotificationsComponent";
|
|||||||
import { SerializedObject } from "../types/SerializedObject";
|
import { SerializedObject } from "../types/SerializedObject";
|
||||||
import { QuantityMap } from "../types/QuantityMap";
|
import { QuantityMap } from "../types/QuantityMap";
|
||||||
|
|
||||||
type SliderComponentProps = {
|
interface SliderComponentProps {
|
||||||
fullAccessPath: string;
|
fullAccessPath: string;
|
||||||
min: NumberObject;
|
min: NumberObject;
|
||||||
max: NumberObject;
|
max: NumberObject;
|
||||||
@ -20,7 +20,7 @@ type SliderComponentProps = {
|
|||||||
changeCallback?: (value: SerializedObject, callback?: (ack: unknown) => void) => void;
|
changeCallback?: (value: SerializedObject, callback?: (ack: unknown) => void) => void;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
id: string;
|
id: string;
|
||||||
};
|
}
|
||||||
|
|
||||||
export const SliderComponent = React.memo((props: SliderComponentProps) => {
|
export const SliderComponent = React.memo((props: SliderComponentProps) => {
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRef(0);
|
||||||
@ -122,7 +122,7 @@ export const SliderComponent = React.memo((props: SliderComponentProps) => {
|
|||||||
const deconstructNumberDict = (
|
const deconstructNumberDict = (
|
||||||
numberDict: NumberObject,
|
numberDict: NumberObject,
|
||||||
): [number, boolean, string | undefined] => {
|
): [number, boolean, string | undefined] => {
|
||||||
let numberMagnitude: number = 0;
|
let numberMagnitude = 0;
|
||||||
let numberUnit: string | undefined = undefined;
|
let numberUnit: string | undefined = undefined;
|
||||||
const numberReadOnly = numberDict.readonly;
|
const numberReadOnly = numberDict.readonly;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import { SerializedObject } from "../types/SerializedObject";
|
|||||||
|
|
||||||
// TODO: add button functionality
|
// TODO: add button functionality
|
||||||
|
|
||||||
type StringComponentProps = {
|
interface StringComponentProps {
|
||||||
fullAccessPath: string;
|
fullAccessPath: string;
|
||||||
value: string;
|
value: string;
|
||||||
readOnly: boolean;
|
readOnly: boolean;
|
||||||
@ -17,7 +17,7 @@ type StringComponentProps = {
|
|||||||
changeCallback?: (value: SerializedObject, callback?: (ack: unknown) => void) => void;
|
changeCallback?: (value: SerializedObject, callback?: (ack: unknown) => void) => void;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
id: string;
|
id: string;
|
||||||
};
|
}
|
||||||
|
|
||||||
export const StringComponent = React.memo((props: StringComponentProps) => {
|
export const StringComponent = React.memo((props: StringComponentProps) => {
|
||||||
const {
|
const {
|
||||||
|
@ -9,5 +9,5 @@ import "bootstrap/dist/css/bootstrap.min.css";
|
|||||||
ReactDOM.createRoot(document.getElementById("root")!).render(
|
ReactDOM.createRoot(document.getElementById("root")!).render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<App />
|
<App />
|
||||||
</React.StrictMode>
|
</React.StrictMode>,
|
||||||
);
|
);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export type QuantityMap = {
|
export interface QuantityMap {
|
||||||
magnitude: number;
|
magnitude: number;
|
||||||
unit: string;
|
unit: string;
|
||||||
};
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import { QuantityMap } from "./QuantityMap";
|
import { QuantityMap } from "./QuantityMap";
|
||||||
|
|
||||||
type SignatureDict = {
|
interface SignatureDict {
|
||||||
parameters: Record<string, Record<string, unknown>>;
|
parameters: Record<string, Record<string, unknown>>;
|
||||||
return_annotation: Record<string, unknown>;
|
return_annotation: Record<string, unknown>;
|
||||||
};
|
}
|
||||||
|
|
||||||
type SerializedObjectBase = {
|
interface SerializedObjectBase {
|
||||||
full_access_path: string;
|
full_access_path: string;
|
||||||
doc: string | null;
|
doc: string | null;
|
||||||
readonly: boolean;
|
readonly: boolean;
|
||||||
};
|
}
|
||||||
|
|
||||||
type SerializedInteger = SerializedObjectBase & {
|
type SerializedInteger = SerializedObjectBase & {
|
||||||
value: number;
|
value: number;
|
||||||
|
@ -41,7 +41,7 @@ const serializePrimitive = (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const serializeList = (obj: unknown[], accessPath: string = "") => {
|
export const serializeList = (obj: unknown[], accessPath = "") => {
|
||||||
const doc = null;
|
const doc = null;
|
||||||
const value = obj.map((item, index) => {
|
const value = obj.map((item, index) => {
|
||||||
if (
|
if (
|
||||||
@ -65,10 +65,7 @@ export const serializeList = (obj: unknown[], accessPath: string = "") => {
|
|||||||
doc,
|
doc,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
export const serializeDict = (
|
export const serializeDict = (obj: Record<string, unknown>, accessPath = "") => {
|
||||||
obj: Record<string, unknown>,
|
|
||||||
accessPath: string = "",
|
|
||||||
) => {
|
|
||||||
const doc = null;
|
const doc = null;
|
||||||
const value = Object.entries(obj).reduce(
|
const value = Object.entries(obj).reduce(
|
||||||
(acc, [key, val]) => {
|
(acc, [key, val]) => {
|
||||||
@ -87,7 +84,7 @@ export const serializeDict = (
|
|||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
<Record<string, SerializedObject>>{},
|
{} as Record<string, SerializedObject>,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { SerializedObject } from "../types/SerializedObject";
|
import { SerializedObject } from "../types/SerializedObject";
|
||||||
|
|
||||||
export type State = {
|
export interface State {
|
||||||
type: string;
|
type: string;
|
||||||
name: string;
|
name: string;
|
||||||
value: Record<string, SerializedObject> | null;
|
value: Record<string, SerializedObject> | null;
|
||||||
readonly: boolean;
|
readonly: boolean;
|
||||||
doc: string | null;
|
doc: string | null;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Splits a full access path into its atomic parts, separating attribute names, numeric
|
* Splits a full access path into its atomic parts, separating attribute names, numeric
|
||||||
@ -110,7 +110,7 @@ function getOrCreateItemInContainer(
|
|||||||
function getContainerItemByKey(
|
function getContainerItemByKey(
|
||||||
container: Record<string, SerializedObject> | SerializedObject[],
|
container: Record<string, SerializedObject> | SerializedObject[],
|
||||||
key: string,
|
key: string,
|
||||||
allowAppend: boolean = false,
|
allowAppend = false,
|
||||||
): SerializedObject {
|
): SerializedObject {
|
||||||
const processedKey = parseSerializedKey(key);
|
const processedKey = parseSerializedKey(key);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user