From 6153ef62a3cec763a1ee4d301082751b7e73956e Mon Sep 17 00:00:00 2001 From: gucal Date: Tue, 2 Apr 2024 17:02:24 +0300 Subject: [PATCH] Update calendar props and demos --- components/doc/calendar/filleddoc.js | 57 +++++ components/doc/calendar/form/formikdoc.js | 217 -------------------- components/doc/calendar/form/hookfromdoc.js | 179 ---------------- components/doc/calendar/invaliddoc.js | 10 +- components/lib/calendar/Calendar.js | 2 +- components/lib/calendar/CalendarBase.js | 5 + components/lib/calendar/calendar.d.ts | 5 + pages/calendar/index.js | 26 +-- 8 files changed, 79 insertions(+), 422 deletions(-) create mode 100644 components/doc/calendar/filleddoc.js delete mode 100644 components/doc/calendar/form/formikdoc.js delete mode 100644 components/doc/calendar/form/hookfromdoc.js diff --git a/components/doc/calendar/filleddoc.js b/components/doc/calendar/filleddoc.js new file mode 100644 index 0000000000..bc40cba1ea --- /dev/null +++ b/components/doc/calendar/filleddoc.js @@ -0,0 +1,57 @@ +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 FilledDoc(props) { + const [date, setDate] = useState(null); + + const code = { + basic: ` + setDate(e.value)} /> + `, + javascript: ` +import React, { useState } from "react"; +import { Calendar } from 'primereact/calendar'; + +export default function FilledDemo() { + const [date, setDate] = useState(null); + + return ( +
+ setDate(e.value)} /> +
+ ) +} + `, + typescript: ` +import React, { useState } from "react"; +import { Calendar } from 'primereact/calendar'; +import { Nullable } from "primereact/ts-helpers"; + +export default function FilledDemo() { + const [date, setDate] = useState>(null); + + return ( +
+ setDate(e.value)} /> +
+ ) +} + ` + }; + + return ( + <> + +

+ Specify the variant property as filled to display the component with a higher visual emphasis than the default outlined style. +

+
+
+ setDate(e.value)} /> +
+ + + ); +} diff --git a/components/doc/calendar/form/formikdoc.js b/components/doc/calendar/form/formikdoc.js deleted file mode 100644 index 06c3a716e8..0000000000 --- a/components/doc/calendar/form/formikdoc.js +++ /dev/null @@ -1,217 +0,0 @@ -import { DocSectionCode } from '@/components/doc/common/docsectioncode'; -import { DocSectionText } from '@/components/doc/common/docsectiontext'; -import { Button } from '@/components/lib/button/Button'; -import { Calendar } from '@/components/lib/calendar/Calendar'; -import { Toast } from '@/components/lib/toast/Toast'; -import { classNames } from '@/components/lib/utils/Utils'; -import { useFormik } from 'formik'; -import { useRef } from 'react'; - -export function FormikDoc(props) { - const toast = useRef(null); - - const show = () => { - toast.current.show({ severity: 'success', summary: 'Form Submitted', detail: formik.values.date.toLocaleDateString() }); - }; - - const formik = useFormik({ - initialValues: { - date: '' - }, - validate: (data) => { - let errors = {}; - - if (!data.date) { - errors.date = 'Date is required.'; - } - - return errors; - }, - onSubmit: (data) => { - if (!formik.errors.date) { - data && show(data); - formik.resetForm(); - } - } - }); - - const isFormFieldInvalid = (name) => !!(formik.touched[name] && formik.errors[name]); - - const getFormErrorMessage = (name) => { - return isFormFieldInvalid(name) ? {formik.errors[name]} :  ; - }; - - const code = { - basic: ` -
- - - { - formik.setFieldValue('date', e.target.value); - }} - /> - {getFormErrorMessage('date')} -