@ssv/ngx.command 3.0.0-dev.36 → 3.0.0-dev.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/command-ref.directive.d.ts +29 -0
- package/command.d.ts +59 -0
- package/command.directive.d.ts +24 -0
- package/command.model.d.ts +28 -0
- package/command.module.d.ts +8 -0
- package/command.options.d.ts +18 -0
- package/command.util.d.ts +15 -0
- package/esm2022/command-ref.directive.mjs +57 -0
- package/esm2022/command.directive.mjs +165 -0
- package/esm2022/command.mjs +149 -0
- package/esm2022/command.model.mjs +2 -0
- package/esm2022/command.module.mjs +23 -0
- package/esm2022/command.options.mjs +27 -0
- package/esm2022/command.util.mjs +28 -0
- package/esm2022/index.mjs +8 -0
- package/esm2022/ssv-ngx.command.mjs +5 -0
- package/esm2022/version.mjs +2 -0
- package/fesm2022/ssv-ngx.command.mjs +442 -0
- package/fesm2022/ssv-ngx.command.mjs.map +1 -0
- package/package.json +18 -3
- package/version.d.ts +1 -0
- package/eslint.config.js +0 -43
- package/index.ts +0 -1
- package/jest.config.ts +0 -21
- package/ng-package.json +0 -7
- package/project.json +0 -36
- package/src/command-ref.directive.ts +0 -57
- package/src/command.directive.ts +0 -190
- package/src/command.directive.xspec.ts +0 -105
- package/src/command.model.ts +0 -39
- package/src/command.module.ts +0 -17
- package/src/command.options.ts +0 -49
- package/src/command.spec.ts +0 -215
- package/src/command.ts +0 -208
- package/src/command.util.ts +0 -49
- package/src/test-setup.ts +0 -8
- package/src/version.ts +0 -1
- package/tsconfig.json +0 -28
- package/tsconfig.lib.json +0 -17
- package/tsconfig.lib.prod.json +0 -9
- package/tsconfig.spec.json +0 -16
- /package/{src/index.ts → index.d.ts} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NgModule } from "@angular/core";
|
|
2
|
+
import { CommandDirective } from "./command.directive";
|
|
3
|
+
import { CommandRefDirective } from "./command-ref.directive";
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
const EXPORTED_IMPORTS = [
|
|
6
|
+
CommandDirective,
|
|
7
|
+
CommandRefDirective
|
|
8
|
+
];
|
|
9
|
+
export class SsvCommandModule {
|
|
10
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: SsvCommandModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
11
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.9", ngImport: i0, type: SsvCommandModule, imports: [CommandDirective,
|
|
12
|
+
CommandRefDirective], exports: [CommandDirective,
|
|
13
|
+
CommandRefDirective] });
|
|
14
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: SsvCommandModule });
|
|
15
|
+
}
|
|
16
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: SsvCommandModule, decorators: [{
|
|
17
|
+
type: NgModule,
|
|
18
|
+
args: [{
|
|
19
|
+
imports: [EXPORTED_IMPORTS],
|
|
20
|
+
exports: [EXPORTED_IMPORTS]
|
|
21
|
+
}]
|
|
22
|
+
}] });
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWFuZC5tb2R1bGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9saWJzL25neC5jb21tYW5kL3NyYy9jb21tYW5kLm1vZHVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBRXpDLE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3ZELE9BQU8sRUFBRSxtQkFBbUIsRUFBRSxNQUFNLHlCQUF5QixDQUFDOztBQUU5RCxNQUFNLGdCQUFnQixHQUFHO0lBQ3hCLGdCQUFnQjtJQUNoQixtQkFBbUI7Q0FDbkIsQ0FBQztBQU1GLE1BQU0sT0FBTyxnQkFBZ0I7dUdBQWhCLGdCQUFnQjt3R0FBaEIsZ0JBQWdCLFlBUjVCLGdCQUFnQjtZQUNoQixtQkFBbUIsYUFEbkIsZ0JBQWdCO1lBQ2hCLG1CQUFtQjt3R0FPUCxnQkFBZ0I7OzJGQUFoQixnQkFBZ0I7a0JBSjVCLFFBQVE7bUJBQUM7b0JBQ1QsT0FBTyxFQUFFLENBQUMsZ0JBQWdCLENBQUM7b0JBQzNCLE9BQU8sRUFBRSxDQUFDLGdCQUFnQixDQUFDO2lCQUMzQiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IE5nTW9kdWxlIH0gZnJvbSBcIkBhbmd1bGFyL2NvcmVcIjtcblxuaW1wb3J0IHsgQ29tbWFuZERpcmVjdGl2ZSB9IGZyb20gXCIuL2NvbW1hbmQuZGlyZWN0aXZlXCI7XG5pbXBvcnQgeyBDb21tYW5kUmVmRGlyZWN0aXZlIH0gZnJvbSBcIi4vY29tbWFuZC1yZWYuZGlyZWN0aXZlXCI7XG5cbmNvbnN0IEVYUE9SVEVEX0lNUE9SVFMgPSBbXG5cdENvbW1hbmREaXJlY3RpdmUsXG5cdENvbW1hbmRSZWZEaXJlY3RpdmVcbl07XG5cbkBOZ01vZHVsZSh7XG5cdGltcG9ydHM6IFtFWFBPUlRFRF9JTVBPUlRTXSxcblx0ZXhwb3J0czogW0VYUE9SVEVEX0lNUE9SVFNdXG59KVxuZXhwb3J0IGNsYXNzIFNzdkNvbW1hbmRNb2R1bGUge1xuXG59XG4iXX0=
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { InjectionToken, makeEnvironmentProviders } from "@angular/core";
|
|
2
|
+
const DEFAULT_OPTIONS = Object.freeze({
|
|
3
|
+
executingCssClass: "executing",
|
|
4
|
+
handleDisabled: true,
|
|
5
|
+
hasDisabledDelay: false,
|
|
6
|
+
});
|
|
7
|
+
export const COMMAND_OPTIONS = new InjectionToken("SSV_COMMAND_OPTIONS", {
|
|
8
|
+
factory: () => DEFAULT_OPTIONS,
|
|
9
|
+
});
|
|
10
|
+
export function provideSsvCommandOptions(options) {
|
|
11
|
+
return makeEnvironmentProviders([
|
|
12
|
+
{
|
|
13
|
+
provide: COMMAND_OPTIONS,
|
|
14
|
+
useFactory: () => {
|
|
15
|
+
let opts = typeof options === "function" ? options(DEFAULT_OPTIONS) : options;
|
|
16
|
+
opts = opts
|
|
17
|
+
? {
|
|
18
|
+
...DEFAULT_OPTIONS,
|
|
19
|
+
...opts,
|
|
20
|
+
}
|
|
21
|
+
: DEFAULT_OPTIONS;
|
|
22
|
+
return opts;
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWFuZC5vcHRpb25zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vbGlicy9uZ3guY29tbWFuZC9zcmMvY29tbWFuZC5vcHRpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBNkIsY0FBYyxFQUFFLHdCQUF3QixFQUFFLE1BQU0sZUFBZSxDQUFDO0FBb0JwRyxNQUFNLGVBQWUsR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFpQjtJQUNyRCxpQkFBaUIsRUFBRSxXQUFXO0lBQzlCLGNBQWMsRUFBRSxJQUFJO0lBQ3BCLGdCQUFnQixFQUFFLEtBQUs7Q0FDdkIsQ0FBQyxDQUFDO0FBRUgsTUFBTSxDQUFDLE1BQU0sZUFBZSxHQUFHLElBQUksY0FBYyxDQUFpQixxQkFBcUIsRUFBRTtJQUN4RixPQUFPLEVBQUUsR0FBRyxFQUFFLENBQUMsZUFBZTtDQUM5QixDQ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WFuZE9wdGlvbnMoXG5cdG9wdGlvbnM6IFBhcnRpYWw8Q29tbWFuZE9wdGlvbnM+IHwgKChkZWZhdWx0czogUmVhZG9ubHk8Q29tbWFuZE9wdGlvbnM+KSA9PiBQYXJ0aWFsPENvbW1hbmRPcHRpb25zPilcbik6IEVudmlyb25tZW50UHJvdmlkZXJzIHtcblx0cmV0dXJuIG1ha2VFbnZpcm9ubWVudFByb3ZpZGVycyhbXG5cdFx0e1xuXHRcdFx0cHJvdmlkZTogQ09NTUFORF9PUFRJT05TLFxuXHRcdFx0dXNlRmFjdG9yeTogKCkgPT4ge1xuXHRcdFx0XHRsZXQgb3B0cyA9IHR5cGVvZiBvcHRpb25zID09PSBcImZ1bmN0aW9uXCIgPyBvcHRpb25zKERFRkFVTFRfT1BUSU9OUykgOiBvcHRpb25zO1xuXHRcdFx0XHRvcHRzID0gb3B0c1xuXHRcdFx0XHRcdD8ge1xuXHRcdFx0XHRcdFx0Li4uREVGQVVMVF9PUFRJT05TLFxuXHRcdFx0XHRcdFx0Li4ub3B0cyxcblx0XHRcdFx0XHR9XG5cdFx0XHRcdFx0OiBERUZBVUxUX09QVElPTlM7XG5cdFx0XHRcdHJldHVybiBvcHRzO1xuXHRcdFx0fSxcblx0XHR9LFxuXHRdKTtcbn1cbiJdfQ==
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { of, map, distinctUntilChanged, startWith, delay } from "rxjs";
|
|
2
|
+
import { Command } from "./command";
|
|
3
|
+
/** Determines whether the arg object is of type `Command`. */
|
|
4
|
+
export function isCommand(arg) {
|
|
5
|
+
return arg instanceof Command;
|
|
6
|
+
}
|
|
7
|
+
/** Determines whether the arg object is of type `CommandCreator`. */
|
|
8
|
+
export function isCommandCreator(arg) {
|
|
9
|
+
if (arg instanceof Command) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
else if (isAssumedType(arg) && arg.execute && arg.host) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
/** Get form is valid as an observable. */
|
|
18
|
+
export function canExecuteFromNgForm(form, options) {
|
|
19
|
+
const opts = { validity: true, dirty: true, ...options };
|
|
20
|
+
return form.statusChanges
|
|
21
|
+
? form.statusChanges.pipe(// todo: remove cast when working correctly
|
|
22
|
+
delay(0), startWith(form.valid), map(() => !!(!opts.validity || form.valid) && !!(!opts.dirty || form.dirty)), distinctUntilChanged())
|
|
23
|
+
: of(true);
|
|
24
|
+
}
|
|
25
|
+
function isAssumedType(x) {
|
|
26
|
+
return x !== null && typeof x === "object";
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWFuZC51dGlsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vbGlicy9uZ3guY29tbWFuZC9zcmMvY29tbWFuZC51dGlsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBYyxFQUFFLEVBQUUsR0FBRyxFQUFFLG9CQUFvQixFQUFFLFNBQVMsRUFBRSxLQUFLLEVBQUUsTUFBTSxNQUFNLENBQUM7QUFHbkYsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLFdBQVcsQ0FBQztBQUVwQyw4REFBOEQ7QUFDOUQsTUFBTSxVQUFVLFNBQVMsQ0FBQyxHQUFZO0lBQ3JDLE9BQU8sR0FBRyxZQUFZLE9BQU8sQ0FBQztBQUMvQixDQUFDO0FBRUQscUVBQXFFO0FBQ3JFLE1BQU0sVUFBVSxnQkFBZ0IsQ0FBQyxHQUFZO0lBQzVDLElBQUksR0FBRyxZQUFZLE9BQU8sRUFBRSxDQUFDO1FBQzVCLE9BQU8sS0FBSyxDQUFDO0lBQ2QsQ0FBQztTQUFNLElBQUksYUFBYSxDQUFpQixHQUFHLENBQUMsSUFBSSxHQUFHLENBQUMsT0FBTyxJQUFJLEdB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c3RyaW5nLCB1bmtub3duPj4oeDogdW5rbm93bik6IHggaXMgUGFydGlhbDxUPiB7XG5cdHJldHVybiB4ICE9PSBudWxsICYmIHR5cGVvZiB4ID09PSBcIm9iamVjdFwiO1xufVxuIl19
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { SsvCommandModule } from "./command.module";
|
|
2
|
+
export { provideSsvCommandOptions, COMMAND_OPTIONS } from "./command.options";
|
|
3
|
+
export * from "./command";
|
|
4
|
+
export { CommandDirective } from "./command.directive";
|
|
5
|
+
export { CommandRefDirective } from "./command-ref.directive";
|
|
6
|
+
export { isCommand, isCommandCreator, canExecuteFromNgForm } from "./command.util";
|
|
7
|
+
export { VERSION } from "./version";
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9saWJzL25neC5jb21tYW5kL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUNwRCxPQUFPLEVBQUUsd0JBQXdCLEVBQUUsZUFBZSxFQUF1QixNQUFNLG1CQUFtQixDQUFDO0FBQ25HLGNBQWMsV0FBVyxDQUFDO0FBQzFCLE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3ZELE9BQU8sRUFBRSxtQkFBbUIsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQzlELE9BQU8sRUFBOEIsU0FBUyxFQUFFLGdCQUFnQixFQUFFLG9CQUFvQixFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFFL0csT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLFdBQVcsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCB7IFNzdkNvbW1hbm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ENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vaW5kZXgnO1xuIl19
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export const VERSION = "3.0.0-dev.38";
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyc2lvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL2xpYnMvbmd4LmNvbW1hbmQvc3JjL3ZlcnNpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTSxDQUFDLE1BQU0sT0FBTyxHQUFHLGNBQWMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBjb25zdCBWRVJTSU9OID0gXCIzLjAuMC1kZXYuMzhcIjtcbiJdfQ==
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, makeEnvironmentProviders, inject, DestroyRef, isSignal, Renderer2, ElementRef, ChangeDetectorRef, Directive, Input, HostListener, NgModule } from '@angular/core';
|
|
3
|
+
import { BehaviorSubject, Subject, Subscription, combineLatest, map, tap, filter, switchMap, of, finalize, take, catchError, EMPTY, delay, startWith, distinctUntilChanged, takeUntil } from 'rxjs';
|
|
4
|
+
import { toObservable } from '@angular/core/rxjs-interop';
|
|
5
|
+
|
|
6
|
+
const DEFAULT_OPTIONS = Object.freeze({
|
|
7
|
+
executingCssClass: "executing",
|
|
8
|
+
handleDisabled: true,
|
|
9
|
+
hasDisabledDelay: false,
|
|
10
|
+
});
|
|
11
|
+
const COMMAND_OPTIONS = new InjectionToken("SSV_COMMAND_OPTIONS", {
|
|
12
|
+
factory: () => DEFAULT_OPTIONS,
|
|
13
|
+
});
|
|
14
|
+
function provideSsvCommandOptions(options) {
|
|
15
|
+
return makeEnvironmentProviders([
|
|
16
|
+
{
|
|
17
|
+
provide: COMMAND_OPTIONS,
|
|
18
|
+
useFactory: () => {
|
|
19
|
+
let opts = typeof options === "function" ? options(DEFAULT_OPTIONS) : options;
|
|
20
|
+
opts = opts
|
|
21
|
+
? {
|
|
22
|
+
...DEFAULT_OPTIONS,
|
|
23
|
+
...opts,
|
|
24
|
+
}
|
|
25
|
+
: DEFAULT_OPTIONS;
|
|
26
|
+
return opts;
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
33
|
+
/** Creates an async {@link Command}. Must be used within an injection context.
|
|
34
|
+
* NOTE: this auto injects `DestroyRef` and handles auto destroy. {@link ICommand.autoDestroy} should not be used.
|
|
35
|
+
*/
|
|
36
|
+
function createCommandAsync(execute, canExecute$) {
|
|
37
|
+
return createCommand(execute, canExecute$, true);
|
|
38
|
+
}
|
|
39
|
+
/** Creates a {@link Command}. Must be used within an injection context.
|
|
40
|
+
* NOTE: this auto injects `DestroyRef` and handles auto destroy. {@link ICommand.autoDestroy} should not be used.
|
|
41
|
+
*/
|
|
42
|
+
function createCommand(execute, canExecute$, isAsync) {
|
|
43
|
+
const destroyRef = inject(DestroyRef);
|
|
44
|
+
const cmd = new Command(execute, canExecute$, isAsync);
|
|
45
|
+
cmd.autoDestroy = false;
|
|
46
|
+
destroyRef.onDestroy(() => {
|
|
47
|
+
// console.warn("[createCommandAsync::destroy]");
|
|
48
|
+
cmd.destroy();
|
|
49
|
+
});
|
|
50
|
+
return cmd;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Command object used to encapsulate information which is needed to perform an action.
|
|
54
|
+
*/
|
|
55
|
+
class Command {
|
|
56
|
+
/** Determines whether the command is currently executing, as a snapshot value. */
|
|
57
|
+
get isExecuting() {
|
|
58
|
+
return this._isExecuting;
|
|
59
|
+
}
|
|
60
|
+
/** Determines whether the command can execute or not, as a snapshot value. */
|
|
61
|
+
get canExecute() {
|
|
62
|
+
return this._canExecute;
|
|
63
|
+
}
|
|
64
|
+
/** Determines whether the command is currently executing, as an observable. */
|
|
65
|
+
get isExecuting$() {
|
|
66
|
+
return this._isExecuting$.asObservable();
|
|
67
|
+
}
|
|
68
|
+
/** Determines whether to auto destroy when having 0 subscribers. */
|
|
69
|
+
autoDestroy = true;
|
|
70
|
+
/** Determines whether the command can execute or not, as an observable. */
|
|
71
|
+
canExecute$;
|
|
72
|
+
_isExecuting$ = new BehaviorSubject(false);
|
|
73
|
+
_isExecuting = false;
|
|
74
|
+
_canExecute = true;
|
|
75
|
+
executionPipe$ = new Subject();
|
|
76
|
+
isExecuting$$ = Subscription.EMPTY;
|
|
77
|
+
canExecute$$ = Subscription.EMPTY;
|
|
78
|
+
executionPipe$$ = Subscription.EMPTY;
|
|
79
|
+
subscribersCount = 0;
|
|
80
|
+
/**
|
|
81
|
+
* Creates an instance of Command.
|
|
82
|
+
*
|
|
83
|
+
* @param execute Execute function to invoke - use `isAsync: true` when `Observable<any>`.
|
|
84
|
+
* @param canExecute Observable which determines whether it can execute or not.
|
|
85
|
+
* @param isAsync Indicates that the execute function is async e.g. Observable.
|
|
86
|
+
*/
|
|
87
|
+
constructor(execute, canExecute$, isAsync) {
|
|
88
|
+
if (canExecute$) {
|
|
89
|
+
this.canExecute$ = combineLatest([
|
|
90
|
+
this._isExecuting$,
|
|
91
|
+
isSignal(canExecute$) ? toObservable(canExecute$) : canExecute$
|
|
92
|
+
]).pipe(map(([isExecuting, canExecuteResult]) => {
|
|
93
|
+
// console.log("[command::combineLatest$] update!", { isExecuting, canExecuteResult });
|
|
94
|
+
this._isExecuting = isExecuting;
|
|
95
|
+
this._canExecute = !isExecuting && !!canExecuteResult;
|
|
96
|
+
return this._canExecute;
|
|
97
|
+
}));
|
|
98
|
+
this.canExecute$$ = this.canExecute$.subscribe();
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
this.canExecute$ = this._isExecuting$.pipe(map(x => {
|
|
102
|
+
const canExecute = !x;
|
|
103
|
+
this._canExecute = canExecute;
|
|
104
|
+
return canExecute;
|
|
105
|
+
}));
|
|
106
|
+
this.isExecuting$$ = this._isExecuting$
|
|
107
|
+
.pipe(tap(x => this._isExecuting = x))
|
|
108
|
+
.subscribe();
|
|
109
|
+
}
|
|
110
|
+
this.executionPipe$$ = this.buildExecutionPipe(execute, isAsync).subscribe();
|
|
111
|
+
}
|
|
112
|
+
/** Execute function to invoke. */
|
|
113
|
+
execute(...args) {
|
|
114
|
+
// console.warn("[command::execute]", args);
|
|
115
|
+
this.executionPipe$.next(args);
|
|
116
|
+
}
|
|
117
|
+
/** Disposes all resources held by subscriptions. */
|
|
118
|
+
destroy() {
|
|
119
|
+
// console.warn("[command::destroy]");
|
|
120
|
+
this.executionPipe$$.unsubscribe();
|
|
121
|
+
this.canExecute$$.unsubscribe();
|
|
122
|
+
this.isExecuting$$.unsubscribe();
|
|
123
|
+
}
|
|
124
|
+
subscribe() {
|
|
125
|
+
this.subscribersCount++;
|
|
126
|
+
}
|
|
127
|
+
unsubscribe() {
|
|
128
|
+
this.subscribersCount--;
|
|
129
|
+
// console.log("[command::unsubscribe]", { autoDestroy: this.autoDestroy, subscribersCount: this.subscribersCount });
|
|
130
|
+
if (this.autoDestroy && this.subscribersCount <= 0) {
|
|
131
|
+
this.destroy();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
buildExecutionPipe(execute, isAsync) {
|
|
135
|
+
let pipe$ = this.executionPipe$.pipe(
|
|
136
|
+
// tap(x => console.warn(">>>> executionPipe", this._canExecute)),
|
|
137
|
+
filter(() => this._canExecute), tap(() => {
|
|
138
|
+
// console.log("[command::executionPipe$] do#1 - set execute", { args: x });
|
|
139
|
+
this._isExecuting$.next(true);
|
|
140
|
+
}));
|
|
141
|
+
const execFn = isAsync
|
|
142
|
+
? switchMap(args => {
|
|
143
|
+
if (args) {
|
|
144
|
+
return execute(...args);
|
|
145
|
+
}
|
|
146
|
+
return execute();
|
|
147
|
+
})
|
|
148
|
+
: tap((args) => {
|
|
149
|
+
if (args) {
|
|
150
|
+
execute(...args);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
execute();
|
|
154
|
+
});
|
|
155
|
+
pipe$ = pipe$.pipe(switchMap(args => of(args).pipe(execFn, finalize(() => {
|
|
156
|
+
// console.log("[command::executionPipe$] finalize inner#1 - set idle");
|
|
157
|
+
this._isExecuting$.next(false);
|
|
158
|
+
}), take(1), catchError(error => {
|
|
159
|
+
console.error("Unhandled execute error", error);
|
|
160
|
+
return EMPTY;
|
|
161
|
+
}))), tap(() => {
|
|
162
|
+
// console.log("[command::executionPipe$] tap#2 - set idle");
|
|
163
|
+
this._isExecuting$.next(false);
|
|
164
|
+
}));
|
|
165
|
+
return pipe$;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Async Command object used to encapsulate information which is needed to perform an action,
|
|
170
|
+
* which takes an execute function as Observable/Promise.
|
|
171
|
+
*/
|
|
172
|
+
class CommandAsync extends Command {
|
|
173
|
+
constructor(execute, canExecute$) {
|
|
174
|
+
super(execute, canExecute$, true);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Determines whether the arg object is of type `Command`. */
|
|
179
|
+
function isCommand(arg) {
|
|
180
|
+
return arg instanceof Command;
|
|
181
|
+
}
|
|
182
|
+
/** Determines whether the arg object is of type `CommandCreator`. */
|
|
183
|
+
function isCommandCreator(arg) {
|
|
184
|
+
if (arg instanceof Command) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
else if (isAssumedType(arg) && arg.execute && arg.host) {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
/** Get form is valid as an observable. */
|
|
193
|
+
function canExecuteFromNgForm(form, options) {
|
|
194
|
+
const opts = { validity: true, dirty: true, ...options };
|
|
195
|
+
return form.statusChanges
|
|
196
|
+
? form.statusChanges.pipe(// todo: remove cast when working correctly
|
|
197
|
+
delay(0), startWith(form.valid), map(() => !!(!opts.validity || form.valid) && !!(!opts.dirty || form.dirty)), distinctUntilChanged())
|
|
198
|
+
: of(true);
|
|
199
|
+
}
|
|
200
|
+
function isAssumedType(x) {
|
|
201
|
+
return x !== null && typeof x === "object";
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Controls the state of a component in sync with `Command`.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ### Most common usage
|
|
209
|
+
* ```html
|
|
210
|
+
* <button [ssvCommand]="saveCmd">Save</button>
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
*
|
|
214
|
+
* ### Usage with options
|
|
215
|
+
* ```html
|
|
216
|
+
* <button [ssvCommand]="saveCmd" [ssvCommandOptions]="{executingCssClass: 'in-progress'}">Save</button>
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
*
|
|
220
|
+
* ### Usage with params
|
|
221
|
+
* This is useful for collections (loops) or using multiple actions with different args.
|
|
222
|
+
* *NOTE: This will share the `isExecuting` when used with multiple controls.*
|
|
223
|
+
*
|
|
224
|
+
* #### With single param
|
|
225
|
+
*
|
|
226
|
+
* ```html
|
|
227
|
+
* <button [ssvCommand]="saveCmd" [ssvCommandParams]="{id: 1}">Save</button>
|
|
228
|
+
* ```
|
|
229
|
+
* *NOTE: if you have only 1 argument as an array, it should be enclosed within an array e.g. `[['apple', 'banana']]`,
|
|
230
|
+
* else it will spread and you will `arg1: "apple", arg2: "banana"`*
|
|
231
|
+
*
|
|
232
|
+
* #### With multi params
|
|
233
|
+
* ```html
|
|
234
|
+
* <button [ssvCommand]="saveCmd" [ssvCommandParams]="[{id: 1}, 'hello', hero]">Save</button>
|
|
235
|
+
* ```
|
|
236
|
+
*
|
|
237
|
+
* ### Usage with Command Creator
|
|
238
|
+
* This is useful for collections (loops) or using multiple actions with different args, whilst not sharing `isExecuting`.
|
|
239
|
+
*
|
|
240
|
+
*
|
|
241
|
+
* ```html
|
|
242
|
+
* <button [ssvCommand]="{host: this, execute: removeHero$, canExecute: isValid$, params: [hero, 1337, 'xx']}">Save</button>
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
*/
|
|
246
|
+
const NAME_CAMEL$1 = "ssvCommand";
|
|
247
|
+
// let nextUniqueId = 0;
|
|
248
|
+
class CommandDirective {
|
|
249
|
+
// readonly id = `${NAME_CAMEL}-${nextUniqueId++}`;
|
|
250
|
+
globalOptions = inject(COMMAND_OPTIONS);
|
|
251
|
+
renderer = inject(Renderer2);
|
|
252
|
+
element = inject(ElementRef);
|
|
253
|
+
cdr = inject(ChangeDetectorRef);
|
|
254
|
+
commandOrCreator;
|
|
255
|
+
get commandOptions() { return this._commandOptions; }
|
|
256
|
+
set commandOptions(value) {
|
|
257
|
+
if (value === this._commandOptions) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
this._commandOptions = {
|
|
261
|
+
...this.globalOptions,
|
|
262
|
+
...value,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
commandParams;
|
|
266
|
+
get command() { return this._command; }
|
|
267
|
+
_command;
|
|
268
|
+
_commandOptions = this.globalOptions;
|
|
269
|
+
_destroy$ = new Subject();
|
|
270
|
+
ngOnInit() {
|
|
271
|
+
// console.log("[ssvCommand::init]", this.globalOptions);
|
|
272
|
+
if (!this.commandOrCreator) {
|
|
273
|
+
throw new Error(`${NAME_CAMEL$1}: [${NAME_CAMEL$1}] should be defined!`);
|
|
274
|
+
}
|
|
275
|
+
else if (isCommand(this.commandOrCreator)) {
|
|
276
|
+
this._command = this.commandOrCreator;
|
|
277
|
+
}
|
|
278
|
+
else if (isCommandCreator(this.commandOrCreator)) {
|
|
279
|
+
const isAsync = this.commandOrCreator.isAsync || this.commandOrCreator.isAsync === undefined;
|
|
280
|
+
// todo: find something like this for ivy (or angular10+)
|
|
281
|
+
// const hostComponent = (this.viewContainer as any)._view.component;
|
|
282
|
+
const execFn = this.commandOrCreator.execute.bind(this.commandOrCreator.host);
|
|
283
|
+
this.commandParams = this.commandParams || this.commandOrCreator.params;
|
|
284
|
+
const canExec = this.commandOrCreator.canExecute instanceof Function
|
|
285
|
+
? this.commandOrCreator.canExecute.bind(this.commandOrCreator.host, this.commandParams)()
|
|
286
|
+
: this.commandOrCreator.canExecute;
|
|
287
|
+
// console.log("[ssvCommand::init] command creator", {
|
|
288
|
+
// firstParam: this.commandParams ? this.commandParams[0] : null,
|
|
289
|
+
// params: this.commandParams
|
|
290
|
+
// });
|
|
291
|
+
this._command = new Command(execFn, canExec, isAsync);
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
throw new Error(`${NAME_CAMEL$1}: [${NAME_CAMEL$1}] is not defined properly!`);
|
|
295
|
+
}
|
|
296
|
+
this._command.subscribe();
|
|
297
|
+
this._command.canExecute$.pipe(this.commandOptions.hasDisabledDelay
|
|
298
|
+
? delay(1)
|
|
299
|
+
: tap(() => { }), tap(x => {
|
|
300
|
+
this.trySetDisabled(!x);
|
|
301
|
+
// console.log("[ssvCommand::canExecute$]", { canExecute: x });
|
|
302
|
+
this.cdr.markForCheck();
|
|
303
|
+
}), takeUntil(this._destroy$)).subscribe();
|
|
304
|
+
if (this._command.isExecuting$) {
|
|
305
|
+
this._command.isExecuting$.pipe(tap(x => {
|
|
306
|
+
// console.log("[ssvCommand::isExecuting$]", x, this.commandOptions);
|
|
307
|
+
if (x) {
|
|
308
|
+
this.renderer.addClass(this.element.nativeElement, this.commandOptions.executingCssClass);
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
this.renderer.removeClass(this.element.nativeElement, this.commandOptions.executingCssClass);
|
|
312
|
+
}
|
|
313
|
+
}), takeUntil(this._destroy$)).subscribe();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
onClick() {
|
|
317
|
+
// console.log("[ssvCommand::onClick]", this.commandParams);
|
|
318
|
+
if (Array.isArray(this.commandParams)) {
|
|
319
|
+
this._command.execute(...this.commandParams);
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
this._command.execute(this.commandParams);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
ngOnDestroy() {
|
|
326
|
+
// console.log("[ssvCommand::destroy]");
|
|
327
|
+
this._destroy$.next();
|
|
328
|
+
this._destroy$.complete();
|
|
329
|
+
if (this._command) {
|
|
330
|
+
this._command.unsubscribe();
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
trySetDisabled(disabled) {
|
|
334
|
+
if (this.commandOptions.handleDisabled) {
|
|
335
|
+
// console.warn(">>>> disabled", { id: this.id, disabled });
|
|
336
|
+
this.renderer.setProperty(this.element.nativeElement, "disabled", disabled);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: CommandDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
340
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.9", type: CommandDirective, isStandalone: true, selector: "[ssvCommand]", inputs: { commandOrCreator: ["ssvCommand", "commandOrCreator"], commandOptions: ["ssvCommandOptions", "commandOptions"], commandParams: ["ssvCommandParams", "commandParams"] }, host: { listeners: { "click": "onClick()" } }, exportAs: ["ssvCommand"], ngImport: i0 });
|
|
341
|
+
}
|
|
342
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: CommandDirective, decorators: [{
|
|
343
|
+
type: Directive,
|
|
344
|
+
args: [{
|
|
345
|
+
selector: `[${NAME_CAMEL$1}]`,
|
|
346
|
+
exportAs: NAME_CAMEL$1,
|
|
347
|
+
standalone: true,
|
|
348
|
+
}]
|
|
349
|
+
}], propDecorators: { commandOrCreator: [{
|
|
350
|
+
type: Input,
|
|
351
|
+
args: [NAME_CAMEL$1]
|
|
352
|
+
}], commandOptions: [{
|
|
353
|
+
type: Input,
|
|
354
|
+
args: [`${NAME_CAMEL$1}Options`]
|
|
355
|
+
}], commandParams: [{
|
|
356
|
+
type: Input,
|
|
357
|
+
args: [`${NAME_CAMEL$1}Params`]
|
|
358
|
+
}], onClick: [{
|
|
359
|
+
type: HostListener,
|
|
360
|
+
args: ["click"]
|
|
361
|
+
}] } });
|
|
362
|
+
|
|
363
|
+
const NAME_CAMEL = "ssvCommandRef";
|
|
364
|
+
/**
|
|
365
|
+
* Command creator ref, directive which allows creating Command in the template
|
|
366
|
+
* and associate it to a command (in order to share executions).
|
|
367
|
+
* @example
|
|
368
|
+
* ### Most common usage
|
|
369
|
+
* ```html
|
|
370
|
+
* <div #actionCmd="ssvCommandRef" [ssvCommandRef]="{host: this, execute: removeHero$, canExecute: isValid$}">
|
|
371
|
+
* <button [ssvCommand]="actionCmd.command" [ssvCommandParams]="hero">
|
|
372
|
+
* Remove
|
|
373
|
+
* </button>
|
|
374
|
+
* <button [ssvCommand]="actionCmd.command" [ssvCommandParams]="hero">
|
|
375
|
+
* Remove
|
|
376
|
+
* </button>
|
|
377
|
+
* </div>
|
|
378
|
+
* ```
|
|
379
|
+
*
|
|
380
|
+
*/
|
|
381
|
+
class CommandRefDirective {
|
|
382
|
+
commandCreator;
|
|
383
|
+
get command() { return this._command; }
|
|
384
|
+
_command;
|
|
385
|
+
ngOnInit() {
|
|
386
|
+
if (isCommandCreator(this.commandCreator)) {
|
|
387
|
+
const isAsync = this.commandCreator.isAsync || this.commandCreator.isAsync === undefined;
|
|
388
|
+
const execFn = this.commandCreator.execute.bind(this.commandCreator.host);
|
|
389
|
+
this._command = new Command(execFn, this.commandCreator.canExecute, isAsync);
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
throw new Error(`${NAME_CAMEL}: [${NAME_CAMEL}] is not defined properly!`);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
ngOnDestroy() {
|
|
396
|
+
// console.log("[commandRef::destroy]");
|
|
397
|
+
if (this._command) {
|
|
398
|
+
this._command.destroy();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: CommandRefDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
402
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.9", type: CommandRefDirective, isStandalone: true, selector: "[ssvCommandRef]", inputs: { commandCreator: ["ssvCommandRef", "commandCreator"] }, exportAs: ["ssvCommandRef"], ngImport: i0 });
|
|
403
|
+
}
|
|
404
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: CommandRefDirective, decorators: [{
|
|
405
|
+
type: Directive,
|
|
406
|
+
args: [{
|
|
407
|
+
selector: `[${NAME_CAMEL}]`,
|
|
408
|
+
exportAs: NAME_CAMEL,
|
|
409
|
+
standalone: true,
|
|
410
|
+
}]
|
|
411
|
+
}], propDecorators: { commandCreator: [{
|
|
412
|
+
type: Input,
|
|
413
|
+
args: [NAME_CAMEL]
|
|
414
|
+
}] } });
|
|
415
|
+
|
|
416
|
+
const EXPORTED_IMPORTS = [
|
|
417
|
+
CommandDirective,
|
|
418
|
+
CommandRefDirective
|
|
419
|
+
];
|
|
420
|
+
class SsvCommandModule {
|
|
421
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: SsvCommandModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
422
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.9", ngImport: i0, type: SsvCommandModule, imports: [CommandDirective,
|
|
423
|
+
CommandRefDirective], exports: [CommandDirective,
|
|
424
|
+
CommandRefDirective] });
|
|
425
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: SsvCommandModule });
|
|
426
|
+
}
|
|
427
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: SsvCommandModule, decorators: [{
|
|
428
|
+
type: NgModule,
|
|
429
|
+
args: [{
|
|
430
|
+
imports: [EXPORTED_IMPORTS],
|
|
431
|
+
exports: [EXPORTED_IMPORTS]
|
|
432
|
+
}]
|
|
433
|
+
}] });
|
|
434
|
+
|
|
435
|
+
const VERSION = "3.0.0-dev.38";
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Generated bundle index. Do not edit.
|
|
439
|
+
*/
|
|
440
|
+
|
|
441
|
+
export { COMMAND_OPTIONS, Command, CommandAsync, CommandDirective, CommandRefDirective, SsvCommandModule, VERSION, canExecuteFromNgForm, createCommand, createCommandAsync, isCommand, isCommandCreator, provideSsvCommandOptions };
|
|
442
|
+
//# sourceMappingURL=ssv-ngx.command.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssv-ngx.command.mjs","sources":["../../../../libs/ngx.command/src/command.options.ts","../../../../libs/ngx.command/src/command.ts","../../../../libs/ngx.command/src/command.util.ts","../../../../libs/ngx.command/src/command.directive.ts","../../../../libs/ngx.command/src/command-ref.directive.ts","../../../../libs/ngx.command/src/command.module.ts","../../../../libs/ngx.command/src/version.ts","../../../../libs/ngx.command/src/ssv-ngx.command.ts"],"sourcesContent":["import { type EnvironmentProviders, InjectionToken, makeEnvironmentProviders } from \"@angular/core\";\n\nexport interface CommandOptions {\n\t/**\n\t * Css Class which gets added/removed on the Command element's host while Command `isExecuting$`.\n\t */\n\texecutingCssClass: string;\n\n\t/** Determines whether the disabled will be handled by the directive or not.\n\t * Disable handled by directive's doesn't always play nice when used with other component/pipe/directive and they also handle disabled.\n\t * This disables the handling manually and need to pass explicitly `[disabled]=\"!saveCmd.canExecute\"`.\n\t */\n\thandleDisabled: boolean;\n\n\t/** Determine whether to set a `delay(1)` when setting the disabled. Which might be needed when working with external\n\t * components/directives (such as material button)\n\t */\n\thasDisabledDelay: boolean;\n}\n\nconst DEFAULT_OPTIONS = Object.freeze<CommandOptions>({\n\texecutingCssClass: \"executing\",\n\thandleDisabled: true,\n\thasDisabledDelay: false,\n});\n\nexport const COMMAND_OPTIONS = new InjectionToken<CommandOptions>(\"SSV_COMMAND_OPTIONS\", {\n\tfactory: () => DEFAULT_OPTIONS,\n});\n\nexport function provideSsvCommandOptions(\n\toptions: Partial<CommandOptions> | ((defaults: Readonly<CommandOptions>) => Partial<CommandOptions>)\n): EnvironmentProviders {\n\treturn makeEnvironmentProviders([\n\t\t{\n\t\t\tprovide: COMMAND_OPTIONS,\n\t\t\tuseFactory: () => {\n\t\t\t\tlet opts = typeof options === \"function\" ? options(DEFAULT_OPTIONS) : options;\n\t\t\t\topts = opts\n\t\t\t\t\t? {\n\t\t\t\t\t\t...DEFAULT_OPTIONS,\n\t\t\t\t\t\t...opts,\n\t\t\t\t\t}\n\t\t\t\t\t: DEFAULT_OPTIONS;\n\t\t\t\treturn opts;\n\t\t\t},\n\t\t},\n\t]);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n\tObservable, combineLatest, Subscription, Subject, BehaviorSubject, of, EMPTY,\n\ttap, map, filter, switchMap, catchError, finalize, take,\n } from \"rxjs\";\nimport type { ICommand } from \"./command.model\";\nimport { DestroyRef, inject, isSignal, type Signal } from \"@angular/core\";\nimport { toObservable } from \"@angular/core/rxjs-interop\";\n\nexport type ExecuteFn = (...args: any[]) => unknown;\nexport type ExecuteAsyncFn = (...args: any[]) => Observable<unknown> | Promise<unknown>;\nexport type CanExecute = Signal<boolean> | Observable<boolean>;\n\n/** Creates an async {@link Command}. Must be used within an injection context.\n * NOTE: this auto injects `DestroyRef` and handles auto destroy. {@link ICommand.autoDestroy} should not be used.\n */\nexport function createCommandAsync(\n\texecute: ExecuteAsyncFn,\n\tcanExecute$?: CanExecute,\n): Command {\n\treturn createCommand(execute, canExecute$, true);\n}\n\n/** Creates a {@link Command}. Must be used within an injection context.\n * NOTE: this auto injects `DestroyRef` and handles auto destroy. {@link ICommand.autoDestroy} should not be used.\n */\nexport function createCommand(\n\texecute: ExecuteFn,\n\tcanExecute$?: CanExecute,\n\tisAsync?: boolean,\n): Command {\n\tconst destroyRef = inject(DestroyRef);\n\n\tconst cmd = new Command(execute, canExecute$, isAsync);\n\tcmd.autoDestroy = false;\n\n\tdestroyRef.onDestroy(() => {\n\t\t// console.warn(\"[createCommandAsync::destroy]\");\n\t\tcmd.destroy();\n\t});\n\treturn cmd;\n}\n\n/**\n * Command object used to encapsulate information which is needed to perform an action.\n */\nexport class Command implements ICommand {\n\n\t/** Determines whether the command is currently executing, as a snapshot value. */\n\tget isExecuting(): boolean {\n\t\treturn this._isExecuting;\n\t}\n\n\t/** Determines whether the command can execute or not, as a snapshot value. */\n\tget canExecute(): boolean {\n\t\treturn this._canExecute;\n\t}\n\n\t/** Determines whether the command is currently executing, as an observable. */\n\tget isExecuting$(): Observable<boolean> {\n\t\treturn this._isExecuting$.asObservable();\n\t}\n\n\t/** Determines whether to auto destroy when having 0 subscribers. */\n\tautoDestroy = true;\n\n\t/** Determines whether the command can execute or not, as an observable. */\n\treadonly canExecute$: Observable<boolean>;\n\n\tprivate _isExecuting$ = new BehaviorSubject<boolean>(false);\n\tprivate _isExecuting = false;\n\tprivate _canExecute = true;\n\tprivate executionPipe$ = new Subject<unknown[] | undefined>();\n\tprivate isExecuting$$ = Subscription.EMPTY;\n\tprivate canExecute$$ = Subscription.EMPTY;\n\tprivate executionPipe$$ = Subscription.EMPTY;\n\tprivate subscribersCount = 0;\n\n\t/**\n\t * Creates an instance of Command.\n\t *\n\t * @param execute Execute function to invoke - use `isAsync: true` when `Observable<any>`.\n\t * @param canExecute Observable which determines whether it can execute or not.\n\t * @param isAsync Indicates that the execute function is async e.g. Observable.\n\t */\n\tconstructor(\n\t\texecute: ExecuteFn,\n\t\tcanExecute$?: CanExecute,\n\t\tisAsync?: boolean,\n\t) {\n\t\tif (canExecute$) {\n\t\t\tthis.canExecute$ = combineLatest([\n\t\t\t\tthis._isExecuting$,\n\t\t\t\tisSignal(canExecute$) ? toObservable(canExecute$) : canExecute$\n\t\t\t]).pipe(\n\t\t\t\tmap(([isExecuting, canExecuteResult]) => {\n\t\t\t\t\t// console.log(\"[command::combineLatest$] update!\", { isExecuting, canExecuteResult });\n\t\t\t\t\tthis._isExecuting = isExecuting;\n\t\t\t\t\tthis._canExecute = !isExecuting && !!canExecuteResult;\n\t\t\t\t\treturn this._canExecute;\n\t\t\t\t}),\n\t\t\t);\n\t\t\tthis.canExecute$$ = this.canExecute$.subscribe();\n\t\t} else {\n\t\t\tthis.canExecute$ = this._isExecuting$.pipe(\n\t\t\t\tmap(x => {\n\t\t\t\t\tconst canExecute = !x;\n\t\t\t\t\tthis._canExecute = canExecute;\n\t\t\t\t\treturn canExecute;\n\t\t\t\t})\n\t\t\t);\n\t\t\tthis.isExecuting$$ = this._isExecuting$\n\t\t\t\t.pipe(tap(x => this._isExecuting = x))\n\t\t\t\t.subscribe();\n\t\t}\n\t\tthis.executionPipe$$ = this.buildExecutionPipe(execute, isAsync).subscribe();\n\t}\n\n\t/** Execute function to invoke. */\n\texecute(...args: unknown[]): void {\n\t\t// console.warn(\"[command::execute]\", args);\n\t\tthis.executionPipe$.next(args);\n\t}\n\n\t/** Disposes all resources held by subscriptions. */\n\tdestroy(): void {\n\t\t// console.warn(\"[command::destroy]\");\n\t\tthis.executionPipe$$.unsubscribe();\n\t\tthis.canExecute$$.unsubscribe();\n\t\tthis.isExecuting$$.unsubscribe();\n\t}\n\n\tsubscribe(): void {\n\t\tthis.subscribersCount++;\n\t}\n\n\tunsubscribe(): void {\n\t\tthis.subscribersCount--;\n\t\t// console.log(\"[command::unsubscribe]\", { autoDestroy: this.autoDestroy, subscribersCount: this.subscribersCount });\n\t\tif (this.autoDestroy && this.subscribersCount <= 0) {\n\t\t\tthis.destroy();\n\t\t}\n\t}\n\n\tprivate buildExecutionPipe(execute: (...args: unknown[]) => any, isAsync?: boolean): Observable<unknown> {\n\t\tlet pipe$ = this.executionPipe$.pipe(\n\t\t\t// tap(x => console.warn(\">>>> executionPipe\", this._canExecute)),\n\t\t\tfilter(() => this._canExecute),\n\t\t\ttap(() => {\n\t\t\t\t// console.log(\"[command::executionPipe$] do#1 - set execute\", { args: x });\n\t\t\t\tthis._isExecuting$.next(true);\n\t\t\t})\n\t\t);\n\n\t\tconst execFn = isAsync\n\t\t\t? switchMap<unknown[] | undefined, any[]>(args => {\n\t\t\t\tif (args) {\n\t\t\t\t\treturn execute(...args);\n\t\t\t\t}\n\t\t\t\treturn execute();\n\t\t\t})\n\t\t\t: tap((args: unknown[] | undefined) => {\n\t\t\t\tif (args) {\n\t\t\t\t\texecute(...args);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\texecute();\n\t\t\t});\n\n\t\tpipe$ = pipe$.pipe(\n\t\t\tswitchMap(args => of(args).pipe(\n\t\t\t\texecFn,\n\t\t\t\tfinalize(() => {\n\t\t\t\t\t// console.log(\"[command::executionPipe$] finalize inner#1 - set idle\");\n\t\t\t\t\tthis._isExecuting$.next(false);\n\t\t\t\t}),\n\t\t\t\ttake(1),\n\t\t\t\tcatchError(error => {\n\t\t\t\t\tconsole.error(\"Unhandled execute error\", error);\n\t\t\t\t\treturn EMPTY;\n\t\t\t\t}),\n\t\t\t)),\n\t\t\ttap(\n\t\t\t\t() => {\n\t\t\t\t\t// console.log(\"[command::executionPipe$] tap#2 - set idle\");\n\t\t\t\t\tthis._isExecuting$.next(false);\n\t\t\t\t},\n\t\t\t)\n\t\t);\n\t\treturn pipe$;\n\t}\n\n}\n\n/**\n * Async Command object used to encapsulate information which is needed to perform an action,\n * which takes an execute function as Observable/Promise.\n */\nexport class CommandAsync extends Command {\n\n\tconstructor(\n\t\texecute: ExecuteAsyncFn,\n\t\tcanExecute$?: CanExecute,\n\t) {\n\t\tsuper(execute, canExecute$, true);\n\t}\n\n}\n","import { AbstractControl, AbstractControlDirective, FormControlStatus } from \"@angular/forms\";\nimport { Observable, of, map, distinctUntilChanged, startWith, delay } from \"rxjs\";\n\nimport { CommandCreator, ICommand } from \"./command.model\";\nimport { Command } from \"./command\";\n\n/** Determines whether the arg object is of type `Command`. */\nexport function isCommand(arg: unknown): arg is ICommand {\n\treturn arg instanceof Command;\n}\n\n/** Determines whether the arg object is of type `CommandCreator`. */\nexport function isCommandCreator(arg: unknown): arg is CommandCreator {\n\tif (arg instanceof Command) {\n\t\treturn false;\n\t} else if (isAssumedType<CommandCreator>(arg) && arg.execute && arg.host) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport interface CanExecuteFormOptions {\n\t/** Determines whether to check for validity. (defaults: true) */\n\tvalidity?: boolean;\n\n\t/** Determines whether to check whether UI has been touched. (defaults: true) */\n\tdirty?: boolean;\n}\n\n/** Get form is valid as an observable. */\nexport function canExecuteFromNgForm(\n\tform: AbstractControl | AbstractControlDirective,\n\toptions?: CanExecuteFormOptions\n): Observable<boolean> {\n\tconst opts: CanExecuteFormOptions = { validity: true, dirty: true, ...options };\n\n\treturn form.statusChanges\n\t\t? (form.statusChanges as Observable<FormControlStatus>).pipe( // todo: remove cast when working correctly\n\t\t\tdelay(0),\n\t\t\tstartWith(form.valid),\n\t\t\tmap(() => !!(!opts.validity || form.valid) && !!(!opts.dirty || form.dirty)),\n\t\t\tdistinctUntilChanged(),\n\t\t)\n\t\t: of(true);\n}\n\nfunction isAssumedType<T = Record<string, unknown>>(x: unknown): x is Partial<T> {\n\treturn x !== null && typeof x === \"object\";\n}\n","import {\n\tDirective,\n\tOnInit,\n\tOnDestroy,\n\tInput,\n\tHostListener,\n\tElementRef,\n\tRenderer2,\n\tChangeDetectorRef,\n\tinject,\n} from \"@angular/core\";\nimport { Subject, tap, delay, takeUntil } from \"rxjs\";\n\nimport { type CommandOptions, COMMAND_OPTIONS } from \"./command.options\";\nimport { Command } from \"./command\";\nimport { isCommand, isCommandCreator } from \"./command.util\";\nimport { CommandCreator, type ICommand } from \"./command.model\";\n\n/**\n * Controls the state of a component in sync with `Command`.\n *\n * @example\n * ### Most common usage\n * ```html\n * <button [ssvCommand]=\"saveCmd\">Save</button>\n * ```\n *\n *\n * ### Usage with options\n * ```html\n * <button [ssvCommand]=\"saveCmd\" [ssvCommandOptions]=\"{executingCssClass: 'in-progress'}\">Save</button>\n * ```\n *\n *\n * ### Usage with params\n * This is useful for collections (loops) or using multiple actions with different args.\n * *NOTE: This will share the `isExecuting` when used with multiple controls.*\n *\n * #### With single param\n *\n * ```html\n * <button [ssvCommand]=\"saveCmd\" [ssvCommandParams]=\"{id: 1}\">Save</button>\n * ```\n * *NOTE: if you have only 1 argument as an array, it should be enclosed within an array e.g. `[['apple', 'banana']]`,\n * else it will spread and you will `arg1: \"apple\", arg2: \"banana\"`*\n *\n * #### With multi params\n * ```html\n * <button [ssvCommand]=\"saveCmd\" [ssvCommandParams]=\"[{id: 1}, 'hello', hero]\">Save</button>\n * ```\n *\n * ### Usage with Command Creator\n * This is useful for collections (loops) or using multiple actions with different args, whilst not sharing `isExecuting`.\n *\n *\n * ```html\n * <button [ssvCommand]=\"{host: this, execute: removeHero$, canExecute: isValid$, params: [hero, 1337, 'xx']}\">Save</button>\n * ```\n *\n */\n\nconst NAME_CAMEL = \"ssvCommand\";\n\n// let nextUniqueId = 0;\n\n@Directive({\n\tselector: `[${NAME_CAMEL}]`,\n\texportAs: NAME_CAMEL,\n\tstandalone: true,\n})\nexport class CommandDirective implements OnInit, OnDestroy {\n\n\t// readonly id = `${NAME_CAMEL}-${nextUniqueId++}`;\n\tprivate readonly globalOptions = inject(COMMAND_OPTIONS);\n\tprivate readonly renderer = inject(Renderer2);\n\tprivate readonly element = inject(ElementRef);\n\tprivate readonly cdr = inject(ChangeDetectorRef);\n\n\t@Input(NAME_CAMEL) commandOrCreator: ICommand | CommandCreator | undefined;\n\n\t@Input(`${NAME_CAMEL}Options`)\n\tget commandOptions(): CommandOptions { return this._commandOptions; }\n\tset commandOptions(value: Partial<CommandOptions>) {\n\t\tif (value === this._commandOptions) {\n\t\t\treturn;\n\t\t}\n\t\tthis._commandOptions = {\n\t\t\t...this.globalOptions,\n\t\t\t...value,\n\t\t};\n\t}\n\n\t@Input(`${NAME_CAMEL}Params`) commandParams: unknown | unknown[];\n\n\tget command(): ICommand { return this._command; }\n\n\tprivate _command!: ICommand;\n\tprivate _commandOptions: CommandOptions = this.globalOptions;\n\tprivate _destroy$ = new Subject<void>();\n\n\tngOnInit(): void {\n\t\t// console.log(\"[ssvCommand::init]\", this.globalOptions);\n\t\tif (!this.commandOrCreator) {\n\t\t\tthrow new Error(`${NAME_CAMEL}: [${NAME_CAMEL}] should be defined!`);\n\t\t} else if (isCommand(this.commandOrCreator)) {\n\t\t\tthis._command = this.commandOrCreator;\n\t\t} else if (isCommandCreator(this.commandOrCreator)) {\n\t\t\tconst isAsync = this.commandOrCreator.isAsync || this.commandOrCreator.isAsync === undefined;\n\n\t\t\t// todo: find something like this for ivy (or angular10+)\n\t\t\t// const hostComponent = (this.viewContainer as any)._view.component;\n\n\t\t\tconst execFn = this.commandOrCreator.execute.bind(this.commandOrCreator.host);\n\t\t\tthis.commandParams = this.commandParams || this.commandOrCreator.params;\n\n\t\t\tconst canExec = this.commandOrCreator.canExecute instanceof Function\n\t\t\t\t? this.commandOrCreator.canExecute.bind(this.commandOrCreator.host, this.commandParams)()\n\t\t\t\t: this.commandOrCreator.canExecute;\n\n\t\t\t// console.log(\"[ssvCommand::init] command creator\", {\n\t\t\t// \tfirstParam: this.commandParams ? this.commandParams[0] : null,\n\t\t\t// \tparams: this.commandParams\n\t\t\t// });\n\t\t\tthis._command = new Command(execFn, canExec, isAsync);\n\t\t} else {\n\t\t\tthrow new Error(`${NAME_CAMEL}: [${NAME_CAMEL}] is not defined properly!`);\n\t\t}\n\n\t\tthis._command.subscribe();\n\t\tthis._command.canExecute$.pipe(\n\t\t\tthis.commandOptions.hasDisabledDelay\n\t\t\t\t? delay(1)\n\t\t\t\t: tap(() => { /* stub */ }),\n\t\t\ttap(x => {\n\t\t\t\tthis.trySetDisabled(!x);\n\t\t\t\t// console.log(\"[ssvCommand::canExecute$]\", { canExecute: x });\n\t\t\t\tthis.cdr.markForCheck();\n\t\t\t}),\n\t\t\ttakeUntil(this._destroy$),\n\t\t).subscribe();\n\n\t\tif (this._command.isExecuting$) {\n\t\t\tthis._command.isExecuting$.pipe(\n\t\t\t\ttap(x => {\n\t\t\t\t\t// console.log(\"[ssvCommand::isExecuting$]\", x, this.commandOptions);\n\t\t\t\t\tif (x) {\n\t\t\t\t\t\tthis.renderer.addClass(\n\t\t\t\t\t\t\tthis.element.nativeElement,\n\t\t\t\t\t\t\tthis.commandOptions.executingCssClass\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.renderer.removeClass(\n\t\t\t\t\t\t\tthis.element.nativeElement,\n\t\t\t\t\t\t\tthis.commandOptions.executingCssClass\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\ttakeUntil(this._destroy$),\n\t\t\t).subscribe();\n\t\t}\n\t}\n\n\t@HostListener(\"click\")\n\tonClick(): void {\n\t\t// console.log(\"[ssvCommand::onClick]\", this.commandParams);\n\t\tif (Array.isArray(this.commandParams)) {\n\t\t\tthis._command.execute(...this.commandParams);\n\t\t} else {\n\t\t\tthis._command.execute(this.commandParams);\n\t\t}\n\t}\n\n\tngOnDestroy(): void {\n\t\t// console.log(\"[ssvCommand::destroy]\");\n\t\tthis._destroy$.next();\n\t\tthis._destroy$.complete();\n\t\tif (this._command) {\n\t\t\tthis._command.unsubscribe();\n\t\t}\n\t}\n\n\tprivate trySetDisabled(disabled: boolean) {\n\t\tif (this.commandOptions.handleDisabled) {\n\t\t\t// console.warn(\">>>> disabled\", { id: this.id, disabled });\n\t\t\tthis.renderer.setProperty(this.element.nativeElement, \"disabled\", disabled);\n\t\t}\n\t}\n\n}\n\n","import { Observable } from \"rxjs\";\nimport { Directive, OnInit, OnDestroy, Input } from \"@angular/core\";\n\nimport { ICommand, CommandCreator } from \"./command.model\";\nimport { isCommandCreator } from \"./command.util\";\nimport { Command } from \"./command\";\n\nconst NAME_CAMEL = \"ssvCommandRef\";\n\n/**\n * Command creator ref, directive which allows creating Command in the template\n * and associate it to a command (in order to share executions).\n * @example\n * ### Most common usage\n * ```html\n * <div #actionCmd=\"ssvCommandRef\" [ssvCommandRef]=\"{host: this, execute: removeHero$, canExecute: isValid$}\">\n * <button [ssvCommand]=\"actionCmd.command\" [ssvCommandParams]=\"hero\">\n * Remove\n * </button>\n * <button [ssvCommand]=\"actionCmd.command\" [ssvCommandParams]=\"hero\">\n * Remove\n * </button>\n * </div>\n * ```\n *\n */\n@Directive({\n\tselector: `[${NAME_CAMEL}]`,\n\texportAs: NAME_CAMEL,\n\tstandalone: true,\n})\nexport class CommandRefDirective implements OnInit, OnDestroy {\n\n\t@Input(NAME_CAMEL) commandCreator: CommandCreator | undefined;\n\n\tget command(): ICommand { return this._command; }\n\tprivate _command!: ICommand;\n\n\tngOnInit(): void {\n\t\tif (isCommandCreator(this.commandCreator)) {\n\t\t\tconst isAsync = this.commandCreator.isAsync || this.commandCreator.isAsync === undefined;\n\n\t\t\tconst execFn = this.commandCreator.execute.bind(this.commandCreator.host);\n\t\t\tthis._command = new Command(execFn, this.commandCreator.canExecute as Observable<boolean> | undefined, isAsync);\n\t\t} else {\n\t\t\tthrow new Error(`${NAME_CAMEL}: [${NAME_CAMEL}] is not defined properly!`);\n\t\t}\n\t}\n\n\tngOnDestroy(): void {\n\t\t// console.log(\"[commandRef::destroy]\");\n\t\tif (this._command) {\n\t\t\tthis._command.destroy();\n\t\t}\n\t}\n\n}\n","import { NgModule } from \"@angular/core\";\n\nimport { CommandDirective } from \"./command.directive\";\nimport { CommandRefDirective } from \"./command-ref.directive\";\n\nconst EXPORTED_IMPORTS = [\n\tCommandDirective,\n\tCommandRefDirective\n];\n\n@NgModule({\n\timports: [EXPORTED_IMPORTS],\n\texports: [EXPORTED_IMPORTS]\n})\nexport class SsvCommandModule {\n\n}\n","export const VERSION = \"3.0.0-dev.38\";\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["NAME_CAMEL"],"mappings":";;;;;AAoBA,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAiB;AACrD,IAAA,iBAAiB,EAAE,WAAW;AAC9B,IAAA,cAAc,EAAE,IAAI;AACpB,IAAA,gBAAgB,EAAE,KAAK;AACvB,CAAA,CAAC,CAAC;MAEU,eAAe,GAAG,IAAI,cAAc,CAAiB,qBAAqB,EAAE;AACxF,IAAA,OAAO,EAAE,MAAM,eAAe;AAC9B,CAAA,EAAE;AAEG,SAAU,wBAAwB,CACvC,OAAoG,EAAA;AAEpG,IAAA,OAAO,wBAAwB,CAAC;AAC/B,QAAA;AACC,YAAA,OAAO,EAAE,eAAe;YACxB,UAAU,EAAE,MAAK;AAChB,gBAAA,IAAI,IAAI,GAAG,OAAO,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC;AAC9E,gBAAA,IAAI,GAAG,IAAI;AACV,sBAAE;AACD,wBAAA,GAAG,eAAe;AAClB,wBAAA,GAAG,IAAI;AACP,qBAAA;sBACC,eAAe,CAAC;AACnB,gBAAA,OAAO,IAAI,CAAC;aACZ;AACD,SAAA;AACD,KAAA,CAAC,CAAC;AACJ;;AChDA;AAaA;;AAEG;AACa,SAAA,kBAAkB,CACjC,OAAuB,EACvB,WAAwB,EAAA;IAExB,OAAO,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AAClD,CAAC;AAED;;AAEG;SACa,aAAa,CAC5B,OAAkB,EAClB,WAAwB,EACxB,OAAiB,EAAA;AAEjB,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IA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