From 2b10241ac38d5bf1aab43d11aa26b16d968cdcdb Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Mon, 24 Oct 2022 20:33:54 +0200 Subject: [PATCH] WIP: FEATURE Infer props from component ``` @propTypes { text = PackageFactory.AtomicFusion.PropTypes:PropsFromComponent { type = "Foo.Bar:Text" isRequired = true } } ``` --- Configuration/Development/Settings.yaml | 5 ----- Configuration/Settings.yaml | 6 ++++++ Resources/Private/Fusion/Root.fusion | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Configuration/Development/Settings.yaml b/Configuration/Development/Settings.yaml index e99a425..0065214 100644 --- a/Configuration/Development/Settings.yaml +++ b/Configuration/Development/Settings.yaml @@ -3,8 +3,3 @@ PackageFactory: PropTypes: enable: true -Neos: - Neos: - fusion: - autoInclude: - 'PackageFactory.AtomicFusion.PropTypes': true diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index 7cba3e3..e3dbc41 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -7,3 +7,9 @@ Neos: Fusion: defaultContext: PropTypes: \PackageFactory\AtomicFusion\PropTypes\Eel\PropTypesHelper + + Neos: + Neos: + fusion: + autoInclude: + 'PackageFactory.AtomicFusion.PropTypes': true diff --git a/Resources/Private/Fusion/Root.fusion b/Resources/Private/Fusion/Root.fusion index 1da4ebe..aaabb25 100644 --- a/Resources/Private/Fusion/Root.fusion +++ b/Resources/Private/Fusion/Root.fusion @@ -1,4 +1,5 @@ // this is only included in dev context +// todo not anymore prototype(Neos.Fusion:Component) { @exceptionHandler = 'PackageFactory\\AtomicFusion\\PropTypes\\Error\\ExceptionHandler\\PropTypeExceptionHandler' } @@ -6,3 +7,25 @@ prototype(Neos.Fusion:Component) { prototype(PackageFactory.AtomicFusion:Component) { @exceptionHandler = 'PackageFactory\\AtomicFusion\\PropTypes\\Error\\ExceptionHandler\\PropTypeExceptionHandler' } + +prototype(PackageFactory.AtomicFusion.PropTypes:PropsFromComponent) < prototype(Neos.Fusion:Value) { + type = null + isRequired = false + + @context.type = ${this.type} + value = Neos.Fusion:Renderer { + renderPath = ${'/<' + type + '>/__meta/propTypes'} + @process.propsArrayToPropTypes = ${PropTypes.dataStructure(value)} + } + + @process.makeRequired = ${this.isRequired ? value.isRequired : value} + @process.makeRequired.@position = "end" + +} + +prototype(PackageFactory.AtomicFusion.PropTypes:ArrayOfPropsFromComponent) < prototype(PackageFactory.AtomicFusion.PropTypes:ForComponent) { + type = null + isRequired = false + + @process.makeArrayOf = ${PropTypes.arrayOf(value)} +}