mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-12 00:15:48 +01:00
Add options to sort and resize graphs in dash. widget
This commit is contained in:
@@ -3,7 +3,7 @@ import React from 'react';
|
||||
import { AreaType } from '../types/area';
|
||||
import { ShapeType } from '../types/shape';
|
||||
|
||||
// Type of widgets which are safed to config
|
||||
// Type of widgets which are saved to config
|
||||
export type IWidget<TKey extends string, TDefinition extends IWidgetDefinition> = {
|
||||
id: TKey;
|
||||
properties: {
|
||||
@@ -18,15 +18,7 @@ export type IWidget<TKey extends string, TDefinition extends IWidgetDefinition>
|
||||
// Makes the type less specific
|
||||
// For example when the type true is used as input the result is boolean
|
||||
// By not using this type the definition would always be { property: true }
|
||||
type MakeLessSpecific<TInput extends IWidgetOptionValue['defaultValue']> = TInput extends boolean
|
||||
? boolean
|
||||
: TInput extends number
|
||||
? number
|
||||
: TInput extends string[]
|
||||
? string[]
|
||||
: TInput extends string
|
||||
? string
|
||||
: never;
|
||||
type MakeLessSpecific<T> = T extends boolean ? boolean : T;
|
||||
|
||||
// Types of options that can be specified for the widget edit modal
|
||||
export type IWidgetOptionValue =
|
||||
@@ -35,7 +27,8 @@ export type IWidgetOptionValue =
|
||||
| ITextInputOptionValue
|
||||
| ISliderInputOptionValue
|
||||
| ISelectOptionValue
|
||||
| INumberInputOptionValue;
|
||||
| INumberInputOptionValue
|
||||
| IDraggableListInputValue;
|
||||
|
||||
// Interface for data type
|
||||
interface DataType {
|
||||
@@ -84,6 +77,18 @@ export type ISliderInputOptionValue = {
|
||||
step: number;
|
||||
};
|
||||
|
||||
export type IDraggableListInputValue = {
|
||||
type: 'draggable-list';
|
||||
defaultValue: {
|
||||
key: string;
|
||||
subValues?: Record<string, any>;
|
||||
}[];
|
||||
items: Record<
|
||||
string,
|
||||
Record<string, Omit<Exclude<IWidgetOptionValue, IDraggableListInputValue>, 'defaultValue'>>
|
||||
>;
|
||||
};
|
||||
|
||||
// is used to type the widget definitions which will be used to display all widgets
|
||||
export type IWidgetDefinition<TKey extends string = string> = {
|
||||
id: TKey;
|
||||
|
||||
Reference in New Issue
Block a user