Skip to content
This repository was archived by the owner on Dec 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f2a43bc
Add FabrixFormConstraint type
IzumiSy Oct 17, 2024
b7a8c6e
Split GraphQL definition files
IzumiSy Oct 18, 2024
8854953
Add test for graphql-config
IzumiSy Oct 18, 2024
fe70e65
Fix lint errors
IzumiSy Oct 18, 2024
5f63fb4
Specified target
IzumiSy Oct 18, 2024
4507207
Remove constraint.graphql
IzumiSy Oct 18, 2024
de54976
pnpm dedupe
IzumiSy Oct 18, 2024
85f2115
Add FabrixFormConstraint type
IzumiSy Oct 17, 2024
bd8ce81
Split GraphQL definition files
IzumiSy Oct 18, 2024
e3b8b38
Add test for graphql-config
IzumiSy Oct 18, 2024
a12e7f7
Fix lint errors
IzumiSy Oct 18, 2024
212f79d
Specified target
IzumiSy Oct 18, 2024
ef42f22
Remove constraint.graphql
IzumiSy Oct 18, 2024
fc9e623
Add input type for constraint
IzumiSy Oct 18, 2024
22d20d3
Added zod schema for constraint fields
IzumiSy Oct 18, 2024
d5a745c
Use constraint in example
IzumiSy Oct 18, 2024
1e4b591
Fallback to empty record
IzumiSy Oct 18, 2024
cb46394
Curved out merger
IzumiSy Oct 18, 2024
52c150c
Spreading
IzumiSy Oct 18, 2024
bbf655f
Implement pluggable merger
IzumiSy Oct 18, 2024
17af376
Merge branch 'split_directive_files' into directive_validation_support
IzumiSy Oct 18, 2024
0460ad3
Fix lint errors
IzumiSy Oct 18, 2024
425ae92
Merge branch 'main' into directive_validation_support
IzumiSy Oct 21, 2024
8c6d76c
Fix lockfile
IzumiSy Oct 21, 2024
c262456
Export constraint schema
IzumiSy Oct 21, 2024
7316701
Remove an unused function
IzumiSy Oct 21, 2024
5815e14
Unabstract meta field
IzumiSy Oct 21, 2024
88f7c95
Add buildFieldMeta function
IzumiSy Oct 21, 2024
73b9b72
Fix type errors
IzumiSy Oct 21, 2024
bfb074a
Rename types
IzumiSy Oct 21, 2024
b15f3ee
Fix types
IzumiSy Oct 21, 2024
67970ff
Add a function to build ajv schema
IzumiSy Oct 21, 2024
4990006
Show errors
IzumiSy Oct 21, 2024
5069719
Removed unnecessary function
IzumiSy Oct 21, 2024
a283ab3
Add multipleOf support
IzumiSy Oct 21, 2024
d34fcaa
Add schema for Float/Int
IzumiSy Oct 21, 2024
a08c29e
Support oneOf
IzumiSy Oct 22, 2024
b9b9920
Use ajv-formats
IzumiSy Oct 24, 2024
8d5909b
Change dir structure for tests and added tests for validation
IzumiSy Oct 24, 2024
b64c666
Merge branch 'main' into directive_validation_support
IzumiSy Oct 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/todoapp/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ function App() {
input: [
{ field: "id", config: { hidden: true } }
{ field: "hasDone", config: { hidden: true } }
{ field: "name", config: { gridCol: 9 } }
{
field: "name"
config: { gridCol: 9 }
constraint: { maxLength: 50 }
}
{ field: "priority", config: { gridCol: 3 } }
]
) {
Expand Down
5 changes: 4 additions & 1 deletion packages/chakra-ui/src/components/default/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
FormComponentProps,
FieldType,
} from "@fabrix-framework/fabrix";
import { Switch, Input, Stack, Button, Box, Text } from "@chakra-ui/react";
import { Text, Switch, Input, Stack, Button, Box } from "@chakra-ui/react";
import { Select } from "chakra-react-select";
import { useController } from "@fabrix-framework/fabrix/rhf";
import { LabelledHeading } from "./shared";
Expand Down Expand Up @@ -121,6 +121,7 @@ const SelectFormField = (
onBlur={field.onBlur}
onChange={(e) => e && field.onChange(e.value)}
/>
<ErrorField {...props} />
</Stack>
);
};
Expand All @@ -136,6 +137,7 @@ const TextFormField = (props: FormFieldComponentProps) => {
<Stack className={attributes.className} spacing={2}>
<LabelledHeading {...props} />
<Input {...field} placeholder="Enter value" />
<ErrorField {...props} />
</Stack>
);
};
Expand Down Expand Up @@ -173,6 +175,7 @@ const BooleanFormField = (props: FormFieldComponentProps) => {
<Stack className={className} spacing={2}>
<LabelledHeading {...props} />
<Switch {...field} size="lg" />
<ErrorField {...props} />
</Stack>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ export const users = [
{
id: faker.string.uuid(),
name: "first user",
code: "u001",
email: faker.internet.email(),
},
{
id: faker.string.uuid(),
name: "second user",
code: "u002",
email: faker.internet.email(),
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const mockSchema = buildSchema(`
type User {
id: ID!
name: String!
code: String!
email: String!
}

type UsersResult {
Expand All @@ -26,9 +26,9 @@ enum UserCategory {
input CreateUserInput {
id: ID
name: String!
code: String!
email: String
age: Int!
category: UserCategory!
category: UserCategory
}

type Mutation {
Expand Down
51 changes: 51 additions & 0 deletions packages/fabrix/__tests__/mutation.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { describe, expect, it } from "vitest";
import { screen, within } from "@testing-library/react";
import { FabrixComponent } from "@renderer";
import { testWithUnmount } from "./supports/render";

describe("mutation", () => {
it("should render the form", async () => {
await testWithUnmount(
<FabrixComponent
query={`
mutation createUser($input: CreateUserInput!) {
createUser(input: $input) {
id
}
}
`}
/>,
async () => {
const form = await screen.findByRole("form");
expect(form).toBeInTheDocument();

const inputs = await within(form).findAllByRole("textbox");
expect(inputs.length).toBe(5);
},
);
});

it("should render the form with customized labels", async () => {
await testWithUnmount(
<FabrixComponent
query={`
mutation createUser($input: CreateUserInput!) {
createUser(input: $input) @fabrixForm(input: [
{ field: "id", config: { hidden: true } },
{ field: "name", config: { label: "UserName" } }
]) {
id
}
}
`}
/>,
async () => {
const form = await screen.findByRole("form");
expect(form).toBeInTheDocument();

expect(within(form).queryByLabelText("id")).not.toBeInTheDocument();
expect(within(form).getByLabelText("UserName")).toBeInTheDocument();
},
);
});
});
Loading