createWidget(index) {
    // Return null if no widget is found.
    if (!this.component.widget) {
      return null;
    }

    // Get the widget settings.
    const settings = (typeof this.component.widget === 'string') ? {
      type: this.component.widget
    } : this.component.widget;

    if (this.root?.shadowRoot) {
      settings.shadowRoot = this.root?.shadowRoot;
    }

    // Make sure we have a widget.
    if (!Widgets.hasOwnProperty(settings.type)) {
      return null;
    }

    // Create the widget.
    const widget = new Widgets[settings.type](settings, this.component, this, index);
    widget.on('update', () => this.updateValue(this.getValue(), {
      modified: true
    }, index), true);
    widget.on('redraw', () => this.redraw(), true);
    return widget;
  }
Creates an instance of a widget for this component.
@param {number} index - The index of the widget.
@returns {*} - The widget instance.