-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(form): improve published versions of uri, select, date fields
- Loading branch information
Showing
7 changed files
with
75 additions
and
4 deletions.
There are no files selected for viewing
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
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,23 @@ | ||
import { CalendarOutlined } from "@ant-design/icons"; | ||
import dayjs from "dayjs"; | ||
import { DATE_DEFAULT_FORMAT, DATE_TIME_DEFAULT_FORMAT } from "../../../utils"; | ||
import TextBoxWidget from "./TextBoxWidget"; | ||
|
||
const DateWidget = ({ value, schema }) => { | ||
return ( | ||
<TextBoxWidget | ||
value={ | ||
value && | ||
dayjs(value).format( | ||
schema.customFormat || | ||
(schema.format === "date-time" | ||
? DATE_TIME_DEFAULT_FORMAT | ||
: DATE_DEFAULT_FORMAT), | ||
) | ||
} | ||
Icon={CalendarOutlined} | ||
/> | ||
); | ||
}; | ||
|
||
export default DateWidget; |
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,8 @@ | ||
import { AppstoreOutlined } from "@ant-design/icons"; | ||
import TextBoxWidget from "./TextBoxWidget"; | ||
|
||
const SelectWidget = ({ value }) => { | ||
return <TextBoxWidget value={value} Icon={AppstoreOutlined} />; | ||
}; | ||
|
||
export default SelectWidget; |
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,19 @@ | ||
import { Tag } from "antd"; | ||
|
||
const TextBoxWidget = ({ value, Icon }) => { | ||
const values = Array.isArray(value) ? value : value ? [value] : []; | ||
return values.length | ||
? values.map((v) => ( | ||
<Tag | ||
key={v} | ||
bordered={false} | ||
color={"#0069961A"} | ||
style={{ borderRadius: "20px", color: "black" }} | ||
> | ||
<Icon style={{ color: "gray" }} /> {v} | ||
</Tag> | ||
)) | ||
: undefined; | ||
}; | ||
|
||
export default TextBoxWidget; |
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
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 |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import TextWidget from "./TextWidget"; | ||
import RichEditorWidget from "./RichEditorWidget"; | ||
import UriWidget from "./UriWidget"; | ||
import DateWidget from "./DateWidget"; | ||
import SelectWidget from "./SelectWidget"; | ||
|
||
const widgets = { | ||
text: TextWidget, | ||
textarea: TextWidget, | ||
uri: UriWidget, | ||
richeditor: RichEditorWidget, | ||
latex: RichEditorWidget, | ||
date: DateWidget, | ||
select: SelectWidget, | ||
}; | ||
|
||
export default widgets; |
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