diff --git a/spiffworkflow-frontend/src/routes/TaskShow.tsx b/spiffworkflow-frontend/src/routes/TaskShow.tsx index f08bf9046..83e5df3f0 100644 --- a/spiffworkflow-frontend/src/routes/TaskShow.tsx +++ b/spiffworkflow-frontend/src/routes/TaskShow.tsx @@ -217,7 +217,7 @@ export default function TaskShow() { return ( - +
= ({ - uiSchema, - ...props -}) => { +// @ts-ignore +import { AddAlt } from '@carbon/icons-react'; + +import IconButton from '../IconButton/IconButton'; + +/** The `AddButton` renders a button that represent the `Add` action on a form + */ +export default function AddButton< + T = any, + S extends StrictRJSFSchema = RJSFSchema, + F extends FormContextType = any +>({ className, onClick, disabled, registry }: IconButtonProps) { return ( - - - +
+

+ +

+
); -}; - -export default AddButton; +} diff --git a/spiffworkflow-frontend/src/themes/carbon/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx b/spiffworkflow-frontend/src/themes/carbon/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx index cf596f982..cf1d2e353 100644 --- a/spiffworkflow-frontend/src/themes/carbon/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +++ b/spiffworkflow-frontend/src/themes/carbon/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx @@ -5,6 +5,11 @@ import { RJSFSchema, StrictRJSFSchema, } from '@rjsf/utils'; +import { + Grid, + Column, + // @ts-ignore +} from '@carbon/react'; /** The `ArrayFieldItemTemplate` component is the template used to render an items of an array. * @@ -33,53 +38,57 @@ export default function ArrayFieldItemTemplate< const { MoveDownButton, MoveUpButton, RemoveButton } = registry.templates.ButtonTemplates; const btnStyle: CSSProperties = { - flex: 1, - paddingLeft: 6, - paddingRight: 6, - fontWeight: 'bold', + marginBottom: '0.5em', }; + const mainColumnWidthSmall = 3; + const mainColumnWidthMedium = 4; + const mainColumnWidthLarge = 7; return (
-
{children}
- {hasToolbar && ( -
-
- {(hasMoveUp || hasMoveDown) && ( - - )} - {(hasMoveUp || hasMoveDown) && ( - - )} - {hasRemove && ( - - )} -
-
- )} + + + {children} + + {hasToolbar && ( + +
+
+ {(hasMoveUp || hasMoveDown) && ( + + )} + {(hasMoveUp || hasMoveDown) && ( + + )} + {hasRemove && ( + + )} +
+
+
+ )} +
); } diff --git a/spiffworkflow-frontend/src/themes/carbon/BaseInputTemplate/BaseInputTemplate.tsx b/spiffworkflow-frontend/src/themes/carbon/BaseInputTemplate/BaseInputTemplate.tsx index 7954a0ace..699ffeb90 100644 --- a/spiffworkflow-frontend/src/themes/carbon/BaseInputTemplate/BaseInputTemplate.tsx +++ b/spiffworkflow-frontend/src/themes/carbon/BaseInputTemplate/BaseInputTemplate.tsx @@ -85,6 +85,11 @@ export default function BaseInputTemplate< labelToUse = `${labelToUse}*`; } + let helperText = null; + if (uiSchema && uiSchema['ui:help']) { + helperText = uiSchema['ui:help']; + } + let invalid = false; let errorMessageForField = null; if (rawErrors && rawErrors.length > 0) { @@ -102,7 +107,7 @@ export default function BaseInputTemplate< id={id} name={id} className="input" - labelText={labelToUse} + helperText={helperText} invalid={invalid} invalidText={errorMessageForField} autoFocus={autofocus} diff --git a/spiffworkflow-frontend/src/themes/carbon/FieldHelpTemplate/FieldHelpTemplate.tsx b/spiffworkflow-frontend/src/themes/carbon/FieldHelpTemplate/FieldHelpTemplate.tsx index 08a61aeb4..da4543f24 100644 --- a/spiffworkflow-frontend/src/themes/carbon/FieldHelpTemplate/FieldHelpTemplate.tsx +++ b/spiffworkflow-frontend/src/themes/carbon/FieldHelpTemplate/FieldHelpTemplate.tsx @@ -7,10 +7,8 @@ import FormHelperText from '@mui/material/FormHelperText'; * @param props - The `FieldHelpProps` to be rendered */ export default function FieldHelpTemplate(props: FieldHelpProps) { - const { idSchema, help } = props; - if (!help) { - return null; - } - const id = `${idSchema.$id}__help`; - return {help}; + // ui:help is handled by helperText in all carbon widgets. + // see BaseInputTemplate/BaseInputTemplate.tsx and + // SelectWidget/SelectWidget.tsx + return null; } diff --git a/spiffworkflow-frontend/src/themes/carbon/FieldTemplate/FieldTemplate.tsx b/spiffworkflow-frontend/src/themes/carbon/FieldTemplate/FieldTemplate.tsx index 44b687ea3..a1cccb06b 100644 --- a/spiffworkflow-frontend/src/themes/carbon/FieldTemplate/FieldTemplate.tsx +++ b/spiffworkflow-frontend/src/themes/carbon/FieldTemplate/FieldTemplate.tsx @@ -1,64 +1,57 @@ import React from 'react'; -import FormControl from '@mui/material/FormControl'; -import Typography from '@mui/material/Typography'; -import { FieldTemplateProps, getTemplate, getUiOptions } from '@rjsf/utils'; +import { + FieldTemplateProps, + FormContextType, + RJSFSchema, + StrictRJSFSchema, + getTemplate, + getUiOptions, +} from '@rjsf/utils'; -function FieldTemplate({ - id, - children, - classNames, - disabled, - displayLabel, - hidden, - label, - onDropPropertyClick, - onKeyChange, - readonly, - required, - rawErrors = [], - errors, - help, - rawDescription, - schema, - uiSchema, - registry, -}: FieldTemplateProps) { - const uiOptions = getUiOptions(uiSchema); - const WrapIfAdditionalTemplate = getTemplate<'WrapIfAdditionalTemplate'>( - 'WrapIfAdditionalTemplate', +import Label from './Label'; + +/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field + * content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component. + * + * @param props - The `FieldTemplateProps` for this component + */ +export default function FieldTemplate< + T = any, + S extends StrictRJSFSchema = RJSFSchema, + F extends FormContextType = any +>(props: FieldTemplateProps) { + const { + id, + label, + children, + errors, + help, + description, + hidden, + required, + displayLabel, registry, - uiOptions - ); - + uiSchema, + } = props; + const uiOptions = getUiOptions(uiSchema); + const WrapIfAdditionalTemplate = getTemplate< + 'WrapIfAdditionalTemplate', + T, + S, + F + >('WrapIfAdditionalTemplate', registry, uiOptions); if (hidden) { - return
{children}
; + return
{children}
; } return ( - - +
+ + {displayLabel && + +
); } - -export default FieldTemplate; diff --git a/spiffworkflow-frontend/src/themes/carbon/IconButton/IconButton.tsx b/spiffworkflow-frontend/src/themes/carbon/IconButton/IconButton.tsx index 825591061..64eb883db 100644 --- a/spiffworkflow-frontend/src/themes/carbon/IconButton/IconButton.tsx +++ b/spiffworkflow-frontend/src/themes/carbon/IconButton/IconButton.tsx @@ -1,55 +1,96 @@ import React from 'react'; -import IconButton, { - IconButtonProps as MuiIconButtonProps, -} from '@mui/material/IconButton'; -import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward'; -import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward'; -import RemoveIcon from '@mui/icons-material/Remove'; -import { IconButtonProps } from '@rjsf/utils'; +import { + FormContextType, + IconButtonProps, + RJSFSchema, + StrictRJSFSchema, +} from '@rjsf/utils'; -export default function MuiIconButton(props: IconButtonProps) { - const { icon, color, uiSchema, ...otherProps } = props; +// @ts-ignore +import { Add, TrashCan, ArrowUp, ArrowDown } from '@carbon/icons-react'; + +export default function IconButton< + T = any, + S extends StrictRJSFSchema = RJSFSchema, + F extends FormContextType = any +>(props: IconButtonProps) { + const { + iconType = 'default', + icon, + className, + uiSchema, + registry, + ...otherProps + } = props; + // icon string optios: plus, remove, arrow-up, arrow-down + let carbonIcon = ( +

+ Add new +

+ ); + if (icon === 'remove') { + carbonIcon = ; + } + if (icon === 'arrow-up') { + carbonIcon = ; + } + if (icon === 'arrow-down') { + carbonIcon = ; + } + + return ( + + ); +} + +export function MoveDownButton< + T = any, + S extends StrictRJSFSchema = RJSFSchema, + F extends FormContextType = any +>(props: IconButtonProps) { return ( - {icon} - - ); -} - -export function MoveDownButton(props: IconButtonProps) { - return ( - } + icon="arrow-down" /> ); } -export function MoveUpButton(props: IconButtonProps) { +export function MoveUpButton< + T = any, + S extends StrictRJSFSchema = RJSFSchema, + F extends FormContextType = any +>(props: IconButtonProps) { return ( - } + icon="arrow-up" /> ); } -export function RemoveButton(props: IconButtonProps) { - const { iconType, ...otherProps } = props; +export function RemoveButton< + T = any, + S extends StrictRJSFSchema = RJSFSchema, + F extends FormContextType = any +>(props: IconButtonProps) { return ( - - } + className="array-item-remove" + {...props} + iconType="danger" + icon="remove" /> ); } diff --git a/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx b/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx index 616b11a75..eaae4eb61 100644 --- a/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx +++ b/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx @@ -41,6 +41,10 @@ function SelectWidget({ } else if (schema && schema.title) { labelToUse = schema.title; } + let helperText = null; + if (uiSchema && uiSchema['ui:help']) { + helperText = uiSchema['ui:help']; + } if (required) { labelToUse = `${labelToUse}*`; } @@ -49,16 +53,20 @@ function SelectWidget({ let errorMessageForField = null; if (rawErrors && rawErrors.length > 0) { invalid = true; - errorMessageForField = `${labelToUse.replace(/\*$/, '')} ${rawErrors[0]}`; + // errorMessageForField = `${labelToUse.replace(/\*$/, '')} ${rawErrors[0]}`; + errorMessageForField = rawErrors[0]; } + // maybe use placeholder somehow. it was previously jammed into the helperText field, + // but allowing ui:help to grab that spot seems much more appropriate. + return (