@nent/core
Version:
141 lines (140 loc) • 3.49 kB
JavaScript
/*!
* NENT 2022
*/
import { Component, Element, h, Host, Method, Prop, State, } from '@stencil/core';
import { ActionService } from '../../services/actions/service';
/**
* This element just holds data to express the actionEvent to fire. This element
* should always be the child of an n-action-activator.
*
* @system actions
*/
export class Action {
constructor() {
this.valid = true;
this.actionService = new ActionService(this, 'n-action');
}
/**
* Get the underlying actionEvent instance. Used by the n-action-activator element.
*/
getAction() {
return this.actionService.getAction();
}
/**
* Send this action to the action messaging system.
*/
sendAction(data) {
return this.actionService.sendAction(data);
}
get childScript() {
return this.el.querySelector('script');
}
get childInputs() {
return this.el.querySelectorAll('input,select,textarea');
}
render() {
return h(Host, null);
}
static get is() { return "n-action"; }
static get properties() { return {
"topic": {
"type": "string",
"mutable": false,
"complexType": {
"original": "string",
"resolved": "string",
"references": {}
},
"required": true,
"optional": false,
"docs": {
"tags": [],
"text": "This is the topic this action-command is targeting."
},
"attribute": "topic",
"reflect": false
},
"command": {
"type": "string",
"mutable": false,
"complexType": {
"original": "string",
"resolved": "string",
"references": {}
},
"required": true,
"optional": false,
"docs": {
"tags": [],
"text": "The command to execute."
},
"attribute": "command",
"reflect": false
},
"when": {
"type": "string",
"mutable": false,
"complexType": {
"original": "string",
"resolved": "string | undefined",
"references": {}
},
"required": false,
"optional": true,
"docs": {
"tags": [],
"text": "A predicate to evaluate prior to sending the action."
},
"attribute": "when",
"reflect": false
}
}; }
static get states() { return {
"valid": {}
}; }
static get methods() { return {
"getAction": {
"complexType": {
"signature": "() => Promise<EventAction<any> | null>",
"parameters": [],
"references": {
"Promise": {
"location": "global"
},
"EventAction": {
"location": "import",
"path": "../../services/actions"
}
},
"return": "Promise<EventAction<any> | null>"
},
"docs": {
"text": "Get the underlying actionEvent instance. Used by the n-action-activator element.",
"tags": []
}
},
"sendAction": {
"complexType": {
"signature": "(data?: Record<string, any> | undefined) => Promise<void>",
"parameters": [{
"tags": [],
"text": ""
}],
"references": {
"Promise": {
"location": "global"
},
"Record": {
"location": "global"
}
},
"return": "Promise<void>"
},
"docs": {
"text": "Send this action to the action messaging system.",
"tags": []
}
}
}; }
static get elementRef() { return "el"; }
}