updated carbon react to 1.27 for react 18 support and updated all other libraries for it w/ burnettk

This commit is contained in:
jasquat 2023-04-17 16:25:10 -04:00
parent 4efdbdc48e
commit 48ed3da06c
No known key found for this signature in database
7 changed files with 12636 additions and 12884 deletions

File diff suppressed because it is too large Load Diff

View File

@ -7,11 +7,10 @@
"@babel/plugin-transform-react-jsx": "^7.18.6", "@babel/plugin-transform-react-jsx": "^7.18.6",
"@babel/preset-react": "^7.18.6", "@babel/preset-react": "^7.18.6",
"@carbon/icons-react": "^11.10.0", "@carbon/icons-react": "^11.10.0",
"@carbon/react": "^1.16.0", "@carbon/react": "^1.27.0",
"@carbon/styles": "^1.16.0", "@carbon/styles": "^1.16.0",
"@casl/ability": "^6.3.2", "@casl/ability": "^6.3.2",
"@casl/react": "^3.1.0", "@casl/react": "^3.1.0",
"@ginkgo-bioworks/react-json-schema-form-builder": "^2.9.0",
"@monaco-editor/react": "^4.4.5", "@monaco-editor/react": "^4.4.5",
"@mui/material": "^5.10.14", "@mui/material": "^5.10.14",
"@react-icons/all-files": "^4.1.0", "@react-icons/all-files": "^4.1.0",
@ -64,14 +63,6 @@
"overrides": { "overrides": {
"postcss-preset-env": { "postcss-preset-env": {
"autoprefixer": "10.4.5" "autoprefixer": "10.4.5"
},
"@ginkgo-bioworks/react-json-schema-form-builder": {
"react": "^18.2.0",
"bootstrap": "^5.2.0-beta1"
},
"@carbon/react": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
} }
}, },
"scripts": { "scripts": {

View File

@ -890,7 +890,7 @@ export default function ProcessModelEditDiagram() {
const path = generatePath( const path = generatePath(
'/admin/process-models/:process_model_id/form/:file_name', '/admin/process-models/:process_model_id/form/:file_name',
{ {
process_model_id: params.process_model_id, process_model_id: params.process_model_id || null,
file_name: fileName, file_name: fileName,
} }
); );
@ -902,7 +902,7 @@ export default function ProcessModelEditDiagram() {
const path = generatePath( const path = generatePath(
'/admin/process-models/:process_model_id/files/:file_name', '/admin/process-models/:process_model_id/files/:file_name',
{ {
process_model_id: params.process_model_id, process_model_id: params.process_model_id || null,
file_name: file.name, file_name: file.name,
} }
); );

View File

@ -11,7 +11,6 @@ import {
ComboBox, ComboBox,
Button, Button,
ButtonSet, ButtonSet,
// @ts-ignore
} from '@carbon/react'; } from '@carbon/react';
import MDEditor from '@uiw/react-md-editor'; import MDEditor from '@uiw/react-md-editor';

View File

@ -143,7 +143,6 @@ export default function BaseInputTemplate<
<> <>
<TextInput <TextInput
id={id} id={id}
name={id}
className="text-input" className="text-input"
helperText={helperText} helperText={helperText}
invalid={invalid} invalid={invalid}

View File

@ -1,59 +1,92 @@
// @ts-ignore // @ts-ignore
import { Select, SelectItem } from '@carbon/react'; import { Select, SelectItem } from '@carbon/react';
import { WidgetProps, processSelectValue } from '@rjsf/utils'; import { ChangeEvent, FocusEvent, SyntheticEvent, useCallback } from 'react';
import {
enumOptionsValueForIndex,
FormContextType,
RJSFSchema,
StrictRJSFSchema,
WidgetProps,
} from '@rjsf/utils';
function SelectWidget({ function getValue(event: SyntheticEvent<HTMLSelectElement>, multiple: boolean) {
if (multiple) {
return Array.from((event.target as HTMLSelectElement).options)
.slice()
.filter((o) => o.selected)
.map((o) => o.value);
}
return (event.target as HTMLSelectElement).value;
}
/** The `SelectWidget` is a widget for rendering dropdowns.
* It is typically used with string properties constrained with enum options.
*
* @param props - The `WidgetProps` for this component
*/
function SelectWidget<
T = any,
S extends StrictRJSFSchema = RJSFSchema,
F extends FormContextType = any
>({
schema, schema,
uiSchema,
id, id,
options, options,
label, value,
required,
disabled, disabled,
readonly, readonly,
value, multiple = false,
multiple, autofocus = false,
autofocus,
onChange, onChange,
onBlur, onBlur,
onFocus, onFocus,
uiSchema,
placeholder,
rawErrors = [], rawErrors = [],
}: WidgetProps) { }: WidgetProps<T, S, F>) {
const { enumOptions, enumDisabled } = options; const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
const emptyValue = multiple ? [] : ''; const emptyValue = multiple ? [] : '';
const _onChange = ({ const handleFocus = useCallback(
target: { value }, (event: FocusEvent<HTMLSelectElement>) => {
}: React.ChangeEvent<{ name?: string; value: unknown }>) => const newValue = getValue(event, multiple);
onChange(processSelectValue(schema, value, options)); return onFocus(
const _onBlur = ({ target: { value } }: React.FocusEvent<HTMLInputElement>) => id,
onBlur(id, processSelectValue(schema, value, options)); enumOptionsValueForIndex<S>(newValue, enumOptions, optEmptyVal)
const _onFocus = ({ );
target: { value }, },
}: React.FocusEvent<HTMLInputElement>) => [onFocus, id, schema, multiple, options]
onFocus(id, processSelectValue(schema, value, options)); );
const handleBlur = useCallback(
(event: FocusEvent<HTMLSelectElement>) => {
const newValue = getValue(event, multiple);
return onBlur(
id,
enumOptionsValueForIndex<S>(newValue, enumOptions, optEmptyVal)
);
},
[onBlur, id, schema, multiple, options]
);
const handleChange = useCallback(
(event: ChangeEvent<HTMLSelectElement>) => {
const newValue = getValue(event, multiple);
return onChange(
enumOptionsValueForIndex<S>(newValue, enumOptions, optEmptyVal)
);
},
[onChange, schema, multiple, options]
);
let labelToUse = label;
if (uiSchema && uiSchema['ui:title']) {
labelToUse = uiSchema['ui:title'];
} else if (schema && schema.title) {
labelToUse = schema.title;
}
let helperText = null; let helperText = null;
if (uiSchema && uiSchema['ui:help']) { if (uiSchema && uiSchema['ui:help']) {
helperText = uiSchema['ui:help']; helperText = uiSchema['ui:help'];
} }
if (required) {
labelToUse = `${labelToUse}*`;
}
let invalid = false; let invalid = false;
let errorMessageForField = null; let errorMessageForField = null;
if (rawErrors && rawErrors.length > 0) { if (rawErrors && rawErrors.length > 0) {
invalid = true; invalid = true;
// errorMessageForField = `${labelToUse.replace(/\*$/, '')} ${rawErrors[0]}`;
errorMessageForField = rawErrors[0]; errorMessageForField = rawErrors[0];
} }
@ -71,9 +104,9 @@ function SelectWidget({
disabled={disabled || readonly} disabled={disabled || readonly}
autoFocus={autofocus} autoFocus={autofocus}
error={rawErrors.length > 0} error={rawErrors.length > 0}
onChange={_onChange} onChange={handleChange}
onBlur={_onBlur} onBlur={handleBlur}
onFocus={_onFocus} onFocus={handleFocus}
invalid={invalid} invalid={invalid}
invalidText={errorMessageForField} invalidText={errorMessageForField}
InputLabelProps={{ InputLabelProps={{

View File

@ -0,0 +1,2 @@
// carbon/react is not very typescript safe so ignore it
declare module '@carbon/react';