config.ts 1.01 KB
import { cloneDeep } from 'lodash-es'
import { VariableImageConfig } from '.'
import { ModeEnum } from '@/enums/modeEnum'
import type { ConfigPresetOptionsType, CreateComponentParamsType, CreateComponentType } from '@/core/Library/types'
export const options: ConfigPresetOptionsType = {
  publicFormSetting: {
    dataSourceSetting: false,
    eventSetting: true,
    actSetting: {
      FLASH: true,
      DISPLAY: true,
      ROTATE: true,
      VARIABLE_IMAGE: true,
    },
  },
}

export default class Config implements CreateComponentType {
  public key: string = VariableImageConfig.key

  public presetOption = cloneDeep(options)

  public mode = ModeEnum.EDIT

  public category = VariableImageConfig.category

  constructor(params: CreateComponentParamsType = {} as CreateComponentParamsType) {
    type Keys = keyof CreateComponentParamsType
    const keys = Object.keys(params) as Keys[]

    for (const key of keys)
      ((this as CreateComponentParamsType)[key] as CreateComponentParamsType[typeof key]) = params[key]
  }
}