@aurigma/ui-framework
Version:
A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.
183 lines (122 loc) • 4.17 kB
Markdown
A non-visual widget that is used to listen for property changes to execute custom functions. Can be used in other widgets.
The following example illustrates how you can listen for property changes to execute custom functions.
```
{
"widgets": [
{
"name": "name",
"type": "option",
"params": {
"type": "list",
"title": "Name",
"prompt": "Choose a name",
"values": [
{ "title": "Jack" },
{ "title": "James" },
{ "title": "John" }
]
}
},
{
"name": "myFunction",
"type": "function-trigger",
"params": {
"arguments": [
"{{ $['name']._.title }}",
"{{ $['name']._.title }}"
],
"callback": [
"{{ #function(arg1, arg2) console.log(arg1, arg2) }}",
"{{ #asyncFunction await new Promise(...) }}"
]
"catch": [
"{{ #function console.error("failed") }}",
],
"finally": [
"{{ #function console.log("cleanup") }}",
]
}
}
]
}
```
* AuBaseInvisibleWidget
↳ **AuWidgetFunctionTrigger**
* [IWidget](../interfaces/iwidget.md)
* [enabled](auwidgetfunctiontrigger.md
* [params](auwidgetfunctiontrigger.md
* [template](auwidgetfunctiontrigger.md
* [checkInitDependenciesWidgets](auwidgetfunctiontrigger.md
* [resetPreloaderState](auwidgetfunctiontrigger.md
* [showPreloader](auwidgetfunctiontrigger.md
* [showToast](auwidgetfunctiontrigger.md
• **enabled**: *boolean* = true
If `false`, the `callback` will not be executed. The default value is `true`.
___
• **params**: *any*
*Implementation of [IWidget](../interfaces/iwidget.md).[params](../interfaces/iwidget.md
*Inherited from [AuBaseWidget](aubasewidget.md).[params](aubasewidget.md
Compiled widget configuration.
• **get template**(): *HTMLTemplateElement*
*Inherited from void*
**Returns:** *HTMLTemplateElement*
▸ **checkInitDependenciesWidgets**(): *string[]*
*Inherited from [AuBaseWidget](aubasewidget.md).[checkInitDependenciesWidgets](aubasewidget.md
Returns an array of widget names, due to which the current widget cannot receive parameters.
**Returns:** *string[]*
___
▸ **resetPreloaderState**(): *void*
*Inherited from [AuBaseWidget](aubasewidget.md).[resetPreloaderState](aubasewidget.md
**Returns:** *void*
___
▸ **showPreloader**(`isPreload`: boolean, `message`: string | string[], `timeout`: number): *void*
*Inherited from [AuBaseWidget](aubasewidget.md).[showPreloader](aubasewidget.md
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 &
`timeout` | number | 5 | - |
**Returns:** *void*
___
▸ **showToast**(`data?`: string, `duration?`: number): *void*
*Inherited from [AuBaseWidget](aubasewidget.md).[showToast](aubasewidget.md
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*