import { createReducer } from "utils/AppsmithUtils"; import { ReduxActionTypes, ReduxAction } from "constants/ReduxActionConstants"; import { WidgetProps } from "widgets/BaseWidget"; import WidgetConfigResponse from "mockResponses/WidgetConfigResponse"; import { ButtonWidgetProps } from "widgets/ButtonWidget"; import { TextWidgetProps } from "widgets/TextWidget"; import { ContainerWidgetProps } from "widgets/ContainerWidget"; import { ImageWidgetProps } from "widgets/ImageWidget"; import { InputWidgetProps } from "widgets/InputWidget"; import { RichTextEditorWidgetProps } from "widgets/RichTextEditorWidget"; import { DatePickerWidgetProps } from "widgets/DatePickerWidget"; import { DatePickerWidget2Props } from "widgets/DatePickerWidget2"; import { TableWidgetProps } from "widgets/TableWidget/TableWidgetConstants"; import { DropdownWidgetProps } from "widgets/DropdownWidget"; import { CheckboxWidgetProps } from "widgets/CheckboxWidget"; import { RadioGroupWidgetProps } from "widgets/RadioGroupWidget"; import { FilePickerWidgetProps } from "widgets/FilepickerWidget"; import { FilePickerWidgetV2Props } from "widgets/FilepickerWidgetV2"; import { TabsWidgetProps, TabContainerWidgetProps, } from "widgets/Tabs/TabsWidget"; import { ChartWidgetProps } from "widgets/ChartWidget"; import { FormWidgetProps } from "widgets/FormWidget"; import { FormButtonWidgetProps } from "widgets/FormButtonWidget"; import { MapWidgetProps } from "widgets/MapWidget"; import { ModalWidgetProps } from "widgets/ModalWidget"; import { IconWidgetProps } from "widgets/IconWidget"; import { VideoWidgetProps } from "widgets/VideoWidget"; import { SkeletonWidgetProps } from "widgets/SkeletonWidget"; import { SwitchWidgetProps } from "widgets/SwitchWidget"; import { ListWidgetProps } from "widgets/ListWidget/ListWidget"; import { MultiSelectWidgetProps } from "widgets/MultiSelectWidget"; import { DividerWidgetProps } from "widgets/DividerWidget"; import { RateWidgetProps } from "widgets/RateWidget"; import { IframeWidgetProps } from "widgets/IframeWidget"; import { MenuButtonWidgetProps } from "widgets/MenuButtonWidget"; import { IconButtonWidgetProps } from "widgets/IconButtonWidget"; import { StatboxWidgetProps } from "widgets/StatboxWidget"; import { CheckboxGroupWidgetProps } from "widgets/CheckboxGroupWidget"; import { AudioRecorderWidgetProps } from "widgets/AudioRecorderWidget"; const initialState: WidgetConfigReducerState = WidgetConfigResponse; export type WidgetBlueprint = { view?: Array<{ type: string; size?: { rows: number; cols: number }; position: { top?: number; left?: number }; props: Record; }>; operations?: any; }; export interface WidgetConfigProps { rows: number; columns: number; blueprint?: WidgetBlueprint; widgetName: string; } export interface WidgetConfigReducerState { config: { BUTTON_WIDGET: Partial & WidgetConfigProps; TEXT_WIDGET: Partial & WidgetConfigProps; IMAGE_WIDGET: Partial & WidgetConfigProps; INPUT_WIDGET: Partial & WidgetConfigProps; RICH_TEXT_EDITOR_WIDGET: Partial & WidgetConfigProps; CONTAINER_WIDGET: Partial> & WidgetConfigProps; DATE_PICKER_WIDGET: Partial & WidgetConfigProps; DATE_PICKER_WIDGET2: Partial & WidgetConfigProps; TABLE_WIDGET: Partial & WidgetConfigProps; VIDEO_WIDGET: Partial & WidgetConfigProps; DROP_DOWN_WIDGET: Partial & WidgetConfigProps; MULTI_SELECT_WIDGET: Partial & WidgetConfigProps; CHECKBOX_WIDGET: Partial & WidgetConfigProps; SWITCH_WIDGET: Partial & WidgetConfigProps; RADIO_GROUP_WIDGET: Partial & WidgetConfigProps; FILE_PICKER_WIDGET: Partial & WidgetConfigProps; FILE_PICKER_WIDGET_V2: Partial & WidgetConfigProps; TABS_WIDGET: Partial> & WidgetConfigProps; TABS_MIGRATOR_WIDGET: Partial> & WidgetConfigProps; MODAL_WIDGET: Partial & WidgetConfigProps; CHART_WIDGET: Partial & WidgetConfigProps; FORM_WIDGET: Partial & WidgetConfigProps; FORM_BUTTON_WIDGET: Partial & WidgetConfigProps; MAP_WIDGET: Partial & WidgetConfigProps; CANVAS_WIDGET: Partial> & WidgetConfigProps; ICON_WIDGET: Partial & WidgetConfigProps; SKELETON_WIDGET: Partial & WidgetConfigProps; LIST_WIDGET: Partial> & WidgetConfigProps; DIVIDER_WIDGET: Partial & WidgetConfigProps; RATE_WIDGET: Partial & WidgetConfigProps; IFRAME_WIDGET: Partial & WidgetConfigProps; MENU_BUTTON_WIDGET: Partial & WidgetConfigProps; ICON_BUTTON_WIDGET: Partial & WidgetConfigProps; STATBOX_WIDGET: Partial & WidgetConfigProps; CHECKBOX_GROUP_WIDGET: Partial & WidgetConfigProps; AUDIO_RECORDER_WIDGET: Partial & WidgetConfigProps; }; configVersion: number; } const widgetConfigReducer = createReducer(initialState, { [ReduxActionTypes.LOAD_WIDGET_CONFIG]: ( state: WidgetConfigReducerState, action: ReduxAction, ) => { return { ...action.payload }; }, }); export default widgetConfigReducer;