@hmiproject/helio-sdk
    Preparing search index...

    Function Enum

    Declares a prop that can hold a value from a set of options.

    Declaring an enum property

    {
    mode: props.Enum({
    label: 'Text',
    options: [
    { value: 'on', label: 'On' },
    { value: 'off', label: 'Off' },
    ],
    defaultValue: 'on',
    optional: false,
    })
    }
    • Optional Enum Property

      Type Parameters

      • V extends string | number
      • O extends readonly OptionItem<V>[]

      Parameters

      • options: ConditionalTypeOptions & {
            description?: string;
            editor?: EnumEditor;
            label: string;
            options: O;
            propGroup?: string;
        } & { defaultValue?: OptionValueOf<O>; optional: true }
        • Optionaldescription?: string

          An optional description that will be displayed below the property in the editor to help users understand the purpose and available options of this property.

        • Optionaleditor?: EnumEditor

          Hint for which control the editor uses to display the options. Defaults to buttons for up to three options and a dropdown for more.

          Option icons are displayed for button groups and dropdowns; option tooltips only for button groups.

        • label: string

          Human-readable label for this property. Will be used to represent this property in the UI.

        • options: O

          List of enum options, either as a list of scalar values or as objects.

          EnumOptions

          Basic Options

          ['on', 'off']
          

          Custom Labels

          [
          { value: 'on', label: 'On' },
          { value: 'off', label: 'Off' },
          ]

          With Icons

          [
          { value: 'on', label: 'On', icon: { name: 'Play' } },
          { value: 'off', label: 'Off', icon: { name: 'Stop' } },
          ]

          With Tooltips (only available in button-group mode).

          [
          {
          value: 'on',
          label: 'On',
          tooltip: 'Description for On' },
          {
          value: 'off',
          label: 'Off',
          tooltip: 'Description for Off'
          },
          ]
        • OptionalpropGroup?: string

          Optionally display this prop as part of the given prop category.

        • OptionaldefaultValue?: OptionValueOf<O>

          The default value for this property.

        • optional: true

          Mark this as an optional value that can also take the value undefined.

      Returns EnumDef<V, O> & { defaultValue: OptionValueOf<O> | undefined; optional: true }

    • Non-Optional Enum Property

      Type Parameters

      • V extends string | number
      • O extends readonly OptionItem<V>[]

      Parameters

      • options: ConditionalTypeOptions & {
            description?: string;
            editor?: EnumEditor;
            label: string;
            options: O;
            propGroup?: string;
        } & { defaultValue: OptionValueOf<O>; optional: false }
        • Optionaldescription?: string

          An optional description that will be displayed below the property in the editor to help users understand the purpose and available options of this property.

        • Optionaleditor?: EnumEditor

          Hint for which control the editor uses to display the options. Defaults to buttons for up to three options and a dropdown for more.

          Option icons are displayed for button groups and dropdowns; option tooltips only for button groups.

        • label: string

          Human-readable label for this property. Will be used to represent this property in the UI.

        • options: O

          List of enum options, either as a list of scalar values or as objects.

          EnumOptions

          Basic Options

          ['on', 'off']
          

          Custom Labels

          [
          { value: 'on', label: 'On' },
          { value: 'off', label: 'Off' },
          ]

          With Icons

          [
          { value: 'on', label: 'On', icon: { name: 'Play' } },
          { value: 'off', label: 'Off', icon: { name: 'Stop' } },
          ]

          With Tooltips (only available in button-group mode).

          [
          {
          value: 'on',
          label: 'On',
          tooltip: 'Description for On' },
          {
          value: 'off',
          label: 'Off',
          tooltip: 'Description for Off'
          },
          ]
        • OptionalpropGroup?: string

          Optionally display this prop as part of the given prop category.

        • defaultValue: OptionValueOf<O>

          The default value for this property.

        • optional: false

          Mark this as an optional value that can also take the value undefined.

      Returns EnumDef<V, O> & { defaultValue: OptionValueOf<O>; optional: false }