Add options to sort and resize graphs in dash. widget

This commit is contained in:
MauriceNino
2023-02-10 18:20:28 +01:00
parent bb010ff54a
commit a05e80bf26
11 changed files with 436 additions and 220 deletions

View File

@@ -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;