From cefe77bc0e4f9420d2479ce45187ebe5c466c6bb Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sun, 28 Dec 2025 01:09:02 +0000 Subject: [PATCH] Enhance ObjectProperty component to support conditional input rendering - Added `useFormItem` prop to control input rendering behavior. - Refactored input rendering logic to streamline component structure and improve maintainability. - Updated various input types to utilize the new `inputProps` for consistent handling of properties. --- .../Dashboard/common/ObjectProperty.jsx | 310 ++++++++---------- 1 file changed, 138 insertions(+), 172 deletions(-) diff --git a/src/components/Dashboard/common/ObjectProperty.jsx b/src/components/Dashboard/common/ObjectProperty.jsx index bfa623f..0f52cad 100644 --- a/src/components/Dashboard/common/ObjectProperty.jsx +++ b/src/components/Dashboard/common/ObjectProperty.jsx @@ -85,6 +85,7 @@ const ObjectProperty = ({ minimal = false, previewOpen = false, showPreview = true, + useFormItem = true, options = [], roundNumber = false, fixedNumber = false, @@ -613,254 +614,218 @@ const ObjectProperty = ({ mergedFormItemProps.onChange = onChange } - switch (type) { - case 'netGross': - return ( - + const inputProps = useFormItem + ? {} + : { + value, + onChange, + disabled + } + + const renderInput = () => { + switch (type) { + case 'netGross': + return ( - - ) - case 'secret': - return ( - + ) + case 'secret': + return ( visible ? : } + {...mergedFormItemProps} + {...inputProps} /> - - ) - case 'wsprotocol': - return ( - + ) + case 'wsprotocol': + return ( - - ) - case 'bool': - return ( - - - - ) - case 'dateTime': - return ( - ({ value: v ? dayjs(v) : null })} - > + ) + case 'bool': + return ( + + ) + case 'dateTime': + return ( - - ) - case 'country': - return ( - - - - ) - case 'color': - return ( - v} - > - - - ) - case 'weight': - return ( - + ) + case 'country': + return + case 'color': + return ( + + ) + case 'weight': + return ( - - ) - case 'number': - return ( - + ) + case 'number': + return ( - - ) - case 'text': - return ( - - - - ) - case 'codeBlock': - return ( - + ) + case 'text': + return + case 'codeBlock': + return ( - - ) - case 'markdown': - return ( - - - - ) - case 'material': - return ( - + ) + case 'markdown': + return + case 'material': + return ( } - default: - return ( - - - - ) } + + if (!useFormItem) { + return renderInput() + } + + return ( + v } + : {})} + {...(type === 'dateTime' + ? { getValueProps: (v) => ({ value: v ? dayjs(v) : null }) } + : {})} + > + {renderInput()} + + ) } const property = renderProperty() @@ -892,6 +857,7 @@ ObjectProperty.propTypes = { height: PropTypes.string, previewOpen: PropTypes.bool, showPreview: PropTypes.bool, + useFormItem: PropTypes.bool, showHyperlink: PropTypes.bool, options: PropTypes.array, showSince: PropTypes.bool,