-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ecfb6f7
commit 2cd8c95
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
cfdraw/.web/src/plugins/components/Fields/BooleanField.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { observer } from "mobx-react-lite"; | ||
|
||
import type { IField } from "@/schema/plugins"; | ||
import type { IBooleanField } from "@/schema/fields"; | ||
import { titleCaseWord } from "@/utils/misc"; | ||
import { getMetaField, setMetaField } from "@/stores/meta"; | ||
import CFSwitch from "@/components/CFSwitch"; | ||
import { useDefaultFieldValue } from "./utils"; | ||
|
||
export interface BooleanFieldProps extends IField<IBooleanField> {} | ||
function BooleanField({ field, definition }: BooleanFieldProps) { | ||
useDefaultFieldValue({ field, definition }); | ||
|
||
return ( | ||
<CFSwitch | ||
label={definition.label ?? titleCaseWord(field)} | ||
value={getMetaField(field)} | ||
setValue={(value) => setMetaField(field, value)} | ||
tooltip={definition.tooltip} | ||
{...definition.props} | ||
/> | ||
); | ||
} | ||
|
||
export default observer(BooleanField); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters