forked from keystonejs/keystone
/
Field.js
37 lines (31 loc) 路 1.01 KB
/
Field.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/** @jsx jsx */
import { jsx } from '@emotion/core';
import { FieldContainer, FieldLabel, FieldDescription, FieldInput } from '@arch-ui/fields';
import { TextDayPicker } from '@arch-ui/day-picker';
import { Alert } from '@arch-ui/alert';
const CalendarDayField = ({ autoFocus, field, value, errors, onChange, isDisabled }) => {
const htmlID = `ks-daypicker-${field.path}`;
return (
<FieldContainer>
<FieldLabel htmlFor={htmlID} field={field} errors={errors} />
<FieldDescription text={field.adminDoc} />
<FieldInput>
<TextDayPicker
id={htmlID}
autoFocus={autoFocus}
date={value}
format={field.config.format}
onChange={onChange}
disabled={isDisabled}
/>
</FieldInput>
{errors.map(({ message, data }) => (
<Alert appearance="danger" key={message}>
{message}
{data ? ` - ${JSON.stringify(data)}` : null}
</Alert>
))}
</FieldContainer>
);
};
export default CalendarDayField;