UNPKG

@rxap/remote-method

Version:

This package provides abstractions for defining and executing remote methods in Angular applications. It includes features such as automatic refreshing, proxying, and error handling. It offers a structured way to manage remote calls and their dependencies

142 lines (136 loc) 6.06 kB
import { __decorate, __metadata } from 'tslib'; import * as i0 from '@angular/core'; import { Directive, Inject, HostBinding, Input, HostListener } from '@angular/core'; import { DebounceCall } from '@rxap/utilities'; import * as i1 from '@rxap/remote-method/http'; import { HttpRemoteMethodLoader } from '@rxap/remote-method/http'; import { RemoteMethodDirective } from '@rxap/remote-method/directive'; class ContenteditableDirective { constructor(httpRemoteMethodLoader) { this.httpRemoteMethodLoader = httpRemoteMethodLoader; this.contenteditable = true; } onClick($event) { $event.stopPropagation(); } onInput($event) { const value = $event.target.textContent; if (value && value.length > 3) { return this.httpRemoteMethodLoader.request$(this.remoteMethodId, { pathParams: { uuid: this.uuid }, body: { [this.property]: value }, }); } return Promise.resolve(); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: ContenteditableDirective, deps: [{ token: HttpRemoteMethodLoader }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.1", type: ContenteditableDirective, isStandalone: true, selector: "[rxapContenteditable]", inputs: { remoteMethodId: ["rxapContenteditable", "remoteMethodId"], property: "property", uuid: "uuid" }, host: { listeners: { "click": "onClick($event)", "input": "onInput($event)" }, properties: { "attr.contenteditable": "this.contenteditable" } }, ngImport: i0 }); } } __decorate([ DebounceCall(1000), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], ContenteditableDirective.prototype, "onInput", null); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: ContenteditableDirective, decorators: [{ type: Directive, args: [{ selector: '[rxapContenteditable]', standalone: true, }] }], ctorParameters: () => [{ type: i1.HttpRemoteMethodLoader, decorators: [{ type: Inject, args: [HttpRemoteMethodLoader] }] }], propDecorators: { contenteditable: [{ type: HostBinding, args: ['attr.contenteditable'] }], remoteMethodId: [{ type: Input, args: [{ required: true, alias: 'rxapContenteditable', }] }], property: [{ type: Input, args: [{ required: true }] }], uuid: [{ type: Input, args: [{ required: true }] }], onClick: [{ type: HostListener, args: ['click', ['$event']] }], onInput: [{ type: HostListener, args: ['input', ['$event']] }] } }); class HttpRemoteMethodDirective extends RemoteMethodDirective { set headers(headers) { this.updateParameters({ headers }); } set reportProgress(reportProgress) { this.updateParameters({ reportProgress }); } set params(params) { this.updateParameters({ params }); } set responseType(responseType) { this.updateParameters({ responseType }); } set withCredentials(withCredentials) { this.updateParameters({ withCredentials }); } set body(body) { this.updateParameters({ body }); } set setHeaders(setHeaders) { this.updateParameters({ setHeaders }); } set setParams(setParams) { this.updateParameters({ setParams }); } set pathParams(pathParams) { this.updateParameters({ pathParams }); } set remoteMethodOrIdOrToken(value) { if (value) { this._remoteMethodOrIdOrToken = value; } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: HttpRemoteMethodDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.1", type: HttpRemoteMethodDirective, isStandalone: true, selector: "button[rxapHttpRemoteMethod]", inputs: { headers: "headers", reportProgress: "reportProgress", params: "params", responseType: "responseType", withCredentials: "withCredentials", body: "body", setHeaders: "setHeaders", setParams: "setParams", pathParams: "pathParams", remoteMethodOrIdOrToken: ["rxapHttpRemoteMethod", "remoteMethodOrIdOrToken"] }, usesInheritance: true, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: HttpRemoteMethodDirective, decorators: [{ type: Directive, args: [{ selector: 'button[rxapHttpRemoteMethod]', standalone: true, }] }], propDecorators: { headers: [{ type: Input }], reportProgress: [{ type: Input }], params: [{ type: Input }], responseType: [{ type: Input }], withCredentials: [{ type: Input }], body: [{ type: Input }], setHeaders: [{ type: Input }], setParams: [{ type: Input }], pathParams: [{ type: Input }], remoteMethodOrIdOrToken: [{ type: Input, args: ['rxapHttpRemoteMethod'] }] } }); // region // endregion /** * Generated bundle index. Do not edit. */ export { ContenteditableDirective, HttpRemoteMethodDirective }; //# sourceMappingURL=rxap-remote-method-http-directive.mjs.map