Skip to content

Commit c6deafc

Browse files
committed
Convert React to TypeScript
1 parent 36ce681 commit c6deafc

File tree

7 files changed

+261
-212
lines changed

7 files changed

+261
-212
lines changed

src-editor/package.json

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,38 @@
55
"dependencies": {
66
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
77
"@craco/craco": "^7.1.0",
8+
"@devbookhq/splitter": "^1.4.2",
89
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
9-
"@icons/material": "^0.4.1",
10-
"@iobroker/adapter-react-v5": "^7.2.3",
10+
"@iobroker/adapter-react-v5": "^7.3.1",
1111
"@iobroker/type-detector": "^4.0.1",
12-
"@mui/icons-material": "^6.1.2",
13-
"@devbookhq/splitter": "^1.4.2",
14-
"@mui/material": "^6.1.2",
15-
"@mui/x-date-pickers": "^7.19.0",
16-
"@sentry/browser": "^8.33.1",
12+
"@mui/icons-material": "^6.1.7",
13+
"@mui/material": "^6.1.7",
14+
"@mui/x-date-pickers": "^7.22.2",
15+
"@sentry/browser": "^8.38.0",
1716
"craco-module-federation": "^1.1.0",
1817
"lodash": "^4.17.21",
1918
"monaco-editor": "~0.52.0",
20-
"openai": "^4.67.1",
19+
"openai": "^4.72.0",
2120
"react": "^18.3.1",
22-
"react-ace": "^12.0.0",
21+
"react-ace": "^13.0.0",
2322
"react-bem-helper": "^1.4.1",
2423
"react-dnd": "^16.0.1",
2524
"react-dnd-html5-backend": "^16.0.1",
2625
"react-dnd-touch-backend": "^16.0.1",
2726
"react-dom": "^18.3.1",
28-
"react-dropzone": "^14.2.9",
27+
"react-dropzone": "^14.3.5",
2928
"react-fullscreen": "^0.1.0",
30-
"react-i18next": "^15.0.2",
29+
"react-i18next": "^15.1.1",
3130
"react-icons": "^5.3.0",
32-
"react-inlinesvg": "^4.1.3",
31+
"react-inlinesvg": "^4.1.5",
3332
"react-json-view": "^1.21.3",
3433
"react-monaco-editor": "^0.56.2",
3534
"react-scripts": "^5.0.1",
3635
"react-splitter-layout": "^4.0.0",
3736
"react-text-mask": "^5.5.0",
3837
"react-treeview-mui": "^0.1.2",
3938
"reactour": "^1.19.4",
40-
"sass": "^1.79.4",
39+
"sass": "^1.81.0",
4140
"styled-components": "^6.1.13",
4241
"suncalc2": "^1.8.1"
4342
},

src-editor/src/Dialogs/AddNewScript.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import ImgJS from '../assets/tileJS.png';
2121
import ImgTS from '../assets/tileTS.png';
2222
import ImgBlockly from '../assets/tileBlockly.png';
2323
import ImgRules from '../assets/tileRules.png';
24+
import {ScriptType} from "@/types";
2425

2526
const styles: Record<string, React.CSSProperties> = {
2627
card: {
@@ -44,7 +45,7 @@ const styles: Record<string, React.CSSProperties> = {
4445
};
4546

4647
interface DialogAddNewProps {
47-
onClose: (type?: 'TypeScript/ts' | 'Javascript/js' | 'Blockly' | 'Rules') => void;
48+
onClose: (type?: ScriptType) => void;
4849
}
4950

5051
class DialogAddNew extends React.Component<DialogAddNewProps> {

src-editor/src/Dialogs/New.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ import {
1616
import { Check as IconOk, Cancel as IconCancel } from '@mui/icons-material';
1717

1818
import { I18n } from '@iobroker/adapter-react-v5';
19+
import type { ScriptType } from '@/types';
1920

2021
interface DialogNewProps {
2122
onClose: () => void;
22-
onAdd: (id: string, name: string, instance: number, type: string) => void;
23+
onAdd: (id: string, name: string, instance?: number, type?: ScriptType) => void;
2324
name: string;
2425
title: string;
2526
parent: string;
26-
instance: number;
27-
instances: number[];
27+
instance?: number;
28+
instances?: number[];
2829
parents: { id: string; name: string }[];
29-
existingItems: string[];
30-
folder: boolean;
31-
type: string;
32-
source: string;
30+
existingItems?: string[];
31+
folder?: boolean;
32+
type?: ScriptType;
3333
}
3434

3535
interface DialogNewState {
@@ -189,7 +189,7 @@ class DialogNew extends React.Component<DialogNewProps, DialogNewState> {
189189
onChange={e => this.setState({ instance: parseInt(e.target.value as string, 10) })}
190190
inputProps={{ name: 'instance', id: 'instance' }}
191191
>
192-
{this.props.instances.map(instance => (
192+
{this.props.instances?.map(instance => (
193193
<MenuItem
194194
key={`instance${instance}`}
195195
value={instance}

src-editor/src/Dialogs/Rename.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ import { I18n } from '@iobroker/adapter-react-v5';
1919

2020
interface DialogRenameProps {
2121
onClose: () => void;
22-
onRename: (oldId: string, newId: string, newName: string, instance: number) => void;
22+
onRename: (oldId: string, newId: string, newName: string, instance: number | null) => void;
2323
name: string;
2424
id: string;
25-
instance: number;
25+
instance: number | null;
2626
instances: number[];
2727
folder: boolean;
2828
}
2929

3030
interface DialogRenameState {
3131
name: string;
3232
id: string;
33-
instance: number;
33+
instance: number | null;
3434
prefix: string;
3535
}
3636

0 commit comments

Comments
 (0)