@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: { description?: string; 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.

        • 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.

          Basic Options

          ['on', 'off']
          

          Custom Labels

          [
          { value: 'on', label: 'On' },
          { value: 'off', label: '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>; optional: true }

    • Non-Optional Enum Property

      Type Parameters

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

      Parameters

      • options: { description?: string; 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.

        • 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.

          Basic Options

          ['on', 'off']
          

          Custom Labels

          [
          { value: 'on', label: 'On' },
          { value: 'off', label: '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 }