forked from primefaces/primereact
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasicdoc.js
More file actions
69 lines (62 loc) · 2.08 KB
/
basicdoc.js
File metadata and controls
69 lines (62 loc) · 2.08 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { DocSectionCode } from '@/components/doc/common/docsectioncode';
import { DocSectionText } from '@/components/doc/common/docsectiontext';
import { Calendar } from '@/components/lib/calendar/Calendar';
import { useState } from 'react';
export function BasicDoc(props) {
const [date, setDate] = useState(null);
const code = {
basic: `
<Calendar
value={date}
onChange={(e) => setDate(e.value)}
appendTo={typeof window !== 'undefined' ? document.body : null}
/>
`,
javascript: `
import React, { useState } from "react";
import { Calendar } from 'primereact/calendar';
export default function BasicDemo() {
const [date, setDate] = useState(null);
return (
<div className="card flex justify-content-center">
<Calendar
value={date}
onChange={(e) => setDate(e.value)}
appendTo={typeof window !== 'undefined' ? document.body : null}
/>
</div>
)
}
`,
typescript: `
import React, { useState } from "react";
import { Calendar } from 'primereact/calendar';
import { Nullable } from "primereact/ts-helpers";
export default function BasicDemo() {
const [date, setDate] = useState<Nullable<Date>>(null);
return (
<div className="card flex justify-content-center">
<Calendar
value={date}
onChange={(e) => setDate(e.value)}
appendTo={typeof window !== 'undefined' ? document.body : null}
/>
</div>
)
}
`
};
return (
<>
<DocSectionText {...props}>
<p>
Calendar is used a controlled input component with <i>value</i> and <i>onChange</i> properties.
</p>
</DocSectionText>
<div className="card flex justify-content-center">
<Calendar value={date} onChange={(e) => setDate(e.value)} appendTo={typeof window !== 'undefined' ? document.body : null} />
</div>
<DocSectionCode code={code} />
</>
);
}