Skip to content

Commit

Permalink
extend rxwidgetstate in single widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
foxriver76 committed Mar 12, 2024
1 parent 4932592 commit 753bff7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/src/Vis/Widgets/Basic/BasicSpeechToText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import type {
import { I18n } from '@iobroker/adapter-react-v5';
// @ts-expect-error fix import
import type * as SpeechRecognition from 'dom-speech-recognition';
import type { VisBaseWidgetState } from '@/Vis/visBaseWidget';

// eslint-disable-next-line no-use-before-define
type RxData = GetRxDataFromWidget<typeof BasicSpeechToText>

interface BasicSpeechToTextState {
interface BasicSpeechToTextState extends VisBaseWidgetState {
/** Current shown module text */
text: string;
/** Current shown image */
Expand Down
2 changes: 1 addition & 1 deletion src/src/Vis/visBaseWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ interface VisBaseWidget {
renderLastChange(style: unknown): React.ReactNode;
}

class VisBaseWidget<TState extends VisBaseWidgetState = VisBaseWidgetState> extends React.Component<VisBaseWidgetProps, TState & VisBaseWidgetState> {
class VisBaseWidget<TState extends Partial<VisBaseWidgetState> = VisBaseWidgetState> extends React.Component<VisBaseWidgetProps, TState & VisBaseWidgetState> {
static FORBIDDEN_CHARS = /[^._\-/ :!#$%&()+=@^{}|~]+/g; // from https://github.com/ioBroker/ioBroker.js-controller/blob/master/packages/common/lib/common/tools.js

/** We do not store the SVG Element in the state because it is cyclic */
Expand Down
2 changes: 1 addition & 1 deletion src/src/Vis/visRxWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ interface VisRxWidgetState extends VisBaseWidgetState {
disabled?: boolean;
}

class VisRxWidget<TRxData extends Record<string, any>, TState extends VisRxWidgetState = VisRxWidgetState> extends VisBaseWidget<VisRxWidgetState & TState & { rxData: TRxData }> {
class VisRxWidget<TRxData extends Record<string, any>, TState extends Partial<VisRxWidgetState> = VisRxWidgetState> extends VisBaseWidget<VisRxWidgetState & TState & { rxData: TRxData }> {
static POSSIBLE_MUI_STYLES = POSSIBLE_MUI_STYLES;

static i18nPrefix: string | undefined;
Expand Down

0 comments on commit 753bff7

Please sign in to comment.