@cerebruminc/cerebellum 17.0.0 → 17.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/jest.config.cjs +2 -1
- package/package.json +5 -4
- package/src/components/RJSForm/RJSForm.tsx +2 -1
- package/src/components/RJSForm/fields/AddressField.tsx +1 -1
- package/src/components/RJSForm/fields/ArrayField.tsx +27 -31
- package/src/components/RJSForm/fields/CheckboxField.tsx +8 -8
- package/src/components/RJSForm/fields/CheckboxGroupField.tsx +9 -9
- package/src/components/RJSForm/fields/DateField.tsx +9 -9
- package/src/components/RJSForm/fields/HiddenField.tsx +2 -4
- package/src/components/RJSForm/fields/MaskedInputField.tsx +5 -6
- package/src/components/RJSForm/fields/MultiSelectField.tsx +11 -11
- package/src/components/RJSForm/fields/MultiTextInputField.tsx +12 -13
- package/src/components/RJSForm/fields/NumberField.tsx +6 -7
- package/src/components/RJSForm/fields/RadioField.tsx +7 -7
- package/src/components/RJSForm/fields/SelectField.tsx +9 -9
- package/src/components/RJSForm/fields/TextField.tsx +9 -9
- package/src/components/RJSForm/fields/TextareaField.tsx +8 -8
- package/src/components/RJSForm/fields/ToggleField.tsx +8 -8
- package/src/components/Table/Table.test.tsx +1 -1
- package/tsconfig.test.json +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# react-component-lib-boilerplate
|
|
2
2
|
|
|
3
|
+
## [17.0.1](https://github.com/cerebruminc/cerebellum/compare/v17.0.0...v17.0.1) (2026-05-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* Update rjsform to v6 ([25394f8](https://github.com/cerebruminc/cerebellum/commit/25394f8dad43c2a1773a26fb86c8755ce75eb35f))
|
|
9
|
+
|
|
3
10
|
## [17.0.0](https://github.com/cerebruminc/cerebellum/compare/v16.14.0...v17.0.0) (2026-05-18)
|
|
4
11
|
|
|
5
12
|
|
package/jest.config.cjs
CHANGED
|
@@ -11,8 +11,9 @@ module.exports = {
|
|
|
11
11
|
roots: ["<rootDir>"],
|
|
12
12
|
moduleDirectories: ["node_modules", "src"],
|
|
13
13
|
testPathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/lib/"],
|
|
14
|
-
transformIgnorePatterns: ["/node_modules/(?!(nanoid)/)"],
|
|
14
|
+
transformIgnorePatterns: ["/node_modules/(?!(nanoid|@rjsf|@x0k)/)"],
|
|
15
15
|
transform: {
|
|
16
|
+
"^.+\\.tsx?$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.test.json" }],
|
|
16
17
|
"^.+\\.jsx?$": "<rootDir>/jest.transform.cjs",
|
|
17
18
|
},
|
|
18
19
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerebruminc/cerebellum",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.1",
|
|
4
4
|
"description": "Cerebrum's React Component Library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -95,6 +95,7 @@
|
|
|
95
95
|
"jest-environment-jsdom": "^29.7.0",
|
|
96
96
|
"lint-staged": "^15.0.0",
|
|
97
97
|
"lorem-ipsum": "^2.0.4",
|
|
98
|
+
"msw": "^2.14.6",
|
|
98
99
|
"next": "^15.1.5",
|
|
99
100
|
"react": "^18.3.1",
|
|
100
101
|
"react-dom": "^18.3.1",
|
|
@@ -130,9 +131,9 @@
|
|
|
130
131
|
},
|
|
131
132
|
"dependencies": {
|
|
132
133
|
"@react-google-maps/api": "^2.19.2",
|
|
133
|
-
"@rjsf/core": "^5.
|
|
134
|
-
"@rjsf/utils": "^5.
|
|
135
|
-
"@rjsf/validator-ajv8": "^5.
|
|
134
|
+
"@rjsf/core": "^6.5.3",
|
|
135
|
+
"@rjsf/utils": "^6.5.3",
|
|
136
|
+
"@rjsf/validator-ajv8": "^6.5.3",
|
|
136
137
|
"@types/styled-components": "^5.1.34",
|
|
137
138
|
"browser-image-compression": "^2.0.2",
|
|
138
139
|
"country-flag-icons": "^1.5.11",
|
|
@@ -6,7 +6,7 @@ import { noop } from "lodash";
|
|
|
6
6
|
import { PrimaryButton } from "../Button";
|
|
7
7
|
import { StyleHack } from "./RJSFormStyles";
|
|
8
8
|
import { fields, widgets } from "./const";
|
|
9
|
-
import { ArrayFieldTemplate } from "./fields/ArrayField";
|
|
9
|
+
import { ArrayFieldItemTemplate, ArrayFieldTemplate } from "./fields/ArrayField";
|
|
10
10
|
import { ObjectFieldTemplate } from "./fields/ObjectField";
|
|
11
11
|
import { transformErrors } from "./helpers";
|
|
12
12
|
import { RJSFormType } from "./types";
|
|
@@ -35,6 +35,7 @@ export const RJSForm: FC<RJSFormType> = (props) => {
|
|
|
35
35
|
...uiSchema,
|
|
36
36
|
};
|
|
37
37
|
const templatesWithDefaults = {
|
|
38
|
+
ArrayFieldItemTemplate: ArrayFieldItemTemplate,
|
|
38
39
|
ArrayFieldTemplate: ArrayFieldTemplate,
|
|
39
40
|
ObjectFieldTemplate: ObjectFieldTemplate,
|
|
40
41
|
...templates,
|
|
@@ -1,53 +1,49 @@
|
|
|
1
|
-
import { ArrayFieldTemplateProps } from "@rjsf/utils";
|
|
1
|
+
import { ArrayFieldItemTemplateProps, ArrayFieldTemplateProps } from "@rjsf/utils";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { AddButton } from "../../../configuredComponents/AddButton";
|
|
4
4
|
import { CaretDown, CaretUp } from "../../Icons";
|
|
5
|
-
import { HeadingH2 } from "../../../const/text";
|
|
6
5
|
import { IconButton } from "../../IconButton";
|
|
7
6
|
import { TextButton } from "../../Button";
|
|
8
7
|
import { TitleGroup } from "../../Form/FormStyles";
|
|
9
8
|
import { AddButtonBox, ArrayBase, ArrayGroup, HeaderButtons } from "../RJSFormStyles";
|
|
10
|
-
import { HandleRemoveProps } from "../types";
|
|
11
9
|
|
|
12
|
-
export const
|
|
13
|
-
const {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const displayTitle = title || idSchema.$id.split("_").pop();
|
|
17
|
-
|
|
18
|
-
const handleRemove = ({ index }: HandleRemoveProps) => {
|
|
19
|
-
// Mark this index as "removing"
|
|
20
|
-
setRemovingIndices((prev) => new Set(Array.from(prev).concat([index])));
|
|
10
|
+
export const ArrayFieldItemTemplate = (props: ArrayFieldItemTemplateProps) => {
|
|
11
|
+
const { buttonsProps, children } = props;
|
|
12
|
+
const { hasMoveDown, hasMoveUp, hasRemove, onMoveDownItem, onMoveUpItem, onRemoveItem } = buttonsProps;
|
|
13
|
+
const [isFading, setIsFading] = useState(false);
|
|
21
14
|
|
|
22
|
-
|
|
15
|
+
const handleRemove = () => {
|
|
16
|
+
setIsFading(true);
|
|
23
17
|
setTimeout(() => {
|
|
24
|
-
|
|
25
|
-
setRemovingIndices((prev) => {
|
|
26
|
-
const updated = new Set(Array.from(prev));
|
|
27
|
-
updated.delete(index);
|
|
28
|
-
return updated;
|
|
29
|
-
});
|
|
18
|
+
onRemoveItem();
|
|
30
19
|
}, 400);
|
|
31
20
|
};
|
|
32
21
|
|
|
22
|
+
return (
|
|
23
|
+
<ArrayGroup $fade={isFading}>
|
|
24
|
+
<TitleGroup $roomForRemove>
|
|
25
|
+
<HeaderButtons>
|
|
26
|
+
{hasMoveDown && <IconButton Icon={CaretDown} onClick={onMoveDownItem} />}
|
|
27
|
+
{hasMoveUp && <IconButton Icon={CaretUp} onClick={onMoveUpItem} />}
|
|
28
|
+
{hasRemove && <TextButton onClick={handleRemove} text="Remove" />}
|
|
29
|
+
</HeaderButtons>
|
|
30
|
+
</TitleGroup>
|
|
31
|
+
{children}
|
|
32
|
+
</ArrayGroup>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const ArrayFieldTemplate = (props: ArrayFieldTemplateProps) => {
|
|
37
|
+
const { canAdd, items, onAddClick, title } = props;
|
|
38
|
+
|
|
33
39
|
return (
|
|
34
40
|
<ArrayBase>
|
|
35
41
|
{items.map((element, index) => (
|
|
36
|
-
<
|
|
37
|
-
<TitleGroup $roomForRemove>
|
|
38
|
-
<HeadingH2 data-sentry-unmask>{`${displayTitle} (${index + 1})`}</HeadingH2>
|
|
39
|
-
<HeaderButtons>
|
|
40
|
-
{element.hasMoveDown && <IconButton Icon={CaretDown} onClick={element.onReorderClick(element.index, element.index + 1)} />}
|
|
41
|
-
{element.hasMoveUp && <IconButton Icon={CaretUp} onClick={element.onReorderClick(element.index, element.index - 1)} />}
|
|
42
|
-
{element.hasRemove && <TextButton onClick={(event) => handleRemove({ event, index })} text="Remove" />}
|
|
43
|
-
</HeaderButtons>
|
|
44
|
-
</TitleGroup>
|
|
45
|
-
{element.children}
|
|
46
|
-
</ArrayGroup>
|
|
42
|
+
<div key={element.key ?? index}>{element}</div>
|
|
47
43
|
))}
|
|
48
44
|
{canAdd && (
|
|
49
45
|
<AddButtonBox>
|
|
50
|
-
<AddButton onClick={onAddClick} text={`Add ${
|
|
46
|
+
<AddButton onClick={onAddClick} text={`Add ${title ?? "item"}`} />
|
|
51
47
|
</AddButtonBox>
|
|
52
48
|
)}
|
|
53
49
|
</ArrayBase>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorSchema,
|
|
1
|
+
import { ErrorSchema, FieldPathId, FieldProps, RJSFSchema, Widget } from "@rjsf/utils";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { CheckboxItem, CheckboxItemType } from "../../CheckboxItem";
|
|
4
4
|
import { FieldBox } from "../RJSFormStyles";
|
|
@@ -17,32 +17,32 @@ export type CheckboxFieldUiSchemaOptions = {
|
|
|
17
17
|
type CheckboxFieldProps = FieldProps & {
|
|
18
18
|
errorSchema?: ErrorSchema;
|
|
19
19
|
formData?: any;
|
|
20
|
-
idSchema: IdSchema;
|
|
21
20
|
idSeparator?: string;
|
|
22
21
|
uiSchema?: CheckboxFieldUiSchemaOptions;
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
// This is a wrapper component to convert the types from the widget to be used with the field types
|
|
26
25
|
export const CheckboxWidget: Widget<any, RJSFSchema, any> = (props) => {
|
|
27
|
-
const { id, value, disabled = false, readonly = false, uiSchema, ...rest } = props;
|
|
26
|
+
const { id, value, disabled = false, readonly = false, uiSchema, onChange, ...rest } = props;
|
|
28
27
|
|
|
29
|
-
const
|
|
28
|
+
const fieldPathId: FieldPathId = { $id: id, path: [] };
|
|
30
29
|
|
|
31
30
|
const checkboxFieldProps: CheckboxFieldProps = {
|
|
32
|
-
|
|
31
|
+
fieldPathId,
|
|
33
32
|
formData: value,
|
|
34
33
|
disabled,
|
|
35
34
|
readonly,
|
|
36
35
|
uiSchema: uiSchema as CheckboxFieldUiSchemaOptions,
|
|
37
36
|
...rest,
|
|
37
|
+
onChange: (newValue: any, _path: any, es?: any, id?: string) => onChange(newValue, es, id),
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
return <CheckboxField {...checkboxFieldProps} />;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
export const CheckboxField: React.FC<CheckboxFieldProps> = (props) => {
|
|
44
|
-
const { autofocus, disabled, formData,
|
|
45
|
-
const id =
|
|
44
|
+
const { autofocus, disabled, formData, fieldPathId, label, name, onBlur, onChange, onFocus, schema, uiSchema } = props;
|
|
45
|
+
const id = fieldPathId.$id;
|
|
46
46
|
|
|
47
47
|
const ui = uiSchema?.["ui:options"] || {};
|
|
48
48
|
const contentPadding = (ui?.padding as string) || "";
|
|
@@ -56,7 +56,7 @@ export const CheckboxField: React.FC<CheckboxFieldProps> = (props) => {
|
|
|
56
56
|
id={id}
|
|
57
57
|
label={label || schema.title || name}
|
|
58
58
|
name={name}
|
|
59
|
-
onClick={(event) => onChange(event.target.checked)}
|
|
59
|
+
onClick={(event) => onChange(event.target.checked, [])}
|
|
60
60
|
onBlur={() => onBlur(id, formData)}
|
|
61
61
|
onFocus={() => onFocus(id, formData)}
|
|
62
62
|
value={formData}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorSchema,
|
|
1
|
+
import { ErrorSchema, FieldPathId, FieldProps, RJSFSchema, Widget } from "@rjsf/utils";
|
|
2
2
|
import React, { useEffect, useState } from "react";
|
|
3
3
|
import { flushSync } from "react-dom";
|
|
4
4
|
import { CheckboxGroup, CheckboxGroupType } from "../../CheckboxGroup";
|
|
@@ -21,32 +21,32 @@ export type CheckboxGroupFieldUiSchemaOptions = {
|
|
|
21
21
|
type CheckboxGroupFieldProps = FieldProps & {
|
|
22
22
|
errorSchema?: ErrorSchema;
|
|
23
23
|
formData?: any;
|
|
24
|
-
idSchema: IdSchema;
|
|
25
24
|
idSeparator?: string;
|
|
26
25
|
uiSchema?: CheckboxGroupFieldUiSchemaOptions;
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
// This is a wrapper component to convert the types from the widget to be used with the field types
|
|
30
29
|
export const CheckboxGroupWidget: Widget<any, RJSFSchema, any> = (props) => {
|
|
31
|
-
const { id, value, disabled = false, readonly = false, uiSchema, ...rest } = props;
|
|
30
|
+
const { id, value, disabled = false, readonly = false, uiSchema, onChange, ...rest } = props;
|
|
32
31
|
|
|
33
|
-
const
|
|
32
|
+
const fieldPathId: FieldPathId = { $id: id, path: [] };
|
|
34
33
|
|
|
35
34
|
const checkboxGroupFieldProps: CheckboxGroupFieldProps = {
|
|
36
|
-
|
|
35
|
+
fieldPathId,
|
|
37
36
|
formData: value,
|
|
38
37
|
disabled,
|
|
39
38
|
readonly,
|
|
40
39
|
uiSchema: uiSchema as CheckboxGroupFieldUiSchemaOptions,
|
|
41
40
|
...rest,
|
|
41
|
+
onChange: (newValue: any, _path: any, es?: any, id?: string) => onChange(newValue, es, id),
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
return <CheckboxGroupField {...checkboxGroupFieldProps} />;
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
export const CheckboxGroupField: React.FC<CheckboxGroupFieldProps> = (props) => {
|
|
48
|
-
const { autofocus, hideLabel, rawErrors, required, formData,
|
|
49
|
-
const id =
|
|
48
|
+
const { autofocus, hideLabel, rawErrors, required, formData, fieldPathId, label, name, onBlur, onChange, onFocus, schema, uiSchema } = props;
|
|
49
|
+
const id = fieldPathId.$id;
|
|
50
50
|
|
|
51
51
|
const [formattedOptions, setFormattedOptions] = useState<SwitchGroupSwitchType[]>([]);
|
|
52
52
|
|
|
@@ -59,7 +59,7 @@ export const CheckboxGroupField: React.FC<CheckboxGroupFieldProps> = (props) =>
|
|
|
59
59
|
const enumValues = (schema as RJSFSchema)?.enum || (schema?.items as RJSFSchema)?.enum || [];
|
|
60
60
|
let options: SwitchGroupSwitchType[] = [];
|
|
61
61
|
if (!ui.options && enumValues.length > 0) {
|
|
62
|
-
const enumLabels = ui.enumNames
|
|
62
|
+
const enumLabels = Array.isArray(ui.enumNames) ? ui.enumNames : [];
|
|
63
63
|
const validEnumValues = enumValues.filter(
|
|
64
64
|
(enumValue: any): enumValue is string | number => typeof enumValue === "string" || typeof enumValue === "number"
|
|
65
65
|
);
|
|
@@ -91,7 +91,7 @@ export const CheckboxGroupField: React.FC<CheckboxGroupFieldProps> = (props) =>
|
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
flushSync(() => {
|
|
94
|
-
onChange(updatedValues);
|
|
94
|
+
onChange(updatedValues, []);
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorSchema,
|
|
1
|
+
import { ErrorSchema, FieldPathId, FieldProps, RJSFSchema, UiSchema, Widget } from "@rjsf/utils";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
3
|
import React, { useEffect } from "react";
|
|
4
4
|
import { DatePicker, DatePickerType, InlineDatePicker } from "../../DatePicker";
|
|
@@ -34,24 +34,24 @@ type DateFieldUiSchemaType = UiSchema & DateFieldUiSchemaOptions;
|
|
|
34
34
|
type DateFieldProps = FieldProps & {
|
|
35
35
|
errorSchema?: ErrorSchema;
|
|
36
36
|
formData?: any;
|
|
37
|
-
idSchema: IdSchema;
|
|
38
37
|
idSeparator?: string;
|
|
39
38
|
uiSchema?: DateFieldUiSchemaOptions;
|
|
40
39
|
};
|
|
41
40
|
|
|
42
41
|
// This is a wrapper component to convert the types from the widget to be used with the field types
|
|
43
42
|
export const DateWidget: Widget<any, RJSFSchema, any> = (props) => {
|
|
44
|
-
const { id, value, disabled = false, readonly = false, uiSchema, ...rest } = props;
|
|
43
|
+
const { id, value, disabled = false, readonly = false, uiSchema, onChange, ...rest } = props;
|
|
45
44
|
|
|
46
|
-
const
|
|
45
|
+
const fieldPathId: FieldPathId = { $id: id, path: [] };
|
|
47
46
|
|
|
48
47
|
const dateFieldProps: DateFieldProps = {
|
|
49
|
-
|
|
48
|
+
fieldPathId,
|
|
50
49
|
formData: value,
|
|
51
50
|
disabled,
|
|
52
51
|
readonly,
|
|
53
52
|
uiSchema: uiSchema as DateFieldUiSchemaType,
|
|
54
53
|
...rest,
|
|
54
|
+
onChange: (newValue: any, _path: any, es?: any, id?: string) => onChange(newValue, es, id),
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
return <DateField {...dateFieldProps} />;
|
|
@@ -62,7 +62,7 @@ export const DateField: React.FC<DateFieldProps> = (props) => {
|
|
|
62
62
|
disabled,
|
|
63
63
|
formData,
|
|
64
64
|
hideLabel,
|
|
65
|
-
|
|
65
|
+
fieldPathId,
|
|
66
66
|
label,
|
|
67
67
|
name,
|
|
68
68
|
onBlur,
|
|
@@ -74,7 +74,7 @@ export const DateField: React.FC<DateFieldProps> = (props) => {
|
|
|
74
74
|
schema,
|
|
75
75
|
uiSchema,
|
|
76
76
|
} = props;
|
|
77
|
-
const id =
|
|
77
|
+
const id = fieldPathId.$id;
|
|
78
78
|
|
|
79
79
|
const DatePickerComponent = hideLabel ? InlineDatePicker : DatePicker;
|
|
80
80
|
const ui = uiSchema?.["ui:options"] || {};
|
|
@@ -85,7 +85,7 @@ export const DateField: React.FC<DateFieldProps> = (props) => {
|
|
|
85
85
|
// biome-ignore lint/correctness/useExhaustiveDependencies: skip validation
|
|
86
86
|
useEffect(() => {
|
|
87
87
|
if (formData === "") {
|
|
88
|
-
onChange(undefined);
|
|
88
|
+
onChange(undefined, []);
|
|
89
89
|
}
|
|
90
90
|
}, [formData]);
|
|
91
91
|
|
|
@@ -94,7 +94,7 @@ export const DateField: React.FC<DateFieldProps> = (props) => {
|
|
|
94
94
|
|
|
95
95
|
if (date !== null && date !== undefined) {
|
|
96
96
|
const stringDate = dayjs.unix(date).format("YYYY-MM-DD");
|
|
97
|
-
onChange(stringDate, errors, id);
|
|
97
|
+
onChange(stringDate, [], errors, id);
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorSchema, FieldProps
|
|
1
|
+
import { ErrorSchema, FieldProps } from "@rjsf/utils";
|
|
2
2
|
import React, { ChangeEvent, RefObject } from "react";
|
|
3
3
|
import { RJSFormFields, UIErrorMessages } from "../types";
|
|
4
4
|
|
|
@@ -19,7 +19,6 @@ export type HiddenFieldUiSchemaOptions = {
|
|
|
19
19
|
type HiddenFieldProps = FieldProps & {
|
|
20
20
|
errorSchema?: ErrorSchema;
|
|
21
21
|
formData?: any;
|
|
22
|
-
idSchema: IdSchema;
|
|
23
22
|
idSeparator?: string;
|
|
24
23
|
uiSchema?: HiddenFieldUiSchemaOptions;
|
|
25
24
|
};
|
|
@@ -28,11 +27,10 @@ export const HiddenField: React.FC<HiddenFieldProps> = (props) => {
|
|
|
28
27
|
const {
|
|
29
28
|
formData, // Specific to Field
|
|
30
29
|
name,
|
|
31
|
-
onChange,
|
|
32
30
|
uiSchema,
|
|
33
31
|
} = props;
|
|
34
32
|
|
|
35
33
|
const ui = (uiSchema?.["ui:options"] as HiddenOptions) || {};
|
|
36
34
|
|
|
37
|
-
return <input name={name}
|
|
35
|
+
return <input name={name} ref={ui.innerRef} type="hidden" value={formData} readOnly />;
|
|
38
36
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorSchema, FieldProps
|
|
1
|
+
import { ErrorSchema, FieldProps } from "@rjsf/utils";
|
|
2
2
|
import React, { useEffect } from "react";
|
|
3
3
|
import { IMask } from "react-imask";
|
|
4
4
|
import { Input, InputType } from "../../Input";
|
|
@@ -33,7 +33,6 @@ type MaskedInputFieldUiSchemaOptions = {
|
|
|
33
33
|
type MaskedInputFieldProps = FieldProps & {
|
|
34
34
|
errorSchema?: ErrorSchema;
|
|
35
35
|
formData?: any;
|
|
36
|
-
idSchema: IdSchema;
|
|
37
36
|
idSeparator?: string;
|
|
38
37
|
uiSchema?: MaskedInputFieldUiSchemaOptions;
|
|
39
38
|
};
|
|
@@ -43,7 +42,7 @@ export const MaskedInputField: React.FC<MaskedInputFieldProps> = (props) => {
|
|
|
43
42
|
autofocus,
|
|
44
43
|
disabled,
|
|
45
44
|
formData,
|
|
46
|
-
|
|
45
|
+
fieldPathId,
|
|
47
46
|
label,
|
|
48
47
|
name,
|
|
49
48
|
onBlur,
|
|
@@ -56,7 +55,7 @@ export const MaskedInputField: React.FC<MaskedInputFieldProps> = (props) => {
|
|
|
56
55
|
hideLabel,
|
|
57
56
|
} = props;
|
|
58
57
|
|
|
59
|
-
const id =
|
|
58
|
+
const id = fieldPathId.$id;
|
|
60
59
|
const ui = uiSchema?.["ui:options"] || {};
|
|
61
60
|
const contentPadding = (ui?.padding as string) || "";
|
|
62
61
|
const mask = uiSchema?.["ui:mask"];
|
|
@@ -67,7 +66,7 @@ export const MaskedInputField: React.FC<MaskedInputFieldProps> = (props) => {
|
|
|
67
66
|
// biome-ignore lint/correctness/useExhaustiveDependencies: skip validation
|
|
68
67
|
useEffect(() => {
|
|
69
68
|
if (formData === "") {
|
|
70
|
-
onChange(undefined);
|
|
69
|
+
onChange(undefined, []);
|
|
71
70
|
}
|
|
72
71
|
}, [formData]);
|
|
73
72
|
|
|
@@ -99,7 +98,7 @@ export const MaskedInputField: React.FC<MaskedInputFieldProps> = (props) => {
|
|
|
99
98
|
// Remove special mask characters to apply the correct mask
|
|
100
99
|
const sanitizedValue = (value as string).replace(/[^a-zA-Z0-9]/g, "");
|
|
101
100
|
masked.resolve(sanitizedValue as string);
|
|
102
|
-
onChange(masked.value);
|
|
101
|
+
onChange(masked.value, []);
|
|
103
102
|
}}
|
|
104
103
|
placeholder={placeholder}
|
|
105
104
|
required={required}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// MultiSelectWidget supports enum: String[]. oneOf: Object[] will be supported in a separate component
|
|
2
2
|
|
|
3
|
-
import { ErrorSchema,
|
|
3
|
+
import { ErrorSchema, FieldPathId, FieldProps, RJSFSchema, UiSchema, Widget } from "@rjsf/utils";
|
|
4
4
|
import React, { useEffect, useState } from "react";
|
|
5
5
|
import { flushSync } from "react-dom";
|
|
6
6
|
import { MultiSelect, MultiSelectType } from "../../../configuredComponents/MultiSelect";
|
|
@@ -36,24 +36,24 @@ type MultiSelectFieldUiSchemaType = UiSchema & MultiSelectFieldUiSchemaOptions;
|
|
|
36
36
|
type MultiSelectFieldProps = FieldProps & {
|
|
37
37
|
errorSchema?: ErrorSchema;
|
|
38
38
|
formData?: any;
|
|
39
|
-
idSchema: IdSchema;
|
|
40
39
|
idSeparator?: string;
|
|
41
40
|
uiSchema?: MultiSelectFieldUiSchemaType;
|
|
42
41
|
};
|
|
43
42
|
|
|
44
43
|
// This is a wrapper component to convert the types from the widget to be used with the field types
|
|
45
44
|
export const MultiSelectWidget: Widget<any, RJSFSchema, any> = (props) => {
|
|
46
|
-
const { id, value, disabled = false, readonly = false, uiSchema, ...rest } = props;
|
|
45
|
+
const { id, value, disabled = false, readonly = false, uiSchema, onChange, ...rest } = props;
|
|
47
46
|
|
|
48
|
-
const
|
|
47
|
+
const fieldPathId: FieldPathId = { $id: id, path: [] };
|
|
49
48
|
|
|
50
49
|
const checkboxFieldProps: MultiSelectFieldProps = {
|
|
51
|
-
|
|
50
|
+
fieldPathId,
|
|
52
51
|
formData: value,
|
|
53
52
|
disabled,
|
|
54
53
|
readonly,
|
|
55
54
|
uiSchema: uiSchema as MultiSelectFieldUiSchemaType,
|
|
56
55
|
...rest,
|
|
56
|
+
onChange: (newValue: any, _path: any, es?: any, id?: string) => onChange(newValue, es, id),
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
return <MultiSelectField {...checkboxFieldProps} />;
|
|
@@ -65,7 +65,7 @@ export const MultiSelectField: React.FC<MultiSelectFieldProps> = (props) => {
|
|
|
65
65
|
disabled,
|
|
66
66
|
formData, // Specific to Field
|
|
67
67
|
hideLabel,
|
|
68
|
-
|
|
68
|
+
fieldPathId, // Specific to Field
|
|
69
69
|
label,
|
|
70
70
|
name,
|
|
71
71
|
onBlur,
|
|
@@ -78,7 +78,7 @@ export const MultiSelectField: React.FC<MultiSelectFieldProps> = (props) => {
|
|
|
78
78
|
uiSchema,
|
|
79
79
|
} = props;
|
|
80
80
|
const [formattedOptions, setFormattedOptions] = useState<OptionType[]>([]);
|
|
81
|
-
const id =
|
|
81
|
+
const id = fieldPathId.$id;
|
|
82
82
|
|
|
83
83
|
const ui = uiSchema?.["ui:options"] || {};
|
|
84
84
|
const contentPadding = (ui?.padding as string) || "";
|
|
@@ -89,7 +89,7 @@ export const MultiSelectField: React.FC<MultiSelectFieldProps> = (props) => {
|
|
|
89
89
|
const enumValues = (schema as RJSFSchema)?.enum || (schema?.items as RJSFSchema)?.enum || [];
|
|
90
90
|
let options: OptionType[] = [];
|
|
91
91
|
if (!ui?.options && enumValues?.length > 0) {
|
|
92
|
-
const enumLabels = ui.enumNames
|
|
92
|
+
const enumLabels = Array.isArray(ui.enumNames) ? ui.enumNames : [];
|
|
93
93
|
const validEnumValues = enumValues.filter(
|
|
94
94
|
(enumValue: any): enumValue is string | number => typeof enumValue === "string" || typeof enumValue === "number"
|
|
95
95
|
);
|
|
@@ -121,7 +121,7 @@ export const MultiSelectField: React.FC<MultiSelectFieldProps> = (props) => {
|
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
flushSync(() => {
|
|
124
|
-
onChange(updatedValues);
|
|
124
|
+
onChange(updatedValues, []);
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
}}
|
|
@@ -136,7 +136,7 @@ export const MultiSelectField: React.FC<MultiSelectFieldProps> = (props) => {
|
|
|
136
136
|
string: response.tag?.id as string,
|
|
137
137
|
});
|
|
138
138
|
flushSync(() => {
|
|
139
|
-
onChange(updatedValues);
|
|
139
|
+
onChange(updatedValues, []);
|
|
140
140
|
});
|
|
141
141
|
}}
|
|
142
142
|
// uiSchema options
|
|
@@ -144,7 +144,7 @@ export const MultiSelectField: React.FC<MultiSelectFieldProps> = (props) => {
|
|
|
144
144
|
ui?.clearAll
|
|
145
145
|
? () => {
|
|
146
146
|
flushSync(() => {
|
|
147
|
-
onChange([]);
|
|
147
|
+
onChange([], []);
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
: undefined
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorSchema,
|
|
1
|
+
import { ErrorSchema, FieldPathId, FieldProps, RJSFSchema, Widget } from "@rjsf/utils";
|
|
2
2
|
import React, { useEffect, useState } from "react";
|
|
3
3
|
import { CheckboxItem } from "../../CheckboxItem";
|
|
4
4
|
import { Email } from "../../Icons";
|
|
@@ -42,24 +42,24 @@ export type MultiTextInputUiSchemaOptions = {
|
|
|
42
42
|
type TextFieldProps = FieldProps & {
|
|
43
43
|
errorSchema?: ErrorSchema;
|
|
44
44
|
formData?: any;
|
|
45
|
-
idSchema: IdSchema;
|
|
46
45
|
idSeparator?: string;
|
|
47
46
|
uiSchema?: MultiTextInputUiSchemaOptions;
|
|
48
47
|
};
|
|
49
48
|
|
|
50
49
|
// This is a wrapper component to convert the types from the widget to be used with the field types
|
|
51
50
|
export const MultiTextInputWidget: Widget<any, RJSFSchema, any> = (props) => {
|
|
52
|
-
const { id, value, disabled = false, readonly = false, uiSchema, ...rest } = props;
|
|
51
|
+
const { id, value, disabled = false, readonly = false, uiSchema, onChange, ...rest } = props;
|
|
53
52
|
|
|
54
|
-
const
|
|
53
|
+
const fieldPathId: FieldPathId = { $id: id, path: [] };
|
|
55
54
|
|
|
56
55
|
const checkboxFieldProps: TextFieldProps = {
|
|
57
|
-
|
|
56
|
+
fieldPathId,
|
|
58
57
|
formData: value,
|
|
59
58
|
disabled,
|
|
60
59
|
readonly,
|
|
61
60
|
uiSchema: uiSchema as MultiTextInputUiSchemaOptions,
|
|
62
61
|
...rest,
|
|
62
|
+
onChange: (newValue: any, _path: any, es?: any, id?: string) => onChange(newValue, es, id),
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
return <MultiTextInputField {...checkboxFieldProps} />;
|
|
@@ -75,7 +75,7 @@ export const MultiTextInputField: React.FC<TextFieldProps> = (props) => {
|
|
|
75
75
|
formData, // Specific to Field
|
|
76
76
|
// hideError,
|
|
77
77
|
hideLabel,
|
|
78
|
-
|
|
78
|
+
fieldPathId, // Specific to Field
|
|
79
79
|
label,
|
|
80
80
|
name,
|
|
81
81
|
onBlur,
|
|
@@ -89,7 +89,7 @@ export const MultiTextInputField: React.FC<TextFieldProps> = (props) => {
|
|
|
89
89
|
schema,
|
|
90
90
|
uiSchema,
|
|
91
91
|
} = props;
|
|
92
|
-
const id =
|
|
92
|
+
const id = fieldPathId.$id;
|
|
93
93
|
|
|
94
94
|
const InputComponent = hideLabel ? InlineInput : Input;
|
|
95
95
|
const ui = uiSchema?.["ui:options"] || {};
|
|
@@ -146,7 +146,7 @@ export const MultiTextInputField: React.FC<TextFieldProps> = (props) => {
|
|
|
146
146
|
// Clear validation error and add the value
|
|
147
147
|
setValidationError("");
|
|
148
148
|
const newValues = Array.isArray(formData) ? [...formData, trimmedValue] : [trimmedValue];
|
|
149
|
-
onChange(newValues);
|
|
149
|
+
onChange(newValues, []);
|
|
150
150
|
setCurrentValue("");
|
|
151
151
|
}
|
|
152
152
|
};
|
|
@@ -160,10 +160,9 @@ export const MultiTextInputField: React.FC<TextFieldProps> = (props) => {
|
|
|
160
160
|
};
|
|
161
161
|
|
|
162
162
|
const handleRemove = (idx: number | string) => {
|
|
163
|
-
console.log("handleRemove", idx);
|
|
164
163
|
if (!Array.isArray(formData)) return;
|
|
165
164
|
const newValues = formData.filter((_: string, i: number) => i !== idx);
|
|
166
|
-
onChange(newValues);
|
|
165
|
+
onChange(newValues, []);
|
|
167
166
|
};
|
|
168
167
|
|
|
169
168
|
// Updated shouldShowField logic
|
|
@@ -176,7 +175,7 @@ export const MultiTextInputField: React.FC<TextFieldProps> = (props) => {
|
|
|
176
175
|
// this could generate a validation error if we provide a format for this field
|
|
177
176
|
useEffect(() => {
|
|
178
177
|
if (formData === "") {
|
|
179
|
-
onChange(undefined);
|
|
178
|
+
onChange(undefined, []);
|
|
180
179
|
}
|
|
181
180
|
}, [formData]);
|
|
182
181
|
|
|
@@ -194,10 +193,10 @@ export const MultiTextInputField: React.FC<TextFieldProps> = (props) => {
|
|
|
194
193
|
setSavedEmailList(currentEmails);
|
|
195
194
|
setCurrentValue(""); // Clear current input value
|
|
196
195
|
setValidationError(""); // Clear any validation errors
|
|
197
|
-
onChange(undefined); // Set formData to undefined (this disables the backend option)
|
|
196
|
+
onChange(undefined, []); // Set formData to undefined (this disables the backend option)
|
|
198
197
|
} else {
|
|
199
198
|
// If we're showing the input, restore saved email list or set to empty array
|
|
200
|
-
onChange(savedEmailList);
|
|
199
|
+
onChange(savedEmailList, []);
|
|
201
200
|
setSavedEmailList([]); // Clear saved list after restoring
|
|
202
201
|
}
|
|
203
202
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorSchema, FieldProps
|
|
1
|
+
import { ErrorSchema, FieldProps } from "@rjsf/utils";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { InlineInput } from "../../InlineInput";
|
|
4
4
|
import { Input, InputType } from "../../Input";
|
|
@@ -33,7 +33,6 @@ export type NumberFieldUiSchemaOptions = {
|
|
|
33
33
|
type NumberFieldProps = FieldProps & {
|
|
34
34
|
errorSchema?: ErrorSchema;
|
|
35
35
|
formData?: any;
|
|
36
|
-
idSchema: IdSchema;
|
|
37
36
|
idSeparator?: string;
|
|
38
37
|
uiSchema?: NumberFieldUiSchemaOptions;
|
|
39
38
|
};
|
|
@@ -48,7 +47,7 @@ export const NumberField: React.FC<NumberFieldProps> = (props) => {
|
|
|
48
47
|
formData, // Specific to Field
|
|
49
48
|
// hideError,
|
|
50
49
|
hideLabel,
|
|
51
|
-
|
|
50
|
+
fieldPathId, // Specific to Field
|
|
52
51
|
label,
|
|
53
52
|
name,
|
|
54
53
|
onBlur,
|
|
@@ -63,7 +62,7 @@ export const NumberField: React.FC<NumberFieldProps> = (props) => {
|
|
|
63
62
|
schema,
|
|
64
63
|
uiSchema,
|
|
65
64
|
} = props;
|
|
66
|
-
const id =
|
|
65
|
+
const id = fieldPathId.$id;
|
|
67
66
|
|
|
68
67
|
const InputComponent = hideLabel ? InlineInput : Input;
|
|
69
68
|
const ui = uiSchema?.["ui:options"] || {};
|
|
@@ -73,11 +72,11 @@ export const NumberField: React.FC<NumberFieldProps> = (props) => {
|
|
|
73
72
|
const errors: ErrorSchema<any> = {};
|
|
74
73
|
if (Number.isNaN(Number(value))) {
|
|
75
74
|
errors.__errors = [NUMBER_FIELD_INVALID_ERROR];
|
|
76
|
-
onChange(value, errors, id);
|
|
75
|
+
onChange(value, [], errors, id);
|
|
77
76
|
} else if (value === undefined || value === "") {
|
|
78
|
-
onChange("", errors, id);
|
|
77
|
+
onChange("", [], errors, id);
|
|
79
78
|
} else {
|
|
80
|
-
onChange(Number(value), errors, id);
|
|
79
|
+
onChange(Number(value), [], errors, id);
|
|
81
80
|
}
|
|
82
81
|
};
|
|
83
82
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// RadioWidget supports enum: String[]. oneOf: Object[] will be supported in a separate component
|
|
2
2
|
|
|
3
|
-
import { ErrorSchema,
|
|
3
|
+
import { ErrorSchema, FieldPathId, FieldProps, RJSFSchema, UiSchema, Widget } from "@rjsf/utils";
|
|
4
4
|
import React, { useEffect, useState } from "react";
|
|
5
5
|
import { RadioGroup, RadioGroupType } from "../../RadioGroup";
|
|
6
6
|
import { SwitchGroupSwitchType } from "../../../sharedTypes/types";
|
|
@@ -23,24 +23,24 @@ type RadioFieldUiSchemaType = UiSchema & RadioFieldUiSchemaOptions;
|
|
|
23
23
|
type RadioFieldProps = FieldProps & {
|
|
24
24
|
errorSchema?: ErrorSchema;
|
|
25
25
|
formData?: any;
|
|
26
|
-
idSchema: IdSchema;
|
|
27
26
|
idSeparator?: string;
|
|
28
27
|
uiSchema?: RadioFieldUiSchemaType;
|
|
29
28
|
};
|
|
30
29
|
|
|
31
30
|
// This is a wrapper component to convert the types from the widget to be used with the field types
|
|
32
31
|
export const RadioWidget: Widget<any, RJSFSchema, any> = (props) => {
|
|
33
|
-
const { id, value, disabled = false, readonly = false, uiSchema, ...rest } = props;
|
|
32
|
+
const { id, value, disabled = false, readonly = false, uiSchema, onChange, ...rest } = props;
|
|
34
33
|
|
|
35
|
-
const
|
|
34
|
+
const fieldPathId: FieldPathId = { $id: id, path: [] };
|
|
36
35
|
|
|
37
36
|
const radioFieldProps: RadioFieldProps = {
|
|
38
|
-
|
|
37
|
+
fieldPathId,
|
|
39
38
|
formData: value,
|
|
40
39
|
disabled,
|
|
41
40
|
readonly,
|
|
42
41
|
uiSchema: uiSchema as RadioFieldUiSchemaType,
|
|
43
42
|
...rest,
|
|
43
|
+
onChange: (newValue: any, _path: any, es?: any, id?: string) => onChange(newValue, es, id),
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
return <RadioField {...radioFieldProps} />;
|
|
@@ -80,7 +80,7 @@ export const RadioField: React.FC<RadioFieldProps> = (props) => {
|
|
|
80
80
|
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
81
81
|
useEffect(() => {
|
|
82
82
|
// set State for Default values
|
|
83
|
-
onChange(formData);
|
|
83
|
+
onChange(formData, []);
|
|
84
84
|
}, []);
|
|
85
85
|
|
|
86
86
|
return (
|
|
@@ -90,7 +90,7 @@ export const RadioField: React.FC<RadioFieldProps> = (props) => {
|
|
|
90
90
|
helperText={schema.description}
|
|
91
91
|
radioLabel={label || schema.title || name}
|
|
92
92
|
name={name}
|
|
93
|
-
onRadioClick={(event) => onChange(event.target.value)}
|
|
93
|
+
onRadioClick={(event) => onChange(event.target.value, [])}
|
|
94
94
|
radios={radioOptions}
|
|
95
95
|
required={required}
|
|
96
96
|
showValidationMessage={!!rawErrors?.[0]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SelectWidget supports enum: String[]. oneOf: Object[] will be supported in a separate component
|
|
2
2
|
|
|
3
|
-
import { ErrorSchema,
|
|
3
|
+
import { ErrorSchema, FieldPathId, FieldProps, RJSFSchema, UiSchema, Widget } from "@rjsf/utils";
|
|
4
4
|
import React, { useEffect, useState } from "react";
|
|
5
5
|
import { DropdownInput, DropdownInputType } from "../../../configuredComponents/DropdownInput";
|
|
6
6
|
import { OptionType } from "../../../sharedTypes/types";
|
|
@@ -39,24 +39,24 @@ type SelectFieldUiSchemaType = UiSchema & SelectFieldUiSchemaOptions;
|
|
|
39
39
|
type SelectFieldProps = FieldProps & {
|
|
40
40
|
errorSchema?: ErrorSchema;
|
|
41
41
|
formData?: any;
|
|
42
|
-
idSchema: IdSchema;
|
|
43
42
|
idSeparator?: string;
|
|
44
43
|
uiSchema?: SelectFieldUiSchemaType;
|
|
45
44
|
};
|
|
46
45
|
|
|
47
46
|
// This is a wrapper component to convert the types from the widget to be used with the field types
|
|
48
47
|
export const SelectWidget: Widget<any, RJSFSchema, any> = (props) => {
|
|
49
|
-
const { id, value, disabled = false, readonly = false, uiSchema, ...rest } = props;
|
|
48
|
+
const { id, value, disabled = false, readonly = false, uiSchema, onChange, ...rest } = props;
|
|
50
49
|
|
|
51
|
-
const
|
|
50
|
+
const fieldPathId: FieldPathId = { $id: id, path: [] };
|
|
52
51
|
|
|
53
52
|
const checkboxFieldProps: SelectFieldProps = {
|
|
54
|
-
|
|
53
|
+
fieldPathId,
|
|
55
54
|
formData: value,
|
|
56
55
|
disabled,
|
|
57
56
|
readonly,
|
|
58
57
|
uiSchema: uiSchema as SelectFieldUiSchemaType,
|
|
59
58
|
...rest,
|
|
59
|
+
onChange: (newValue: any, _path: any, es?: any, id?: string) => onChange(newValue, es, id),
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
return <SelectField {...checkboxFieldProps} />;
|
|
@@ -68,7 +68,7 @@ export const SelectField: React.FC<SelectFieldProps> = (props) => {
|
|
|
68
68
|
disabled,
|
|
69
69
|
formData,
|
|
70
70
|
hideLabel,
|
|
71
|
-
|
|
71
|
+
fieldPathId,
|
|
72
72
|
label,
|
|
73
73
|
name,
|
|
74
74
|
onBlur,
|
|
@@ -82,7 +82,7 @@ export const SelectField: React.FC<SelectFieldProps> = (props) => {
|
|
|
82
82
|
} = props;
|
|
83
83
|
const [formattedOptions, setFormattedOptions] = useState<OptionType[]>([]);
|
|
84
84
|
const [selectedOption, setSelectedOption] = useState<OptionType | undefined>({});
|
|
85
|
-
const id =
|
|
85
|
+
const id = fieldPathId.$id;
|
|
86
86
|
|
|
87
87
|
const ui = uiSchema?.["ui:options"] || {};
|
|
88
88
|
const contentPadding = (ui?.padding as string) || "";
|
|
@@ -93,7 +93,7 @@ export const SelectField: React.FC<SelectFieldProps> = (props) => {
|
|
|
93
93
|
const enumValues = (schema as RJSFSchema).enum || [];
|
|
94
94
|
let options: OptionType[] = [];
|
|
95
95
|
if (!ui.options && enumValues.length > 0) {
|
|
96
|
-
const enumLabels = ui.enumNames
|
|
96
|
+
const enumLabels = Array.isArray(ui.enumNames) ? ui.enumNames : [];
|
|
97
97
|
const validEnumValues = enumValues.filter(
|
|
98
98
|
(enumValue: any): enumValue is string | number => typeof enumValue === "string" || typeof enumValue === "number"
|
|
99
99
|
);
|
|
@@ -131,7 +131,7 @@ export const SelectField: React.FC<SelectFieldProps> = (props) => {
|
|
|
131
131
|
onInputFocus={() => onFocus(id, formData)}
|
|
132
132
|
onSelect={(option) => {
|
|
133
133
|
setSelectedOption(option);
|
|
134
|
-
onChange(option?.value);
|
|
134
|
+
onChange(option?.value, []);
|
|
135
135
|
}}
|
|
136
136
|
options={formattedOptions}
|
|
137
137
|
placeholder={placeholder}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorSchema,
|
|
1
|
+
import { ErrorSchema, FieldPathId, FieldProps, RJSFSchema, Widget } from "@rjsf/utils";
|
|
2
2
|
import React, { useEffect } from "react";
|
|
3
3
|
import { InlineInput } from "../../InlineInput";
|
|
4
4
|
import { Input, InputType } from "../../Input";
|
|
@@ -34,24 +34,24 @@ export type TextFieldUiSchemaOptions = {
|
|
|
34
34
|
type TextFieldProps = FieldProps & {
|
|
35
35
|
errorSchema?: ErrorSchema;
|
|
36
36
|
formData?: any;
|
|
37
|
-
idSchema: IdSchema;
|
|
38
37
|
idSeparator?: string;
|
|
39
38
|
uiSchema?: TextFieldUiSchemaOptions;
|
|
40
39
|
};
|
|
41
40
|
|
|
42
41
|
// This is a wrapper component to convert the types from the widget to be used with the field types
|
|
43
42
|
export const TextWidget: Widget<any, RJSFSchema, any> = (props) => {
|
|
44
|
-
const { id, value, disabled = false, readonly = false, uiSchema, ...rest } = props;
|
|
43
|
+
const { id, value, disabled = false, readonly = false, uiSchema, onChange, ...rest } = props;
|
|
45
44
|
|
|
46
|
-
const
|
|
45
|
+
const fieldPathId: FieldPathId = { $id: id, path: [] };
|
|
47
46
|
|
|
48
47
|
const checkboxFieldProps: TextFieldProps = {
|
|
49
|
-
|
|
48
|
+
fieldPathId,
|
|
50
49
|
formData: value,
|
|
51
50
|
disabled,
|
|
52
51
|
readonly,
|
|
53
52
|
uiSchema: uiSchema as TextFieldUiSchemaOptions,
|
|
54
53
|
...rest,
|
|
54
|
+
onChange: (newValue: any, _path: any, es?: any, id?: string) => onChange(newValue, es, id),
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
return <TextField {...checkboxFieldProps} />;
|
|
@@ -67,7 +67,7 @@ export const TextField: React.FC<TextFieldProps> = (props) => {
|
|
|
67
67
|
formData, // Specific to Field
|
|
68
68
|
// hideError,
|
|
69
69
|
hideLabel,
|
|
70
|
-
|
|
70
|
+
fieldPathId, // Specific to Field
|
|
71
71
|
label,
|
|
72
72
|
name,
|
|
73
73
|
onBlur,
|
|
@@ -82,7 +82,7 @@ export const TextField: React.FC<TextFieldProps> = (props) => {
|
|
|
82
82
|
schema,
|
|
83
83
|
uiSchema,
|
|
84
84
|
} = props;
|
|
85
|
-
const id =
|
|
85
|
+
const id = fieldPathId.$id;
|
|
86
86
|
|
|
87
87
|
const InputComponent = hideLabel ? InlineInput : Input;
|
|
88
88
|
const ui = uiSchema?.["ui:options"] || {};
|
|
@@ -96,7 +96,7 @@ export const TextField: React.FC<TextFieldProps> = (props) => {
|
|
|
96
96
|
// biome-ignore lint/correctness/useExhaustiveDependencies: skip validation
|
|
97
97
|
useEffect(() => {
|
|
98
98
|
if (formData === "") {
|
|
99
|
-
onChange(undefined);
|
|
99
|
+
onChange(undefined, []);
|
|
100
100
|
}
|
|
101
101
|
}, [formData]);
|
|
102
102
|
|
|
@@ -111,7 +111,7 @@ export const TextField: React.FC<TextFieldProps> = (props) => {
|
|
|
111
111
|
name={name}
|
|
112
112
|
onInputBlur={() => onBlur(id, formData)}
|
|
113
113
|
onInputFocus={() => onFocus(id, formData)}
|
|
114
|
-
onValueChange={onChange}
|
|
114
|
+
onValueChange={(value) => onChange(value, [])}
|
|
115
115
|
placeholder={placeholder}
|
|
116
116
|
required={required}
|
|
117
117
|
showValidationMessage={!!rawErrors?.[0]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorSchema,
|
|
1
|
+
import { ErrorSchema, FieldPathId, FieldProps, RJSFSchema, Widget } from "@rjsf/utils";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Textarea, TextareaType } from "../../Textarea";
|
|
4
4
|
import { FieldBox } from "../RJSFormStyles";
|
|
@@ -32,24 +32,24 @@ export type TextareaFieldUiSchemaOptions = {
|
|
|
32
32
|
type TextareaFieldProps = FieldProps & {
|
|
33
33
|
errorSchema?: ErrorSchema;
|
|
34
34
|
formData?: any;
|
|
35
|
-
idSchema: IdSchema;
|
|
36
35
|
idSeparator?: string;
|
|
37
36
|
uiSchema?: TextareaFieldUiSchemaOptions;
|
|
38
37
|
};
|
|
39
38
|
|
|
40
39
|
// This is a wrapper component to convert the types from the widget to be used with the field types
|
|
41
40
|
export const TextareaWidget: Widget<any, RJSFSchema, any> = (props) => {
|
|
42
|
-
const { id, value, disabled = false, readonly = false, uiSchema, ...rest } = props;
|
|
41
|
+
const { id, value, disabled = false, readonly = false, uiSchema, onChange, ...rest } = props;
|
|
43
42
|
|
|
44
|
-
const
|
|
43
|
+
const fieldPathId: FieldPathId = { $id: id, path: [] };
|
|
45
44
|
|
|
46
45
|
const textareaFieldProps: TextareaFieldProps = {
|
|
47
|
-
|
|
46
|
+
fieldPathId,
|
|
48
47
|
formData: value,
|
|
49
48
|
disabled,
|
|
50
49
|
readonly,
|
|
51
50
|
uiSchema: uiSchema as TextareaFieldUiSchemaOptions,
|
|
52
51
|
...rest,
|
|
52
|
+
onChange: (newValue: any, _path: any, es?: any, id?: string) => onChange(newValue, es, id),
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
return <TextareaField {...textareaFieldProps} />;
|
|
@@ -60,7 +60,7 @@ export const TextareaField: React.FC<TextareaFieldProps> = (props) => {
|
|
|
60
60
|
disabled,
|
|
61
61
|
formData, // Specific to Field
|
|
62
62
|
hideLabel,
|
|
63
|
-
|
|
63
|
+
fieldPathId, // Specific to Field
|
|
64
64
|
label,
|
|
65
65
|
name,
|
|
66
66
|
onBlur,
|
|
@@ -72,7 +72,7 @@ export const TextareaField: React.FC<TextareaFieldProps> = (props) => {
|
|
|
72
72
|
schema,
|
|
73
73
|
uiSchema,
|
|
74
74
|
} = props;
|
|
75
|
-
const id =
|
|
75
|
+
const id = fieldPathId.$id;
|
|
76
76
|
|
|
77
77
|
const ui = uiSchema?.["ui:options"] || {};
|
|
78
78
|
const contentPadding = (ui?.padding as string) || "";
|
|
@@ -81,7 +81,7 @@ export const TextareaField: React.FC<TextareaFieldProps> = (props) => {
|
|
|
81
81
|
<FieldBox $padding={contentPadding}>
|
|
82
82
|
<Textarea
|
|
83
83
|
value={formData}
|
|
84
|
-
onValueChange={onChange}
|
|
84
|
+
onValueChange={(value) => onChange(value, [])}
|
|
85
85
|
disabled={disabled}
|
|
86
86
|
{...(hideLabel ? {} : { helperText: schema.description })}
|
|
87
87
|
htmlId={id}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorSchema,
|
|
1
|
+
import { ErrorSchema, FieldPathId, FieldProps, RJSFSchema, Widget } from "@rjsf/utils";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { ToggleItem, ToggleItemType } from "../../ToggleItem";
|
|
4
4
|
import { FieldBox } from "../RJSFormStyles";
|
|
@@ -14,32 +14,32 @@ export type ToggleFieldUiSchemaOptions = {
|
|
|
14
14
|
type ToggleFieldProps = FieldProps & {
|
|
15
15
|
errorSchema?: ErrorSchema;
|
|
16
16
|
formData?: any;
|
|
17
|
-
idSchema: IdSchema;
|
|
18
17
|
idSeparator?: string;
|
|
19
18
|
uiSchema?: ToggleFieldUiSchemaOptions;
|
|
20
19
|
};
|
|
21
20
|
|
|
22
21
|
// This is a wrapper component to convert the types from the widget to be used with the field types
|
|
23
22
|
export const ToggleWidget: Widget<any, RJSFSchema, any> = (props) => {
|
|
24
|
-
const { id, value, disabled = false, readonly = false, uiSchema, ...rest } = props;
|
|
23
|
+
const { id, value, disabled = false, readonly = false, uiSchema, onChange, ...rest } = props;
|
|
25
24
|
|
|
26
|
-
const
|
|
25
|
+
const fieldPathId: FieldPathId = { $id: id, path: [] };
|
|
27
26
|
|
|
28
27
|
const toggleFieldProps: ToggleFieldProps = {
|
|
29
|
-
|
|
28
|
+
fieldPathId,
|
|
30
29
|
formData: value,
|
|
31
30
|
disabled,
|
|
32
31
|
readonly,
|
|
33
32
|
uiSchema: uiSchema as ToggleFieldUiSchemaOptions,
|
|
34
33
|
...rest,
|
|
34
|
+
onChange: (newValue: any, _path: any, es?: any, id?: string) => onChange(newValue, es, id),
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
return <ToggleField {...toggleFieldProps} />;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
export const ToggleField: React.FC<ToggleFieldProps> = (props) => {
|
|
41
|
-
const { disabled, formData,
|
|
42
|
-
const id =
|
|
41
|
+
const { disabled, formData, fieldPathId, label, name, onChange, schema, uiSchema } = props;
|
|
42
|
+
const id = fieldPathId.$id;
|
|
43
43
|
|
|
44
44
|
const ui = uiSchema?.["ui:options"] || {};
|
|
45
45
|
const contentPadding = (ui?.padding as string) || "";
|
|
@@ -52,7 +52,7 @@ export const ToggleField: React.FC<ToggleFieldProps> = (props) => {
|
|
|
52
52
|
active={!!formData}
|
|
53
53
|
disabled={disabled}
|
|
54
54
|
name={name}
|
|
55
|
-
onToggle={(event) => onChange(event.target?.checked)}
|
|
55
|
+
onToggle={(event) => onChange(event.target?.checked, [])}
|
|
56
56
|
value={formData}
|
|
57
57
|
focusedColor={ui.focusedColor}
|
|
58
58
|
/>
|
|
@@ -982,7 +982,7 @@ describe("Table: Column Filters", () => {
|
|
|
982
982
|
await waitFor(() => userEvent.click(screen.getByText(filterLabel)));
|
|
983
983
|
await userEvent.click(clickoutTarget);
|
|
984
984
|
const element = screen.getByTestId("Slider_component");
|
|
985
|
-
expect(element).toHaveStyle({ opacity: "0" });
|
|
985
|
+
await waitFor(() => expect(element).toHaveStyle({ opacity: "0" }));
|
|
986
986
|
expect(filterFunction).toBeCalledTimes(1);
|
|
987
987
|
});
|
|
988
988
|
|