From e2a2e42712b6a4d831d028557366982bdb920125 Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 16 Nov 2022 14:46:04 -0500 Subject: [PATCH] updated a couple form components to work with carbon w/ burnettk cullerton --- .../src/components/ProcessGroupForm.tsx | 6 +--- .../BaseInputTemplate/BaseInputTemplate.tsx | 36 +++++++++++-------- .../carbon/SubmitButton/SubmitButton.tsx | 31 ++++++++-------- .../src/themes/carbon/index.css | 3 ++ .../src/themes/carbon/index.ts | 1 + 5 files changed, 42 insertions(+), 35 deletions(-) create mode 100644 spiffworkflow-frontend/src/themes/carbon/index.css diff --git a/spiffworkflow-frontend/src/components/ProcessGroupForm.tsx b/spiffworkflow-frontend/src/components/ProcessGroupForm.tsx index 3d51adeb..e427f43b 100644 --- a/spiffworkflow-frontend/src/components/ProcessGroupForm.tsx +++ b/spiffworkflow-frontend/src/components/ProcessGroupForm.tsx @@ -165,11 +165,7 @@ export default function ProcessGroupForm({ }; const formButtons = () => { - const buttons = [ - , - ]; + const buttons = []; if (mode === 'edit') { buttons.push( ) => + }: React.ChangeEvent) => { onChange(value === '' ? options.emptyValue : value); - const _onBlur = ({ target: { value } }: React.FocusEvent) => - onBlur(id, value); - const _onFocus = ({ + }; + const localOnBlur = ({ + // eslint-disable-next-line no-shadow + target: { value }, + }: React.FocusEvent) => onBlur(id, value); + const localOnFocus = ({ + // eslint-disable-next-line no-shadow target: { value }, }: React.FocusEvent) => onFocus(id, value); @@ -50,7 +55,7 @@ function BaseInputTemplate({ return ( <> - 0} - onChange={_onChange} - onBlur={_onBlur} - onFocus={_onFocus} - {...(textFieldProps as TextFieldProps)} + onChange={localOnChange} + onBlur={localOnBlur} + onFocus={localOnFocus} + // eslint-disable-next-line react/jsx-props-no-spreading + {...otherProps} /> {schema.examples && ( {(schema.examples as string[]) .concat(schema.default ? ([schema.default] as string[]) : []) .map((example: any) => { + // eslint-disable-next-line jsx-a11y/control-has-associated-label return diff --git a/spiffworkflow-frontend/src/themes/carbon/SubmitButton/SubmitButton.tsx b/spiffworkflow-frontend/src/themes/carbon/SubmitButton/SubmitButton.tsx index b61d30c8..07a6298d 100644 --- a/spiffworkflow-frontend/src/themes/carbon/SubmitButton/SubmitButton.tsx +++ b/spiffworkflow-frontend/src/themes/carbon/SubmitButton/SubmitButton.tsx @@ -1,29 +1,30 @@ import React from 'react'; -import Box from '@mui/material/Box'; -import Button from '@mui/material/Button'; +// import Box from '@mui/material/Box'; +// @ts-ignore +import { Button } from '@carbon/react'; import { SubmitButtonProps, getSubmitButtonOptions } from '@rjsf/utils'; -const SubmitButton: React.ComponentType = (props) => { +// const SubmitButton: React.ComponentType = (props) => { +function SubmitButton(props: SubmitButtonProps) { + const { uiSchema } = props; const { submitText, norender, props: submitButtonProps, - } = getSubmitButtonOptions(props.uiSchema); + } = getSubmitButtonOptions(uiSchema); if (norender) { return null; } return ( - - - + ); -}; +} export default SubmitButton; diff --git a/spiffworkflow-frontend/src/themes/carbon/index.css b/spiffworkflow-frontend/src/themes/carbon/index.css new file mode 100644 index 00000000..d44ae7e5 --- /dev/null +++ b/spiffworkflow-frontend/src/themes/carbon/index.css @@ -0,0 +1,3 @@ +button.react-json-schema-form-submit-button { + margin-top: 1.5em; +} diff --git a/spiffworkflow-frontend/src/themes/carbon/index.ts b/spiffworkflow-frontend/src/themes/carbon/index.ts index 7da74d8f..cc3d2254 100644 --- a/spiffworkflow-frontend/src/themes/carbon/index.ts +++ b/spiffworkflow-frontend/src/themes/carbon/index.ts @@ -1,4 +1,5 @@ import MuiForm from './MuiForm/MuiForm'; +import './index.css'; export { default as Form } from './MuiForm'; export { default as Templates } from './Templates';