From d30aa45c9031870585390004a345cdd4ff51c1b0 Mon Sep 17 00:00:00 2001 From: astrutz Date: Fri, 23 Feb 2024 12:01:59 +0100 Subject: [PATCH 1/2] feat(app): display inputsignals as inputs rather than properties --- src/app/compiler/angular-dependencies.ts | 4 ++-- .../angular/deps/component-dep.factory.ts | 3 +++ .../angular/deps/directive-dep.factory.ts | 2 +- .../angular/deps/helpers/component-helper.ts | 15 +++++++++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/app/compiler/angular-dependencies.ts b/src/app/compiler/angular-dependencies.ts index 737e9c8c3..9839dfc11 100644 --- a/src/app/compiler/angular-dependencies.ts +++ b/src/app/compiler/angular-dependencies.ts @@ -272,8 +272,8 @@ export class AngularDependencies extends FrameworkDependencies { if (IO.accessors) { deps.accessors = IO.accessors; } - if (IO.inputs) { - deps.inputsClass = IO.inputs; + if (IO.inputs || IO.properties) { + deps.inputsClass = this.componentHelper.getInputSignals(IO.properties).concat(IO.inputs); } if (IO.outputs) { deps.outputsClass = IO.outputs; diff --git a/src/app/compiler/angular/deps/component-dep.factory.ts b/src/app/compiler/angular/deps/component-dep.factory.ts index 2d6b59df1..6c4cc213e 100644 --- a/src/app/compiler/angular/deps/component-dep.factory.ts +++ b/src/app/compiler/angular/deps/component-dep.factory.ts @@ -88,6 +88,9 @@ export class ComponentDepFactory { if (IO.accessors) { componentDep.accessors = IO.accessors; } + if (IO.properties) { + componentDep.inputsClass = componentDep.inputsClass.concat(this.helper.getInputSignals(IO.properties)); + } return componentDep; } diff --git a/src/app/compiler/angular/deps/directive-dep.factory.ts b/src/app/compiler/angular/deps/directive-dep.factory.ts index 5846599bb..e0ccfb189 100644 --- a/src/app/compiler/angular/deps/directive-dep.factory.ts +++ b/src/app/compiler/angular/deps/directive-dep.factory.ts @@ -26,7 +26,7 @@ export class DirectiveDepFactory { standalone: this.helper.getComponentStandalone(props, srcFile) ? true : false, - inputsClass: IO.inputs, + inputsClass: this.helper.getInputSignals(IO.properties).concat(IO.inputs), outputsClass: IO.outputs, deprecated: IO.deprecated, diff --git a/src/app/compiler/angular/deps/helpers/component-helper.ts b/src/app/compiler/angular/deps/helpers/component-helper.ts index 7dc259c6d..46e804046 100644 --- a/src/app/compiler/angular/deps/helpers/component-helper.ts +++ b/src/app/compiler/angular/deps/helpers/component-helper.ts @@ -135,6 +135,21 @@ export class ComponentHelper { return this.symbolHelper.getSymbolDeps(props, 'inputs', srcFile); } + public getInputSignals(props) { + let inputSignals = []; + props?.forEach((prop, i) => { + const regexp = /input(?:\.(required))?(?:<([\w-]+)>)?\(([\w-]+)?\)/; + const res = regexp.exec(prop.defaultValue); + if (res) { + const newInput = prop; + newInput.defaultValue = res[res.length - 1]; + newInput.required = res[0]?.includes('.required') ?? false; + inputSignals.push(newInput); + } + }); + return inputSignals; + } + public getComponentStandalone( props: ReadonlyArray, srcFile: ts.SourceFile From ad1e481c1f7a9a6f95b7bd82e505314104c32465 Mon Sep 17 00:00:00 2001 From: Alexander Strutz Date: Thu, 29 Feb 2024 13:01:02 +0100 Subject: [PATCH 2/2] fix(app): don't concat on undefined values --- src/app/compiler/angular-dependencies.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/compiler/angular-dependencies.ts b/src/app/compiler/angular-dependencies.ts index 9839dfc11..5002bfd18 100644 --- a/src/app/compiler/angular-dependencies.ts +++ b/src/app/compiler/angular-dependencies.ts @@ -248,8 +248,12 @@ export class AngularDependencies extends FrameworkDependencies { if (IO.constructor && !Configuration.mainData.disableConstructors) { deps.constructorObj = IO.constructor; } + if (IO.inputs) { + deps.inputsClass = IO.inputs; + } if (IO.properties) { deps.properties = IO.properties; + deps.inputsClass = deps.inputsClass ? deps.inputsClass.concat(this.componentHelper.getInputSignals(IO.properties)) : this.componentHelper.getInputSignals(IO.properties); } if (IO.description) { deps.description = IO.description; @@ -272,9 +276,6 @@ export class AngularDependencies extends FrameworkDependencies { if (IO.accessors) { deps.accessors = IO.accessors; } - if (IO.inputs || IO.properties) { - deps.inputsClass = this.componentHelper.getInputSignals(IO.properties).concat(IO.inputs); - } if (IO.outputs) { deps.outputsClass = IO.outputs; } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy