diff --git a/components/doc/autocomplete/filleddoc.js b/components/doc/autocomplete/filleddoc.js new file mode 100644 index 0000000000..6de79a0a22 --- /dev/null +++ b/components/doc/autocomplete/filleddoc.js @@ -0,0 +1,71 @@ +import { DocSectionCode } from '@/components/doc/common/docsectioncode'; +import { DocSectionText } from '@/components/doc/common/docsectiontext'; +import { AutoComplete } from '@/components/lib/autocomplete/AutoComplete'; +import { useState } from 'react'; + +export function FilledDoc(props) { + const [value, setValue] = useState(''); + const [items, setItems] = useState([]); + + const search = (event) => { + setItems([...Array(10).keys()].map((item) => event.query + '-' + item)); + }; + + const code = { + basic: ` + setValue(e.value)} variant="filled" /> + `, + javascript: ` +import React, { useState } from "react"; +import { AutoComplete } from "primereact/autocomplete"; + +export default function FilledDemo() { + const [value, setValue] = useState(''); + const [items, setItems] = useState([]); + + const search = (event) => { + setItems([...Array(10).keys()].map(item => event.query + '-' + item)); + } + + return ( +
+ setValue(e.value)} variant="filled" /> +
+ ) +} + `, + typescript: ` +import React, { useState } from "react"; +import { AutoComplete, AutoCompleteCompleteEvent } from "primereact/autocomplete"; + +export default function FilledDemo() { + const [value, setValue] = useState(''); + const [items, setItems] = useState([]); + + const search = (event: AutoCompleteCompleteEvent) => { + setItems([...Array(10).keys()].map(item => event.query + '-' + item)); + } + + return ( +
+ setValue(e.value)} variant="filled" /> +
+ ) +} + ` + }; + + return ( + <> + +

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

+
+
+ setValue(e.value)} variant="filled" /> +
+ + + ); +} diff --git a/components/doc/autocomplete/form/formikdoc.js b/components/doc/autocomplete/form/formikdoc.js deleted file mode 100644 index c06936b3bc..0000000000 --- a/components/doc/autocomplete/form/formikdoc.js +++ /dev/null @@ -1,234 +0,0 @@ -import { DocSectionCode } from '@/components/doc/common/docsectioncode'; -import { DocSectionText } from '@/components/doc/common/docsectiontext'; -import { AutoComplete } from '@/components/lib/autocomplete/AutoComplete'; -import { Button } from '@/components/lib/button/Button'; -import { Toast } from '@/components/lib/toast/Toast'; -import { classNames } from '@/components/lib/utils/Utils'; -import { useFormik } from 'formik'; -import { useRef, useState } from 'react'; - -export function FormikDoc(props) { - const toast = useRef(null); - const [items, setItems] = useState([]); - - const show = () => { - toast.current.show({ severity: 'success', summary: 'Form Submitted', detail: formik.values.item }); - }; - - const search = (event) => { - setItems([...Array(10).keys()].map((item) => event.query + '-' + item)); - }; - - const formik = useFormik({ - initialValues: { - item: '' - }, - validate: (data) => { - let errors = {}; - - if (!data.item) { - errors.item = 'Value is required.'; - } - - return errors; - }, - onSubmit: (data) => { - data.item && 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: ` -
-
Value
- - { - formik.setFieldValue('item', e.value); - }} - /> - {getFormErrorMessage('item')} - - - - - ); - }; - - const header = renderHeader(); - - const formik = useFormik({ - initialValues: { - blog: '' - }, - validate: (data) => { - let errors = {}; - - if (!data.blog || data.blog === \`n\`) { - - errors.blog = 'Content is required.'; - } - - return errors; - }, - onSubmit: (data) => { - data.blog && show(); - formik.resetForm(); - } - }); - - const isFormFieldInvalid = (name) => !!(formik.touched[name] && formik.errors[name]); - - const getFormErrorMessage = (name) => { - return isFormFieldInvalid(name) ? {formik.errors[name]} :  ; - }; - - return ( -
-
- - { - formik.setFieldValue('blog', e.textValue); - }} - style={{ height: '320px' }} - /> -
- {getFormErrorMessage('blog')} -
- -
- ) -} - `, - typescript: ` -import React, { useRef } from "react"; -import { useFormik } from 'formik'; -import { Editor, EditorTextChangeEvent } from 'primereact/editor'; -import { Button } from 'primereact/button'; -import { Toast } from 'primereact/toast'; - -export default function FormikDoc() { - const toast = useRef(null); - - const show = () => { - toast.current.show({ severity: 'success', summary: 'Blog Submitted', detail: 'The blog is uploaded' }); - }; - - const renderHeader = () => { - return ( - - - - - - ); - }; - - const header = renderHeader(); - - const formik = useFormik({ - initialValues: { - blog: '' - }, - validate: (data) => { - let errors = {}; - - if (!data.blog || data.blog === \`n\`) { - - errors.blog = 'Content is required.'; - } - - return errors; - }, - onSubmit: (data) => { - data.blog && show(); - formik.resetForm(); - } - }); - - const isFormFieldInvalid = (name) => !!(formik.touched[name] && formik.errors[name]); - - const getFormErrorMessage = (name) => { - return isFormFieldInvalid(name) ? {formik.errors[name]} :  ; - }; - - return ( -
-
- - { - formik.setFieldValue('blog', e.textValue); - }} - style={{ height: '320px' }} - /> -
- {getFormErrorMessage('blog')} -
- -
- ) -} - ` - }; - - return ( - <> - -

- Formik is a popular library for handling forms in React. -

-
-
-
- - { - formik.setFieldValue('blog', e.textValue); - }} - style={{ height: '320px' }} - /> -
- {getFormErrorMessage('blog')} -
- -
- - - ); -} diff --git a/components/doc/editor/form/hookformdoc.js b/components/doc/editor/form/hookformdoc.js deleted file mode 100644 index 00cc88f458..0000000000 --- a/components/doc/editor/form/hookformdoc.js +++ /dev/null @@ -1,220 +0,0 @@ -import { DocSectionCode } from '@/components/doc/common/docsectioncode'; -import { DocSectionText } from '@/components/doc/common/docsectiontext'; -import { Button } from '@/components/lib/button/Button'; -import { Editor } from '@/components/lib/editor/Editor'; -import { Toast } from '@/components/lib/toast/Toast'; -import { useRef } from 'react'; -import { Controller, useForm } from 'react-hook-form'; - -export function HookFormDoc(props) { - const toast = useRef(null); - - const show = () => { - toast.current.show({ severity: 'success', summary: 'Submission Received', detail: 'The blog is uploaded' }); - }; - - const renderHeader = () => { - return ( - - - - - - ); - }; - - const header = renderHeader(); - - const defaultValues = { - blog: '' - }; - - const { - control, - formState: { errors }, - handleSubmit, - reset - } = useForm({ defaultValues }); - - const onSubmit = (data) => { - data.blog && show(); - - reset(); - }; - - const getFormErrorMessage = (name) => { - return errors[name] ? {errors[name].message} :  ; - }; - - return ( -
-
- - field.onChange(e.textValue)} style={{ height: '320px' }} />} - /> -
- {getFormErrorMessage('blog')} -
- -
- ) -} - `, - typescript: ` -import React, { useRef } from "react"; -import { useForm, Controller } from 'react-hook-form'; -import { Editor, EditorTextChangeEvent } from 'primereact/editor'; -import { Button } from 'primereact/button'; -import { Toast } from 'primereact/toast'; - -export default function HookFormDoc() { - const toast = useRef(null); - - const show = () => { - toast.current.show({ severity: 'success', summary: 'Submission Received', detail: 'The blog is uploaded' }); - }; - - const renderHeader = () => { - return ( - - - - - - ); - }; - - const header = renderHeader(); - - const defaultValues = { - blog: '' - }; - - const { - control, - formState: { errors }, - handleSubmit, - reset - } = useForm({ defaultValues }); - - const onSubmit = (data) => { - data.blog && show(); - - reset(); - }; - - const getFormErrorMessage = (name) => { - return errors[name] ? {errors[name].message} :  ; - }; - - return ( -
-
- - field.onChange(e.textValue)} style={{ height: '320px' }} />} - /> -
- {getFormErrorMessage('blog')} -
- -
- ) -} - ` - }; - - return ( - <> - -

- React Hook Form is another popular React library to handle forms. -

-
-
-
- - field.onChange(e.textValue)} style={{ height: '320px' }} />} - /> -
- {getFormErrorMessage('blog')} -
- -
- - - ); -} diff --git a/components/doc/inputmask/filleddoc.js b/components/doc/inputmask/filleddoc.js new file mode 100644 index 0000000000..0312504a88 --- /dev/null +++ b/components/doc/inputmask/filleddoc.js @@ -0,0 +1,56 @@ +import { DocSectionCode } from '@/components/doc/common/docsectioncode'; +import { DocSectionText } from '@/components/doc/common/docsectiontext'; +import { InputMask } from '@/components/lib/inputmask/InputMask'; +import { useState } from 'react'; + +export function FilledDoc(props) { + const [value, setValue] = useState(); + + const code = { + basic: ` + setValue(e.target.value)} mask="99-999999" placeholder="99-999999" /> + `, + javascript: ` +import React, { useState } from "react"; +import { InputMask } from "primereact/inputmask"; + +export default function FilledDemo() { + const [value, setValue] = useState(); + + return ( +
+ setValue(e.target.value)} mask="99-999999" placeholder="99-999999"/> +
+ ) +} + `, + typescript: ` +import React, { useState } from "react"; +import { InputMask, InputMaskChangeEvent } from "primereact/inputmask"; + +export default function FilledDemo() { + const [value, setValue] = useState(); + + return ( +
+ setValue(e.target.value)} mask="99-999999" placeholder="99-999999"/> +
+ ) +} + ` + }; + + return ( + <> + +

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

+
+
+ setValue(e.target.value)} mask="99-999999" placeholder="99-999999" /> +
+ + + ); +} diff --git a/components/doc/inputmask/floatlabeldoc.js b/components/doc/inputmask/floatlabeldoc.js index 9130433dab..a3a81208f9 100644 --- a/components/doc/inputmask/floatlabeldoc.js +++ b/components/doc/inputmask/floatlabeldoc.js @@ -1,6 +1,8 @@ import { DocSectionCode } from '@/components/doc/common/docsectioncode'; import { DocSectionText } from '@/components/doc/common/docsectiontext'; +import { FloatLabel } from '@/components/lib/floatlabel/FloatLabel'; import { InputMask } from '@/components/lib/inputmask/InputMask'; +import Link from 'next/link'; import { useState } from 'react'; export function FloatLabelDoc(props) { @@ -8,24 +10,25 @@ export function FloatLabelDoc(props) { const code = { basic: ` - + setValue(e.target.value)} mask="999-99-9999" /> - + `, javascript: ` import React, { useState } from "react"; import { InputMask } from "primereact/inputmask"; +import { FloatLabel } from "primereact/floatlabel"; export default function FloatLabelDemo() { const [value, setValue] = useState(); return (
- + setValue(e.target.value)} mask="999-99-9999" /> - +
) } @@ -33,16 +36,17 @@ export default function FloatLabelDemo() { typescript: ` import React, { useState } from "react"; import { InputMask, InputMaskChangeEvent } from "primereact/inputmask"; +import { FloatLabel } from "primereact/floatlabel"; export default function FloatLabelDemo() { const [value, setValue] = useState(); return (
- + setValue(e.target.value)} mask="999-99-9999" /> - +
) } @@ -52,13 +56,15 @@ export default function FloatLabelDemo() { return ( <> -

A floating label appears on top of the input field when focused.

+

+ A floating label appears on top of the input field when focused. Visit FloatLabel documentation for more information. +

- + setValue(e.target.value)} mask="999-99-9999" /> - +
diff --git a/components/doc/inputmask/form/formikdoc.js b/components/doc/inputmask/form/formikdoc.js deleted file mode 100644 index c99f9ec3b5..0000000000 --- a/components/doc/inputmask/form/formikdoc.js +++ /dev/null @@ -1,212 +0,0 @@ -import { DocSectionCode } from '@/components/doc/common/docsectioncode'; -import { DocSectionText } from '@/components/doc/common/docsectiontext'; -import { Button } from '@/components/lib/button/Button'; -import { InputMask } from '@/components/lib/inputmask/InputMask'; -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.value }); - }; - - const formik = useFormik({ - initialValues: { - value: '' - }, - validate: (data) => { - let errors = {}; - - if (!data.value) { - errors.value = 'Phone is required.'; - } - - return errors; - }, - onSubmit: (data) => { - 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('value', e.target.value); - }} - mask="99-999999" - placeholder="99-999999" - className={classNames({ 'p-invalid': isFormFieldInvalid('value') })} -/> -{getFormErrorMessage('value')} -