From abb7420ce7fac004a861f4b4c7de0a4b46c9767f Mon Sep 17 00:00:00 2001 From: cha0s Date: Mon, 22 Jun 2020 05:47:28 -0500 Subject: [PATCH] refactor: flat onChange --- src/client/types/actions.type-renderer.jsx | 4 +-- src/client/types/bool.type-renderer.jsx | 4 +-- src/client/types/condition.type-renderer.jsx | 28 +++++++++----------- src/client/types/literal.type-renderer.jsx | 4 +-- src/client/types/number.type-renderer.jsx | 4 +-- src/client/types/routines.type-renderer.jsx | 4 +-- src/client/types/string.type-renderer.jsx | 4 +-- src/client/types/traversal.type-renderer.jsx | 6 ++--- src/client/types/vector.type-renderer.jsx | 12 +++------ src/client/value.jsx | 4 +-- src/common/resources/entity/trait-pane.jsx | 4 +-- 11 files changed, 31 insertions(+), 47 deletions(-) diff --git a/src/client/types/actions.type-renderer.jsx b/src/client/types/actions.type-renderer.jsx index 8a3f038..fc577b1 100644 --- a/src/client/types/actions.type-renderer.jsx +++ b/src/client/types/actions.type-renderer.jsx @@ -13,7 +13,7 @@ const decorate = compose( const Actions = ({ context, - dispatchers, + onChange = () => {}, value, }) => (
@@ -24,7 +24,7 @@ const Actions = ({ (traversal, i) => ( // eslint-disable-next-line react/no-array-index-key
  • - +
  • ), ) diff --git a/src/client/types/bool.type-renderer.jsx b/src/client/types/bool.type-renderer.jsx index 0685a81..9e72192 100644 --- a/src/client/types/bool.type-renderer.jsx +++ b/src/client/types/bool.type-renderer.jsx @@ -4,9 +4,7 @@ import React from 'react'; import propTypes from './prop-types'; const Bool = ({ - dispatchers: { - onChange = () => {}, - } = {}, + onChange = () => {}, value, }) => ( opDispatchers.onChange(event.target.value, event)} + onChange={(event) => opOnChange(event.target.value, event)} ref={operatorRef} value={value.operator} > @@ -78,7 +76,7 @@ const Condition = ({ @@ -89,7 +87,7 @@ const Condition = ({ diff --git a/src/client/types/literal.type-renderer.jsx b/src/client/types/literal.type-renderer.jsx index b04bb7f..3625afb 100644 --- a/src/client/types/literal.type-renderer.jsx +++ b/src/client/types/literal.type-renderer.jsx @@ -13,7 +13,7 @@ const decorate = compose( const Literal = ({ context, - dispatchers, + onChange = () => {}, value, }) => { const typeRenderers = useTypeRenderers(); @@ -30,7 +30,7 @@ const Literal = ({ .map((option) => ) } - {Component ? : null} + {Component ? : null}
    ); }; diff --git a/src/client/types/number.type-renderer.jsx b/src/client/types/number.type-renderer.jsx index dccfb01..a3d60d5 100644 --- a/src/client/types/number.type-renderer.jsx +++ b/src/client/types/number.type-renderer.jsx @@ -10,9 +10,7 @@ const decorate = compose( ); const Number = ({ - dispatchers: { - onChange = () => {}, - } = {}, + onChange = () => {}, options, value, }) => { diff --git a/src/client/types/routines.type-renderer.jsx b/src/client/types/routines.type-renderer.jsx index 4dcf5ba..c1a9b08 100644 --- a/src/client/types/routines.type-renderer.jsx +++ b/src/client/types/routines.type-renderer.jsx @@ -12,7 +12,7 @@ const decorate = compose( const Routines = ({ context, - dispatchers, + onChange = () => {}, value, }) => { const entries = value.routines ? Object.entries(value.routines) : []; @@ -28,7 +28,7 @@ const Routines = ({ {name} diff --git a/src/client/types/string.type-renderer.jsx b/src/client/types/string.type-renderer.jsx index c599285..f137b75 100644 --- a/src/client/types/string.type-renderer.jsx +++ b/src/client/types/string.type-renderer.jsx @@ -4,9 +4,7 @@ import React from 'react'; import propTypes from './prop-types'; const String = ({ - dispatchers: { - onChange = () => {}, - } = {}, + onChange = () => {}, options, value, }) => ( diff --git a/src/client/types/traversal.type-renderer.jsx b/src/client/types/traversal.type-renderer.jsx index 926c138..e70d8ea 100644 --- a/src/client/types/traversal.type-renderer.jsx +++ b/src/client/types/traversal.type-renderer.jsx @@ -14,7 +14,7 @@ const decorate = compose( const Traversal = (props) => { const { context, - dispatchers, + onChange = () => {}, value: {steps, value}, } = props; const stepsType = typeFromSteps(context, steps); @@ -50,7 +50,7 @@ const Traversal = (props) => { {arg.label} @@ -72,7 +72,7 @@ const Traversal = (props) => { = diff --git a/src/client/types/vector.type-renderer.jsx b/src/client/types/vector.type-renderer.jsx index cce0fa4..4a13c38 100644 --- a/src/client/types/vector.type-renderer.jsx +++ b/src/client/types/vector.type-renderer.jsx @@ -11,23 +11,17 @@ const decorate = compose( ); const Vector = ({ - dispatchers: { - onChange = () => {}, - } = {}, + onChange = () => {}, value, }) => ( onChange([axe, value[1]]), - }} + onChange={(axe) => onChange([axe, value[1]])} value={value[0]} /> {' x '} onChange([value[0], axe]), - }} + onChange={(axe) => onChange([value[0], axe])} value={value[1]} /> diff --git a/src/client/value.jsx b/src/client/value.jsx index f0193ab..4473671 100644 --- a/src/client/value.jsx +++ b/src/client/value.jsx @@ -14,7 +14,7 @@ const decorate = compose( const Value = ({ context, - dispatchers, + onChange = () => {}, options, type: typeHint, value, @@ -36,7 +36,7 @@ const Value = ({ ? ( (trait)
    dispatch(setTraitProperty({...payload, value})), - }} + onChange={(value) => dispatch(setTraitProperty({...payload, value}))} options={options} type={type} value={values[key]}