@ssv/ngx.command 3.2.0-dev.68 → 3.3.0-dev.76

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.
@@ -364,10 +364,10 @@ class CommandDirective {
364
364
  this.renderer.setProperty(this.element.nativeElement, "disabled", disabled);
365
365
  }
366
366
  }
367
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: CommandDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
368
- 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 });
367
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: CommandDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
368
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.7", type: CommandDirective, isStandalone: true, selector: "[ssvCommand]", inputs: { commandOrCreator: ["ssvCommand", "commandOrCreator"], commandOptions: ["ssvCommandOptions", "commandOptions"], commandParams: ["ssvCommandParams", "commandParams"] }, host: { listeners: { "click": "onClick()" } }, exportAs: ["ssvCommand"], ngImport: i0 });
369
369
  }
370
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: CommandDirective, decorators: [{
370
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: CommandDirective, decorators: [{
371
371
  type: Directive,
372
372
  args: [{
373
373
  selector: `[${NAME_CAMEL$1}]`,
@@ -426,10 +426,10 @@ class CommandRefDirective {
426
426
  this._command.destroy();
427
427
  }
428
428
  }
429
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: CommandRefDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
430
- 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 });
429
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: CommandRefDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
430
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.7", type: CommandRefDirective, isStandalone: true, selector: "[ssvCommandRef]", inputs: { commandCreator: ["ssvCommandRef", "commandCreator"] }, exportAs: ["ssvCommandRef"], ngImport: i0 });
431
431
  }
432
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: CommandRefDirective, decorators: [{
432
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: CommandRefDirective, decorators: [{
433
433
  type: Directive,
434
434
  args: [{
435
435
  selector: `[${NAME_CAMEL}]`,
@@ -446,13 +446,13 @@ const EXPORTED_IMPORTS = [
446
446
  CommandRefDirective
447
447
  ];
448
448
  class SsvCommandModule {
449
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: SsvCommandModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
450
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.9", ngImport: i0, type: SsvCommandModule, imports: [CommandDirective,
449
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: SsvCommandModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
450
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.7", ngImport: i0, type: SsvCommandModule, imports: [CommandDirective,
451
451
  CommandRefDirective], exports: [CommandDirective,
452
452
  CommandRefDirective] });
453
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: SsvCommandModule });
453
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: SsvCommandModule });
454
454
  }
455
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: SsvCommandModule, decorators: [{
455
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: SsvCommandModule, decorators: [{
456
456
  type: NgModule,
457
457
  args: [{
458
458
  imports: [EXPORTED_IMPORTS],
@@ -460,7 +460,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImpor
460
460
  }]
461
461
  }] });
462
462
 
463
- const VERSION = "3.2.0-dev.68";
463
+ const VERSION = "3.3.0-dev.76";
464
464
 
465
465
  /**
466
466
  * Generated bundle index. Do not edit.
@@ -1 +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 { assertInInjectionContext, computed, DestroyRef, inject, Injector, 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 = (() => boolean) | Signal<boolean> | Observable<boolean>;\n\nexport interface CommandCreateOptions {\n\tisAsync: boolean,\n\tinjector?: Injector;\n}\n\nconst COMMAND_ASYNC_DEFAULT_OPTIONS: CommandCreateOptions = { isAsync: true };\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 commandAsync(\n\texecute: ExecuteAsyncFn,\n\tcanExecute$?: CanExecute,\n\topts?: Omit<CommandCreateOptions, \"isAsync\">,\n): Command {\n\treturn command(execute, canExecute$, opts ? { ...opts, ...COMMAND_ASYNC_DEFAULT_OPTIONS } : COMMAND_ASYNC_DEFAULT_OPTIONS);\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 command(\n\texecute: ExecuteFn,\n\tcanExecute$?: CanExecute,\n\topts?: CommandCreateOptions,\n): Command {\n\tif (!opts?.injector) {\n\t\tassertInInjectionContext(command);\n\t}\n\tconst injector = opts?.injector ?? inject(Injector);\n\tconst isAsync = opts?.isAsync ?? false;\n\tconst destroyRef = injector.get(DestroyRef);\n\tconst cmd = new Command(execute, canExecute$, isAsync);\n\tcmd.autoDestroy = false;\n\n\tdestroyRef.onDestroy(() => {\n\t\t// console.warn(\"[command::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 * @deprecated Use {@link command} or {@link commandAsync} instead for creating instances.\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\tinjector?: Injector,\n\t) {\n\t\tif (canExecute$) {\n\t\t\tconst canExecute = typeof canExecute$ === \"function\"\n\t\t\t\t? computed(canExecute$)\n\t\t\t\t: canExecute$;\n\t\t\tthis.canExecute$ = combineLatest([\n\t\t\t\tthis._isExecuting$,\n\t\t\t\tisSignal(canExecute) ? toObservable(canExecute, { injector }) : 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 * @deprecated Use {@link commandAsync} instead.\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, PristineChangeEvent, StatusChangeEvent } from \"@angular/forms\";\nimport { Observable, map, distinctUntilChanged, filter, combineLatest, of, defer, concat } from \"rxjs\";\n\nimport { CommandCreator, ICommand } from \"./command.model\";\nimport { Command } from \"./command\";\nimport { type Signal, computed } from \"@angular/core\";\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\nconst CAN_EXECUTE_FORM_OPTIONS_DEFAULTS = Object.freeze<CanExecuteFormOptions>({\n\tvalidity: true,\n\tdirty: true,\n})\n\n/** Get can execute from form validity/pristine as an observable. */\nexport function canExecuteFromNgForm(\n\tform: AbstractControl,\n\toptions?: CanExecuteFormOptions\n): Observable<boolean> {\n\tconst opts: CanExecuteFormOptions = options ?\n\t\t{ ...CAN_EXECUTE_FORM_OPTIONS_DEFAULTS, ...options }\n\t\t: CAN_EXECUTE_FORM_OPTIONS_DEFAULTS;\n\n\tconst pristine$ = opts.dirty\n\t\t? concat(\n\t\t\tdefer(() => of(form.pristine)),\n\t\t\tform.events.pipe(\n\t\t\t\tfilter(x => x instanceof PristineChangeEvent),\n\t\t\t\tmap(x => x.pristine),\n\t\t\t)\n\t\t).pipe(distinctUntilChanged(),)\n\t\t: of(true);\n\n\tconst valid$ = opts.validity\n\t\t? concat(\n\t\t\tdefer(() => of(form.valid)),\n\t\t\tform.events.pipe(\n\t\t\t\tfilter(x => x instanceof StatusChangeEvent),\n\t\t\t\tmap(x => x.status === \"VALID\"),\n\t\t\t)\n\t\t).pipe(distinctUntilChanged(),)\n\t\t: of(true);\n\n\treturn combineLatest([pristine$, valid$]).pipe(\n\t\tmap(([pristine, valid]) => !!(!opts.validity || valid) && !!(!opts.dirty || !pristine)),\n\t\tdistinctUntilChanged(),\n\t);\n}\n\n/** Can executed based on valid/dirty signal inputs. */\nexport function canExecuteFromSignals(\n\tsignals: { valid: Signal<boolean>, dirty: Signal<boolean> },\n\toptions?: CanExecuteFormOptions\n): Signal<boolean> {\n\tconst opts: CanExecuteFormOptions = options ?\n\t\t{ ...CAN_EXECUTE_FORM_OPTIONS_DEFAULTS, ...options }\n\t\t: CAN_EXECUTE_FORM_OPTIONS_DEFAULTS;\n\treturn computed(() => !!(!opts.validity || signals.valid()) && !!(!opts.dirty || signals.dirty()));\n}\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.2.0-dev.68\";\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;AAkBA,MAAM,6BAA6B,GAAyB,EAAE,OAAO,EAAE,IAAI,E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CAAC;MAMW,gBAAgB,CAAA;uGAAhB,gBAAgB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAhB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,YAR5B,gBAAgB;AAChB,YAAA,mBAAmB,aADnB,gBAAgB;YAChB,mBAAmB,CAAA,EAAA,CAAA,CAAA;wGAOP,gBAAgB,EAAA,CAAA,CAAA;;2FAAhB,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAJ5B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACT,OAAO,EAAE,CAAC,gBAAgB,CAAC;oBAC3B,OAAO,EAAE,CAAC,gBAAgB,CAAC;AAC3B,iBAAA,CAAA;;;ACbM,MAAM,OAAO,GAAG;;ACAvB;;AAEG;;;;"}
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 { assertInInjectionContext, computed, DestroyRef, inject, Injector, 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 = (() => boolean) | Signal<boolean> | Observable<boolean>;\n\nexport interface CommandCreateOptions {\n\tisAsync: boolean,\n\tinjector?: Injector;\n}\n\nconst COMMAND_ASYNC_DEFAULT_OPTIONS: CommandCreateOptions = { isAsync: true };\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 commandAsync(\n\texecute: ExecuteAsyncFn,\n\tcanExecute$?: CanExecute,\n\topts?: Omit<CommandCreateOptions, \"isAsync\">,\n): Command {\n\treturn command(execute, canExecute$, opts ? { ...opts, ...COMMAND_ASYNC_DEFAULT_OPTIONS } : COMMAND_ASYNC_DEFAULT_OPTIONS);\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 command(\n\texecute: ExecuteFn,\n\tcanExecute$?: CanExecute,\n\topts?: CommandCreateOptions,\n): Command {\n\tif (!opts?.injector) {\n\t\tassertInInjectionContext(command);\n\t}\n\tconst injector = opts?.injector ?? inject(Injector);\n\tconst isAsync = opts?.isAsync ?? false;\n\tconst destroyRef = injector.get(DestroyRef);\n\tconst cmd = new Command(execute, canExecute$, isAsync);\n\tcmd.autoDestroy = false;\n\n\tdestroyRef.onDestroy(() => {\n\t\t// console.warn(\"[command::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 * @deprecated Use {@link command} or {@link commandAsync} instead for creating instances.\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\tinjector?: Injector,\n\t) {\n\t\tif (canExecute$) {\n\t\t\tconst canExecute = typeof canExecute$ === \"function\"\n\t\t\t\t? computed(canExecute$)\n\t\t\t\t: canExecute$;\n\t\t\tthis.canExecute$ = combineLatest([\n\t\t\t\tthis._isExecuting$,\n\t\t\t\tisSignal(canExecute) ? toObservable(canExecute, { injector }) : 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 * @deprecated Use {@link commandAsync} instead.\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, PristineChangeEvent, StatusChangeEvent } from \"@angular/forms\";\nimport { Observable, map, distinctUntilChanged, filter, combineLatest, of, defer, concat } from \"rxjs\";\n\nimport { CommandCreator, ICommand } from \"./command.model\";\nimport { Command } from \"./command\";\nimport { type Signal, computed } from \"@angular/core\";\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\nconst CAN_EXECUTE_FORM_OPTIONS_DEFAULTS = Object.freeze<CanExecuteFormOptions>({\n\tvalidity: true,\n\tdirty: true,\n})\n\n/** Get can execute from form validity/pristine as an observable. */\nexport function canExecuteFromNgForm(\n\tform: AbstractControl,\n\toptions?: CanExecuteFormOptions\n): Observable<boolean> {\n\tconst opts: CanExecuteFormOptions = options ?\n\t\t{ ...CAN_EXECUTE_FORM_OPTIONS_DEFAULTS, ...options }\n\t\t: CAN_EXECUTE_FORM_OPTIONS_DEFAULTS;\n\n\tconst pristine$ = opts.dirty\n\t\t? concat(\n\t\t\tdefer(() => of(form.pristine)),\n\t\t\tform.events.pipe(\n\t\t\t\tfilter(x => x instanceof PristineChangeEvent),\n\t\t\t\tmap(x => x.pristine),\n\t\t\t)\n\t\t).pipe(distinctUntilChanged(),)\n\t\t: of(true);\n\n\tconst valid$ = opts.validity\n\t\t? concat(\n\t\t\tdefer(() => of(form.valid)),\n\t\t\tform.events.pipe(\n\t\t\t\tfilter(x => x instanceof StatusChangeEvent),\n\t\t\t\tmap(x => x.status === \"VALID\"),\n\t\t\t)\n\t\t).pipe(distinctUntilChanged(),)\n\t\t: of(true);\n\n\treturn combineLatest([pristine$, valid$]).pipe(\n\t\tmap(([pristine, valid]) => !!(!opts.validity || valid) && !!(!opts.dirty || !pristine)),\n\t\tdistinctUntilChanged(),\n\t);\n}\n\n/** Can executed based on valid/dirty signal inputs. */\nexport function canExecuteFromSignals(\n\tsignals: { valid: Signal<boolean>, dirty: Signal<boolean> },\n\toptions?: CanExecuteFormOptions\n): Signal<boolean> {\n\tconst opts: CanExecuteFormOptions = options ?\n\t\t{ ...CAN_EXECUTE_FORM_OPTIONS_DEFAULTS, ...options }\n\t\t: CAN_EXECUTE_FORM_OPTIONS_DEFAULTS;\n\treturn computed(() => !!(!opts.validity || signals.valid()) && !!(!opts.dirty || signals.dirty()));\n}\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.3.0-dev.76\";\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;AAkBA,MAAM,6BAA6B,GAAyB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAE9E;;AAEG;SACa,YAAY,CAC3B,OAAuB,EACvB,WAAwB,EACxB,IAA4C,EAAA;IAE5C,OAAO,OAAO,CAAC,OAAO,EAAE,WAAW,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AAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,YAR5B,gBAAgB;AAChB,YAAA,mBAAmB,aADnB,gBAAgB;YAChB,mBAAmB,CAAA,EAAA,CAAA,CAAA;wGAOP,gBAAgB,EAAA,CAAA,CAAA;;2FAAhB,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAJ5B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACT,OAAO,EAAE,CAAC,gBAAgB,CAAC;oBAC3B,OAAO,EAAE,CAAC,gBAAgB,CAAC;AAC3B,iBAAA,CAAA;;;ACbM,MAAM,OAAO,GAAG;;ACAvB;;AAEG;;;;"}
package/index.d.ts CHANGED
@@ -1,8 +1,190 @@
1
- export { SsvCommandModule } from "./command.module";
2
- export { provideSsvCommandOptions, COMMAND_OPTIONS, type CommandOptions } from "./command.options";
3
- export { command, commandAsync, Command, CommandAsync, type CanExecute, type CommandCreateOptions } from "./command";
4
- export { CommandDirective } from "./command.directive";
5
- export { CommandRefDirective } from "./command-ref.directive";
6
- export { type CanExecuteFormOptions, isCommand, isCommandCreator, canExecuteFromNgForm, canExecuteFromSignals } from "./command.util";
7
- export type { CommandCreator, ICommand } from "./command.model";
8
- export { VERSION } from "./version";
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, EnvironmentProviders, OnInit, OnDestroy, Signal, Injector } from '@angular/core';
3
+ import { Observable } from 'rxjs';
4
+ import { AbstractControl } from '@angular/forms';
5
+
6
+ interface CommandOptions {
7
+ /**
8
+ * Css Class which gets added/removed on the Command element's host while Command `isExecuting$`.
9
+ */
10
+ executingCssClass: string;
11
+ /** Determines whether the disabled will be handled by the directive or not.
12
+ * Disable handled by directive's doesn't always play nice when used with other component/pipe/directive and they also handle disabled.
13
+ * This disables the handling manually and need to pass explicitly `[disabled]="!saveCmd.canExecute"`.
14
+ */
15
+ handleDisabled: boolean;
16
+ /** Determine whether to set a `delay(1)` when setting the disabled. Which might be needed when working with external
17
+ * components/directives (such as material button)
18
+ */
19
+ hasDisabledDelay: boolean;
20
+ }
21
+ declare const COMMAND_OPTIONS: InjectionToken<CommandOptions>;
22
+ declare function provideSsvCommandOptions(options: Partial<CommandOptions> | ((defaults: Readonly<CommandOptions>) => Partial<CommandOptions>)): EnvironmentProviders;
23
+
24
+ interface ICommand {
25
+ /** Determines whether the command is currently executing, as a snapshot value. */
26
+ readonly isExecuting: boolean;
27
+ /** Determines whether the command is currently executing, as an observable. */
28
+ readonly isExecuting$: Observable<boolean>;
29
+ /** Determines whether the command can execute or not, as a snapshot value. */
30
+ readonly canExecute: boolean;
31
+ /** Determines whether the command can execute or not, as an observable. */
32
+ readonly canExecute$: Observable<boolean>;
33
+ /** Determines whether to auto destroy when having 0 subscribers (defaults to `true`). */
34
+ autoDestroy: boolean;
35
+ /** Execute function to invoke. */
36
+ execute(...args: unknown[]): void;
37
+ /** Disposes all resources held by subscriptions. */
38
+ destroy(): void;
39
+ /** Subscribe listener, in order to handle auto disposing. */
40
+ subscribe(): void;
41
+ /** Unsubscribe listener, in order to handle auto disposing. */
42
+ unsubscribe(): void;
43
+ }
44
+ interface CommandCreator {
45
+ execute: (...args: any[]) => Observable<unknown> | Promise<unknown> | void;
46
+ canExecute?: Observable<boolean> | Function;
47
+ params?: unknown | unknown[];
48
+ isAsync?: boolean;
49
+ host: unknown;
50
+ }
51
+
52
+ declare class CommandDirective implements OnInit, OnDestroy {
53
+ private readonly globalOptions;
54
+ private readonly renderer;
55
+ private readonly element;
56
+ private readonly cdr;
57
+ commandOrCreator: ICommand | CommandCreator | undefined;
58
+ get commandOptions(): CommandOptions;
59
+ set commandOptions(value: Partial<CommandOptions>);
60
+ commandParams: unknown | unknown[];
61
+ get command(): ICommand;
62
+ private _command;
63
+ private _commandOptions;
64
+ private _destroy$;
65
+ ngOnInit(): void;
66
+ onClick(): void;
67
+ ngOnDestroy(): void;
68
+ private trySetDisabled;
69
+ static ɵfac: i0.ɵɵFactoryDeclaration<CommandDirective, never>;
70
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CommandDirective, "[ssvCommand]", ["ssvCommand"], { "commandOrCreator": { "alias": "ssvCommand"; "required": false; }; "commandOptions": { "alias": "ssvCommandOptions"; "required": false; }; "commandParams": { "alias": "ssvCommandParams"; "required": false; }; }, {}, never, never, true, never>;
71
+ }
72
+
73
+ /**
74
+ * Command creator ref, directive which allows creating Command in the template
75
+ * and associate it to a command (in order to share executions).
76
+ * @example
77
+ * ### Most common usage
78
+ * ```html
79
+ * <div #actionCmd="ssvCommandRef" [ssvCommandRef]="{host: this, execute: removeHero$, canExecute: isValid$}">
80
+ * <button [ssvCommand]="actionCmd.command" [ssvCommandParams]="hero">
81
+ * Remove
82
+ * </button>
83
+ * <button [ssvCommand]="actionCmd.command" [ssvCommandParams]="hero">
84
+ * Remove
85
+ * </button>
86
+ * </div>
87
+ * ```
88
+ *
89
+ */
90
+ declare class CommandRefDirective implements OnInit, OnDestroy {
91
+ commandCreator: CommandCreator | undefined;
92
+ get command(): ICommand;
93
+ private _command;
94
+ ngOnInit(): void;
95
+ ngOnDestroy(): void;
96
+ static ɵfac: i0.ɵɵFactoryDeclaration<CommandRefDirective, never>;
97
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CommandRefDirective, "[ssvCommandRef]", ["ssvCommandRef"], { "commandCreator": { "alias": "ssvCommandRef"; "required": false; }; }, {}, never, never, true, never>;
98
+ }
99
+
100
+ declare class SsvCommandModule {
101
+ static ɵfac: i0.ɵɵFactoryDeclaration<SsvCommandModule, never>;
102
+ static ɵmod: i0.ɵɵNgModuleDeclaration<SsvCommandModule, never, [typeof CommandDirective, typeof CommandRefDirective], [typeof CommandDirective, typeof CommandRefDirective]>;
103
+ static ɵinj: i0.ɵɵInjectorDeclaration<SsvCommandModule>;
104
+ }
105
+
106
+ type ExecuteFn = (...args: any[]) => unknown;
107
+ type ExecuteAsyncFn = (...args: any[]) => Observable<unknown> | Promise<unknown>;
108
+ type CanExecute = (() => boolean) | Signal<boolean> | Observable<boolean>;
109
+ interface CommandCreateOptions {
110
+ isAsync: boolean;
111
+ injector?: Injector;
112
+ }
113
+ /** Creates an async {@link Command}. Must be used within an injection context.
114
+ * NOTE: this auto injects `DestroyRef` and handles auto destroy. {@link ICommand.autoDestroy} should not be used.
115
+ */
116
+ declare function commandAsync(execute: ExecuteAsyncFn, canExecute$?: CanExecute, opts?: Omit<CommandCreateOptions, "isAsync">): Command;
117
+ /** Creates a {@link Command}. Must be used within an injection context.
118
+ * NOTE: this auto injects `DestroyRef` and handles auto destroy. {@link ICommand.autoDestroy} should not be used.
119
+ */
120
+ declare function command(execute: ExecuteFn, canExecute$?: CanExecute, opts?: CommandCreateOptions): Command;
121
+ /**
122
+ * Command object used to encapsulate information which is needed to perform an action.
123
+ * @deprecated Use {@link command} or {@link commandAsync} instead for creating instances.
124
+ */
125
+ declare class Command implements ICommand {
126
+ /** Determines whether the command is currently executing, as a snapshot value. */
127
+ get isExecuting(): boolean;
128
+ /** Determines whether the command can execute or not, as a snapshot value. */
129
+ get canExecute(): boolean;
130
+ /** Determines whether the command is currently executing, as an observable. */
131
+ get isExecuting$(): Observable<boolean>;
132
+ /** Determines whether to auto destroy when having 0 subscribers. */
133
+ autoDestroy: boolean;
134
+ /** Determines whether the command can execute or not, as an observable. */
135
+ readonly canExecute$: Observable<boolean>;
136
+ private _isExecuting$;
137
+ private _isExecuting;
138
+ private _canExecute;
139
+ private executionPipe$;
140
+ private isExecuting$$;
141
+ private canExecute$$;
142
+ private executionPipe$$;
143
+ private subscribersCount;
144
+ /**
145
+ * Creates an instance of Command.
146
+ *
147
+ * @param execute Execute function to invoke - use `isAsync: true` when `Observable<any>`.
148
+ * @param canExecute Observable which determines whether it can execute or not.
149
+ * @param isAsync Indicates that the execute function is async e.g. Observable.
150
+ */
151
+ constructor(execute: ExecuteFn, canExecute$?: CanExecute, isAsync?: boolean, injector?: Injector);
152
+ /** Execute function to invoke. */
153
+ execute(...args: unknown[]): void;
154
+ /** Disposes all resources held by subscriptions. */
155
+ destroy(): void;
156
+ subscribe(): void;
157
+ unsubscribe(): void;
158
+ private buildExecutionPipe;
159
+ }
160
+ /**
161
+ * Async Command object used to encapsulate information which is needed to perform an action,
162
+ * which takes an execute function as Observable/Promise.
163
+ * @deprecated Use {@link commandAsync} instead.
164
+ */
165
+ declare class CommandAsync extends Command {
166
+ constructor(execute: ExecuteAsyncFn, canExecute$?: CanExecute);
167
+ }
168
+
169
+ /** Determines whether the arg object is of type `Command`. */
170
+ declare function isCommand(arg: unknown): arg is ICommand;
171
+ /** Determines whether the arg object is of type `CommandCreator`. */
172
+ declare function isCommandCreator(arg: unknown): arg is CommandCreator;
173
+ interface CanExecuteFormOptions {
174
+ /** Determines whether to check for validity. (defaults: true) */
175
+ validity?: boolean;
176
+ /** Determines whether to check whether UI has been touched. (defaults: true) */
177
+ dirty?: boolean;
178
+ }
179
+ /** Get can execute from form validity/pristine as an observable. */
180
+ declare function canExecuteFromNgForm(form: AbstractControl, options?: CanExecuteFormOptions): Observable<boolean>;
181
+ /** Can executed based on valid/dirty signal inputs. */
182
+ declare function canExecuteFromSignals(signals: {
183
+ valid: Signal<boolean>;
184
+ dirty: Signal<boolean>;
185
+ }, options?: CanExecuteFormOptions): Signal<boolean>;
186
+
187
+ declare const VERSION = "3.3.0-dev.76";
188
+
189
+ export { COMMAND_OPTIONS, Command, CommandAsync, CommandDirective, CommandRefDirective, SsvCommandModule, VERSION, canExecuteFromNgForm, canExecuteFromSignals, command, commandAsync, isCommand, isCommandCreator, provideSsvCommandOptions };
190
+ export type { CanExecute, CanExecuteFormOptions, CommandCreateOptions, CommandCreator, CommandOptions, ICommand };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssv/ngx.command",
3
- "version": "3.2.0-dev.68",
3
+ "version": "3.3.0-dev.76",
4
4
  "versionSuffix": "",
5
5
  "description": "Command pattern implementation for angular. Command used to encapsulate information which is needed to perform an action.",
6
6
  "keywords": [
@@ -36,8 +36,6 @@
36
36
  },
37
37
  ".": {
38
38
  "types": "./index.d.ts",
39
- "esm2022": "./esm2022/ssv-ngx.command.mjs",
40
- "esm": "./esm2022/ssv-ngx.command.mjs",
41
39
  "default": "./fesm2022/ssv-ngx.command.mjs"
42
40
  }
43
41
  }
@@ -1,29 +0,0 @@
1
- import { OnInit, OnDestroy } from "@angular/core";
2
- import { ICommand, CommandCreator } from "./command.model";
3
- import * as i0 from "@angular/core";
4
- /**
5
- * Command creator ref, directive which allows creating Command in the template
6
- * and associate it to a command (in order to share executions).
7
- * @example
8
- * ### Most common usage
9
- * ```html
10
- * <div #actionCmd="ssvCommandRef" [ssvCommandRef]="{host: this, execute: removeHero$, canExecute: isValid$}">
11
- * <button [ssvCommand]="actionCmd.command" [ssvCommandParams]="hero">
12
- * Remove
13
- * </button>
14
- * <button [ssvCommand]="actionCmd.command" [ssvCommandParams]="hero">
15
- * Remove
16
- * </button>
17
- * </div>
18
- * ```
19
- *
20
- */
21
- export declare class CommandRefDirective implements OnInit, OnDestroy {
22
- commandCreator: CommandCreator | undefined;
23
- get command(): ICommand;
24
- private _command;
25
- ngOnInit(): void;
26
- ngOnDestroy(): void;
27
- static ɵfac: i0.ɵɵFactoryDeclaration<CommandRefDirective, never>;
28
- static ɵdir: i0.ɵɵDirectiveDeclaration<CommandRefDirective, "[ssvCommandRef]", ["ssvCommandRef"], { "commandCreator": { "alias": "ssvCommandRef"; "required": false; }; }, {}, never, never, true, never>;
29
- }
package/command.d.ts DELETED
@@ -1,65 +0,0 @@
1
- import { Observable } from "rxjs";
2
- import type { ICommand } from "./command.model";
3
- import { Injector, type Signal } from "@angular/core";
4
- export type ExecuteFn = (...args: any[]) => unknown;
5
- export type ExecuteAsyncFn = (...args: any[]) => Observable<unknown> | Promise<unknown>;
6
- export type CanExecute = (() => boolean) | Signal<boolean> | Observable<boolean>;
7
- export interface CommandCreateOptions {
8
- isAsync: boolean;
9
- injector?: Injector;
10
- }
11
- /** Creates an async {@link Command}. Must be used within an injection context.
12
- * NOTE: this auto injects `DestroyRef` and handles auto destroy. {@link ICommand.autoDestroy} should not be used.
13
- */
14
- export declare function commandAsync(execute: ExecuteAsyncFn, canExecute$?: CanExecute, opts?: Omit<CommandCreateOptions, "isAsync">): Command;
15
- /** Creates a {@link Command}. Must be used within an injection context.
16
- * NOTE: this auto injects `DestroyRef` and handles auto destroy. {@link ICommand.autoDestroy} should not be used.
17
- */
18
- export declare function command(execute: ExecuteFn, canExecute$?: CanExecute, opts?: CommandCreateOptions): Command;
19
- /**
20
- * Command object used to encapsulate information which is needed to perform an action.
21
- * @deprecated Use {@link command} or {@link commandAsync} instead for creating instances.
22
- */
23
- export declare class Command implements ICommand {
24
- /** Determines whether the command is currently executing, as a snapshot value. */
25
- get isExecuting(): boolean;
26
- /** Determines whether the command can execute or not, as a snapshot value. */
27
- get canExecute(): boolean;
28
- /** Determines whether the command is currently executing, as an observable. */
29
- get isExecuting$(): Observable<boolean>;
30
- /** Determines whether to auto destroy when having 0 subscribers. */
31
- autoDestroy: boolean;
32
- /** Determines whether the command can execute or not, as an observable. */
33
- readonly canExecute$: Observable<boolean>;
34
- private _isExecuting$;
35
- private _isExecuting;
36
- private _canExecute;
37
- private executionPipe$;
38
- private isExecuting$$;
39
- private canExecute$$;
40
- private executionPipe$$;
41
- private subscribersCount;
42
- /**
43
- * Creates an instance of Command.
44
- *
45
- * @param execute Execute function to invoke - use `isAsync: true` when `Observable<any>`.
46
- * @param canExecute Observable which determines whether it can execute or not.
47
- * @param isAsync Indicates that the execute function is async e.g. Observable.
48
- */
49
- constructor(execute: ExecuteFn, canExecute$?: CanExecute, isAsync?: boolean, injector?: Injector);
50
- /** Execute function to invoke. */
51
- execute(...args: unknown[]): void;
52
- /** Disposes all resources held by subscriptions. */
53
- destroy(): void;
54
- subscribe(): void;
55
- unsubscribe(): void;
56
- private buildExecutionPipe;
57
- }
58
- /**
59
- * Async Command object used to encapsulate information which is needed to perform an action,
60
- * which takes an execute function as Observable/Promise.
61
- * @deprecated Use {@link commandAsync} instead.
62
- */
63
- export declare class CommandAsync extends Command {
64
- constructor(execute: ExecuteAsyncFn, canExecute$?: CanExecute);
65
- }
@@ -1,24 +0,0 @@
1
- import { OnInit, OnDestroy } from "@angular/core";
2
- import { type CommandOptions } from "./command.options";
3
- import { CommandCreator, type ICommand } from "./command.model";
4
- import * as i0 from "@angular/core";
5
- export declare class CommandDirective implements OnInit, OnDestroy {
6
- private readonly globalOptions;
7
- private readonly renderer;
8
- private readonly element;
9
- private readonly cdr;
10
- commandOrCreator: ICommand | CommandCreator | undefined;
11
- get commandOptions(): CommandOptions;
12
- set commandOptions(value: Partial<CommandOptions>);
13
- commandParams: unknown | unknown[];
14
- get command(): ICommand;
15
- private _command;
16
- private _commandOptions;
17
- private _destroy$;
18
- ngOnInit(): void;
19
- onClick(): void;
20
- ngOnDestroy(): void;
21
- private trySetDisabled;
22
- static ɵfac: i0.ɵɵFactoryDeclaration<CommandDirective, never>;
23
- static ɵdir: i0.ɵɵDirectiveDeclaration<CommandDirective, "[ssvCommand]", ["ssvCommand"], { "commandOrCreator": { "alias": "ssvCommand"; "required": false; }; "commandOptions": { "alias": "ssvCommandOptions"; "required": false; }; "commandParams": { "alias": "ssvCommandParams"; "required": false; }; }, {}, never, never, true, never>;
24
- }
@@ -1,28 +0,0 @@
1
- import { Observable } from "rxjs";
2
- export interface ICommand {
3
- /** Determines whether the command is currently executing, as a snapshot value. */
4
- readonly isExecuting: boolean;
5
- /** Determines whether the command is currently executing, as an observable. */
6
- readonly isExecuting$: Observable<boolean>;
7
- /** Determines whether the command can execute or not, as a snapshot value. */
8
- readonly canExecute: boolean;
9
- /** Determines whether the command can execute or not, as an observable. */
10
- readonly canExecute$: Observable<boolean>;
11
- /** Determines whether to auto destroy when having 0 subscribers (defaults to `true`). */
12
- autoDestroy: boolean;
13
- /** Execute function to invoke. */
14
- execute(...args: unknown[]): void;
15
- /** Disposes all resources held by subscriptions. */
16
- destroy(): void;
17
- /** Subscribe listener, in order to handle auto disposing. */
18
- subscribe(): void;
19
- /** Unsubscribe listener, in order to handle auto disposing. */
20
- unsubscribe(): void;
21
- }
22
- export interface CommandCreator {
23
- execute: (...args: any[]) => Observable<unknown> | Promise<unknown> | void;
24
- canExecute?: Observable<boolean> | Function;
25
- params?: unknown | unknown[];
26
- isAsync?: boolean;
27
- host: unknown;
28
- }
@@ -1,8 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- import * as i1 from "./command.directive";
3
- import * as i2 from "./command-ref.directive";
4
- export declare class SsvCommandModule {
5
- static ɵfac: i0.ɵɵFactoryDeclaration<SsvCommandModule, never>;
6
- static ɵmod: i0.ɵɵNgModuleDeclaration<SsvCommandModule, never, [typeof i1.CommandDirective, typeof i2.CommandRefDirective], [typeof i1.CommandDirective, typeof i2.CommandRefDirective]>;
7
- static ɵinj: i0.ɵɵInjectorDeclaration<SsvCommandModule>;
8
- }
@@ -1,18 +0,0 @@
1
- import { type EnvironmentProviders, InjectionToken } from "@angular/core";
2
- export interface CommandOptions {
3
- /**
4
- * Css Class which gets added/removed on the Command element's host while Command `isExecuting$`.
5
- */
6
- executingCssClass: string;
7
- /** Determines whether the disabled will be handled by the directive or not.
8
- * Disable handled by directive's doesn't always play nice when used with other component/pipe/directive and they also handle disabled.
9
- * This disables the handling manually and need to pass explicitly `[disabled]="!saveCmd.canExecute"`.
10
- */
11
- handleDisabled: boolean;
12
- /** Determine whether to set a `delay(1)` when setting the disabled. Which might be needed when working with external
13
- * components/directives (such as material button)
14
- */
15
- hasDisabledDelay: boolean;
16
- }
17
- export declare const COMMAND_OPTIONS: InjectionToken<CommandOptions>;
18
- export declare function provideSsvCommandOptions(options: Partial<CommandOptions> | ((defaults: Readonly<CommandOptions>) => Partial<CommandOptions>)): EnvironmentProviders;