UNPKG

@nent/core

Version:

Functional elements to add routing, data-binding, dynamic HTML, declarative actions, audio, video, and so much more. Supercharge static HTML files into web apps without script or builds.

165 lines (164 loc) 4.09 kB
/*! * NENT 2022 */ import { Component, Element, h, Host, Method, Prop, State, } from '@stencil/core'; import { ActionService } from '../../services/actions/service'; /** * This specialized action contains the time attribute, * allowing it to be activated directly within the n-presentation * element (no n-action-activator needed) * * @system presentation * @system actions */ export class PresentationAction { constructor() { this.valid = true; this.sent = false; this.actionService = new ActionService(this, 'n-presentation-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. */ async sendAction(data) { if (this.sent) return; await this.actionService.sendAction(data); this.sent = true; } 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-presentation-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 }, "time": { "type": "any", "mutable": false, "complexType": { "original": "number | 'end'", "resolved": "\"end\" | number | undefined", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "The time this should execute" }, "attribute": "time", "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": {}, "sent": {} }; } static get methods() { return { "getAction": { "complexType": { "signature": "() => Promise<EventAction<any> | null>", "parameters": [], "references": { "Promise": { "location": "global" }, "EventAction": { "location": "import", "path": "../../services/actions/interfaces" } }, "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"; } }