
# Class: AuWidgetGallery

A widget that is used to display a list of images and allows you to select an image.

For details, you can refer to the [Gallery widget](https://customerscanvas.com/dev/editors/ui-framework/widgets/gallery.html) topic.
```
{
  "widgets": [
   {
     "type": "gallery",
     "name": "backgrounds",
     "title": "Background",
     "params": {
       "prompt": "Choose a background image",
       "showTitle": true,
       "items": [{
         "title": "Football",
         "name": "something",
         "previewUrl": "/assets/img/something.jpg"
       }]
     }
   }
  ]
}
```

## Hierarchy

  ↳ [AuBaseSelectorWidget](aubaseselectorwidget.md)

  ↳ **AuWidgetGallery**

## Implements

* [IWidget](../interfaces/iwidget.md)
* [IRestorableWidget](../interfaces/irestorablewidget.md)

## Index

### Properties

* [applyEmptyValues](auwidgetgallery.md#applyemptyvalues)
* [emptyValuesText](auwidgetgallery.md#emptyvaluestext)
* [params](auwidgetgallery.md#params)
* [value](auwidgetgallery.md#value)

### Accessors

* [_](auwidgetgallery.md#_)

### Methods

* [checkInitDependenciesWidgets](auwidgetgallery.md#checkinitdependencieswidgets)
* [clearSelection](auwidgetgallery.md#clearselection)
* [exportWidgetData](auwidgetgallery.md#exportwidgetdata)
* [resetPreloaderState](auwidgetgallery.md#resetpreloaderstate)
* [restoreWidgetFromData](auwidgetgallery.md#restorewidgetfromdata)
* [setSelectedItem](auwidgetgallery.md#setselecteditem)
* [showPreloader](auwidgetgallery.md#showpreloader)
* [showToast](auwidgetgallery.md#showtoast)

## Properties

###  applyEmptyValues

• **applyEmptyValues**: *boolean*

___

###  emptyValuesText

• **emptyValuesText**: *string*

___

###  params

• **params**: *[IGalleryConfig](../interfaces/igalleryconfig.md)*

*Overrides [AuBaseWidget](aubasewidget.md).[params](aubasewidget.md#params)*

Properties of this widget.

___

###  value

• **value**: *[IGalleryItem](../interfaces/igalleryitem.md)*

A gallery item.

## Accessors

###  _

• **get _**(): *[IGalleryItem](../interfaces/igalleryitem.md)*

*Overrides [AuBaseSelectorWidget](aubaseselectorwidget.md).[_](aubaseselectorwidget.md#_)*

Returns the selected gallery item.

**Returns:** *[IGalleryItem](../interfaces/igalleryitem.md)*

## Methods

###  checkInitDependenciesWidgets

▸ **checkInitDependenciesWidgets**(): *string[]*

*Inherited from [AuBaseWidget](aubasewidget.md).[checkInitDependenciesWidgets](aubasewidget.md#checkinitdependencieswidgets)*

Returns an array of widget names, due to which the current widget cannot receive parameters.

**Returns:** *string[]*

___

###  clearSelection

▸ **clearSelection**(): *void*

*Overrides [AuBaseSelectorWidget](aubaseselectorwidget.md).[clearSelection](aubaseselectorwidget.md#abstract-clearselection)*

Resets the selected value.

**Returns:** *void*

___

###  exportWidgetData

▸ **exportWidgetData**(`force`: boolean): *Promise‹GalleryWidgetData›*

*Implementation of [IRestorableWidget](../interfaces/irestorablewidget.md)*

**Parameters:**

Name | Type |
------ | ------ |
`force` | boolean |

**Returns:** *Promise‹GalleryWidgetData›*

___

###  resetPreloaderState

▸ **resetPreloaderState**(): *void*

*Inherited from [AuBaseWidget](aubasewidget.md).[resetPreloaderState](aubasewidget.md#resetpreloaderstate)*

**Returns:** *void*

___

###  restoreWidgetFromData

▸ **restoreWidgetFromData**(`widgetData`: GalleryWidgetData, `force`: boolean): *Promise‹void›*

**Parameters:**

Name | Type |
------ | ------ |
`widgetData` | GalleryWidgetData |
`force` | boolean |

**Returns:** *Promise‹void›*

___

###  setSelectedItem

▸ **setSelectedItem**(`itemIndexOrName`: string | number): *void*

Select gallery item by its index or name

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`itemIndexOrName` | string &#124; number | index or name of item that should be selected  |

**Returns:** *void*

___

###  showPreloader

▸ **showPreloader**(`isPreload`: boolean, `message`: string | string[], `timeout`: number): *void*

*Inherited from [AuBaseWidget](aubasewidget.md).[showPreloader](aubasewidget.md#showpreloader)*

Shows a preloader.

```
"onClick": [
  "{{#function main.showPreloader(true, 'Creating print files...')}}",
  "{{#function $['editor'].getHiResImages(800,800)}}",
  "{{#function main.showPreloader(false)}}"
]
```

**Parameters:**

Name | Type | Default | Description |
------ | ------ | ------ | ------ |
`isPreload` | boolean | - | If `true`, enables the preloader. |
`message` | string &#124; string[] |  [""] | A text message that appears next to the preloader.  |
`timeout` | number | 5 | - |

**Returns:** *void*

___

###  showToast

▸ **showToast**(`data?`: string, `duration?`: number): *void*

*Inherited from [AuBaseWidget](aubasewidget.md).[showToast](aubasewidget.md#showtoast)*

Shows a toast.

```
return editor.loadUserInfo(data)
    .catch(err => {
        this.widget.showToast("Error: Invalid data");
        console.log(err);
    });
```

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`data?` | string | A string message to display in the toast. |
`duration?` | number | Defines how long to show the toast for.  |

**Returns:** *void*
