@web-atoms/core
Version:
112 lines • 4.34 kB
TypeScript
import Command from "../core/Command";
import EventScope from "../core/EventScope";
import FormattedString from "../core/FormattedString";
import XNode from "../core/XNode";
export type onEventSetBusyTypes = "target" | "current-target" | "till-current-target" | "ancestors" | "button";
export interface IActionOptions {
/**
* Execute current action when the specified event will be fired. The benefit is,
* the element which has fired this event will have `[data-busy=true]` set so
* you can use CSS to disable the button and prevent further executions.
*/
onEvent?: string | string[] | EventScope | EventScope[] | Command | Command[];
/**
* By default event is listened on current element, however some events are only sent globally
* and might end up on parent or window. You can change the target by overriding this.
*/
onEventTarget?: EventTarget;
/**
* Set busy will be set to only target of the event. You can change this behavior by providing
* any of target, current-target, ancestors, button. Ancestors will set all ancestors to busy.
* `button` will only set busy if target is button or any ancestor is button.
*/
onEventSetBusy?: MarkBusySet;
/**
* Defer the execution for given milliseconds, each execution request made before the defer
* will cancel previous request and will enqueue the new request. This is helpful in
* preventing multiple simultaneous executions.
*/
defer?: number;
/**
* When action is set to automatically execute on the given event fired,
* if this is set to true, simultaneous executions will be blocked. Default is true.
*/
blockMultipleExecution?: boolean;
/**
* Display success message after method successfully executes,
* if method returns promise, success will display after promise
* has finished, pass null to not display message.
* @default null
*/
success?: string | FormattedString | XNode;
/**
* Title for success message
* @default Done
*/
successTitle?: string;
successMode?: "alert" | "notify";
/**
* By default 2000 milliseconds, the success/error notification will hide in given milliseconds
*/
notifyDelay?: number;
/**
* Ask for confirmation before invoking this method
* @default null
*/
confirm?: string | XNode;
/**
* Title for confirm message
* @default Confirm
*/
confirmTitle?: string;
/**
* Validate the view model before execution and report to user
* @default false
*/
validate?: boolean | string | FormattedString;
/**
* Title for validation
* @default Error
*/
validateTitle?: string;
/**
* dispatch event after successful execution.
*/
dispatchEvent?: string | EventScope;
/**
* Closes the current popup/window by calling viewModel.close, returned result will be sent in close
*/
close?: boolean;
/**
* Authorize user, if not empty role
*/
authorize?: string[] | boolean;
}
export interface IAuthorize {
authorize: string[] | boolean;
authorized: boolean;
}
export declare class MarkBusySet {
private set;
static none: MarkBusySet;
static target: MarkBusySet;
static currentTarget: MarkBusySet;
static tillCurrentTarget: MarkBusySet;
static button: MarkBusySet;
static buttonOrAnchor: MarkBusySet;
static selector(selector: string): MarkBusySet;
static allAncestors: MarkBusySet;
private constructor();
find(event: Event): Generator<HTMLElement, void, any>;
}
/**
* Reports an alert to user when an error has occurred
* or validation has failed.
* If you set success message, it will display an alert with success message.
* If you set confirm message, it will ask form confirmation before executing this method.
* You can configure options to enable/disable certain
* alerts.
* @param reportOptions
*/
export default function Action({ onEvent, onEventTarget, onEventSetBusy, blockMultipleExecution, dispatchEvent, authorize, defer, success, successTitle, successMode, confirm, confirmTitle, validate, validateTitle, close, notifyDelay, }?: IActionOptions): (target: any, key: string | symbol, descriptor: any) => any;
//# sourceMappingURL=Action.d.ts.map