{"version":3,"file":"OptionsUIRegistryBuilder.cjs","sources":["../../../src/types/OptionsUIRegistryBuilder.ts"],"sourcesContent":["import { ComponentType } from 'react';\n\nimport {\n  NumberFieldConfigSettings,\n  SelectFieldConfigSettings,\n  SliderFieldConfigSettings,\n  StringFieldConfigSettings,\n} from '../field/overrides/processors';\nimport { RegistryItem, Registry } from '../utils/Registry';\n\nimport { OptionEditorConfig } from './options';\n\n/**\n * Option editor registry item\n */\nexport interface OptionsEditorItem<TOptions, TSettings, TEditorProps, TValue>\n  extends RegistryItem,\n    OptionEditorConfig<TOptions, TSettings, TValue> {\n  /**\n   * React component used to edit the options property\n   */\n  editor: ComponentType<TEditorProps>;\n\n  /*\n   * @param value\n   */\n  getItemsCount?: (value?: TValue) => number;\n}\n\n/**\n * Describes an API for option editors UI builder\n */\ninterface OptionsUIRegistryBuilderAPI<\n  TOptions,\n  TEditorProps,\n  T extends OptionsEditorItem<TOptions, any, TEditorProps, any>,\n> {\n  addNumberInput?<TSettings extends NumberFieldConfigSettings = NumberFieldConfigSettings>(\n    config: OptionEditorConfig<TOptions, TSettings, number>\n  ): this;\n\n  addSliderInput?<TSettings extends SliderFieldConfigSettings = SliderFieldConfigSettings>(\n    config: OptionEditorConfig<TOptions, TSettings, number>\n  ): this;\n\n  addTextInput?<TSettings extends StringFieldConfigSettings = StringFieldConfigSettings>(\n    config: OptionEditorConfig<TOptions, TSettings, string>\n  ): this;\n\n  addStringArray?<TSettings extends StringFieldConfigSettings = StringFieldConfigSettings>(\n    config: OptionEditorConfig<TOptions, TSettings, string[]>\n  ): this;\n\n  addSelect?<TOption, TSettings extends SelectFieldConfigSettings<TOption>>(\n    config: OptionEditorConfig<TOptions, TSettings, TOption>\n  ): this;\n\n  addRadio?<TOption, TSettings extends SelectFieldConfigSettings<TOption> = SelectFieldConfigSettings<TOption>>(\n    config: OptionEditorConfig<TOptions, TSettings, TOption>\n  ): this;\n\n  addBooleanSwitch?<TSettings>(config: OptionEditorConfig<TOptions, TSettings, boolean>): this;\n\n  addUnitPicker?<TSettings>(config: OptionEditorConfig<TOptions, TSettings, string>): this;\n\n  addColorPicker?<TSettings>(config: OptionEditorConfig<TOptions, TSettings, string>): this;\n\n  /**\n   * Enables custom editor definition\n   * @param config\n   */\n  addCustomEditor<TSettings, TValue>(config: OptionsEditorItem<TOptions, TSettings, TEditorProps, TValue>): this;\n\n  /**\n   * Returns registry of option editors\n   */\n  getRegistry: () => Registry<T>;\n}\n\nexport abstract class OptionsUIRegistryBuilder<\n  TOptions,\n  TEditorProps,\n  T extends OptionsEditorItem<TOptions, any, TEditorProps, any>,\n> implements OptionsUIRegistryBuilderAPI<TOptions, TEditorProps, T>\n{\n  private properties: T[] = [];\n\n  addCustomEditor<TSettings, TValue>(config: T & OptionsEditorItem<TOptions, TSettings, TEditorProps, TValue>): this {\n    this.properties.push(config);\n    return this;\n  }\n\n  getRegistry() {\n    return new Registry(() => {\n      return this.properties;\n    });\n  }\n\n  getItems() {\n    return this.properties;\n  }\n}\n"],"names":["Registry"],"mappings":";;;;;;;AA+EO,MAAe,wBAAA,CAKtB;AAAA,EALO,WAAA,GAAA;AAML,IAAA,IAAA,CAAQ,aAAkB,EAAC;AAAA,EAAA;AAAA,EAE3B,gBAAmC,MAAA,EAAgF;AACjH,IAAA,IAAA,CAAK,UAAA,CAAW,KAAK,MAAM,CAAA;AAC3B,IAAA,OAAO,IAAA;AAAA,EACT;AAAA,EAEA,WAAA,GAAc;AACZ,IAAA,OAAO,IAAIA,kBAAS,MAAM;AACxB,MAAA,OAAO,IAAA,CAAK,UAAA;AAAA,IACd,CAAC,CAAA;AAAA,EACH;AAAA,EAEA,QAAA,GAAW;AACT,IAAA,OAAO,IAAA,CAAK,UAAA;AAAA,EACd;AACF;;;;"}