Skip to content
This repository was archived by the owner on Jul 8, 2025. It is now read-only.

Commit 0b1edec

Browse files
committed
.
1 parent f80507a commit 0b1edec

File tree

2 files changed

+21
-25
lines changed

2 files changed

+21
-25
lines changed

src/forms/rerenders/controls/EnumField.tsx

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
import type {
2+
ControlProps,
23
EnumCellProps,
34
OwnPropsOfEnum,
45
RankedTester,
56
} from "@jsonforms/core";
67
import { isEnumControl, rankWith } from "@jsonforms/core";
7-
import { withJsonFormsEnumProps } from "@jsonforms/react";
88
import {
9-
Input,
10-
Label,
11-
Select,
12-
SelectButton,
13-
TextField,
14-
} from "@stacklok/ui-kit";
9+
withJsonFormsControlProps,
10+
withJsonFormsEnumProps,
11+
} from "@jsonforms/react";
12+
import { Label, Select, SelectButton } from "@stacklok/ui-kit";
1513

16-
import { JsonFormsDescription } from "../utils";
14+
import { getRACPropsFromJSONForms } from "../utils";
1715

18-
const EnumFieldControl = (props: EnumCellProps & OwnPropsOfEnum) => {
16+
// eslint-disable-next-line react-refresh/only-export-components
17+
const EnumFieldControl = (
18+
props: EnumCellProps & OwnPropsOfEnum & ControlProps,
19+
) => {
1920
const items = (props.options ?? []).map(({ label, value }) => ({
2021
textValue: label,
2122
id: value,
2223
}));
24+
const mappedProps = getRACPropsFromJSONForms(props);
2325

24-
console.log({ items });
26+
console.log(mappedProps);
2527

2628
return (
2729
<Select
@@ -31,25 +33,17 @@ const EnumFieldControl = (props: EnumCellProps & OwnPropsOfEnum) => {
3133
className="w-full"
3234
items={items}
3335
>
34-
<Label />
35-
36-
<SelectButton />
37-
</Select>
38-
);
39-
40-
return (
41-
<TextField {...mappedProps}>
42-
<Label className="text-primary text-base mb-2 ">
36+
<Label className="text-primary text-base mb-2">
4337
<div className="flex items-center">
44-
{label}{" "}
38+
{props.label}{" "}
4539
{mappedProps.isRequired === true ? (
4640
<span className="text-red-600">*</span>
4741
) : null}
4842
</div>
4943
</Label>
50-
<Input />
51-
<JsonFormsDescription {...props} />
52-
</TextField>
44+
hello
45+
<SelectButton />
46+
</Select>
5347
);
5448
};
5549

@@ -59,7 +53,9 @@ const tester: RankedTester = (...args) => {
5953
return x;
6054
};
6155

62-
const renderer = withJsonFormsEnumProps(EnumFieldControl, false);
56+
const renderer = withJsonFormsControlProps(
57+
withJsonFormsEnumProps(EnumFieldControl, false),
58+
);
6359

6460
const config = { tester, renderer };
6561

src/forms/rerenders/controls/TextField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const TextFieldControl = (props: ControlProps) => {
1212

1313
return (
1414
<TextField {...mappedProps}>
15-
<Label className="text-primary text-base mb-2 ">
15+
<Label className="text-primary text-base mb-2">
1616
<div className="flex items-center">
1717
{label}{" "}
1818
{mappedProps.isRequired === true ? (

0 commit comments

Comments
 (0)