diff --git a/components/doc/dialog/index.js b/components/doc/dialog/index.js deleted file mode 100644 index c0353de70c..0000000000 --- a/components/doc/dialog/index.js +++ /dev/null @@ -1,1157 +0,0 @@ -import React, { memo } from 'react'; -import Link from 'next/link'; -import { TabView, TabPanel } from '../../lib/tabview/TabView'; -import { useLiveEditorTabs } from '../common/liveeditor'; -import { CodeHighlight } from '../common/codehighlight'; -import { DevelopmentSection } from '../common/developmentsection'; - -const DialogDoc = memo(() => { - const sources = { - class: { - tabName: 'Class Source', - content: ` -import React, { Component } from 'react'; -import { Dialog } from 'primereact/dialog'; -import { Button } from 'primereact/button'; -import './DialogDemo.css'; - -export class DialogDemo extends Component { - - constructor(props) { - super(props); - this.state = { - displayBasic: false, - displayBasic2: false, - displayModal: false, - displayMaximizable: false, - displayPosition: false, - displayResponsive: false, - position: 'center' - }; - - this.onClick = this.onClick.bind(this); - this.onHide = this.onHide.bind(this); - } - - onClick(name, position) { - let state = { - [\`\${name}\`]: true - }; - - if (position) { - state = { - ...state, - position - } - } - - this.setState(state); - } - - onHide(name) { - this.setState({ - [\`\${name}\`]: false - }); - } - - renderFooter(name) { - return ( -
-
- ); - } - - render() { - return ( -
-
-
Basic
-
-
-
-
-
-
- - this.onHide('displayPosition')} - draggable={false} resizable={false}> -

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco - laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. - Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

-
- - - ) - } -} - ` - }, - hooks: { - tabName: 'Hooks Source', - content: ` -import React, { useState } from 'react'; -import { Dialog } from 'primereact/dialog'; -import { Button } from 'primereact/button'; -import './DialogDemo.css'; - -const DialogDemo = () => { - const [displayBasic, setDisplayBasic] = useState(false); - const [displayBasic2, setDisplayBasic2] = useState(false); - const [displayModal, setDisplayModal] = useState(false); - const [displayMaximizable, setDisplayMaximizable] = useState(false); - const [displayPosition, setDisplayPosition] = useState(false); - const [displayResponsive, setDisplayResponsive] = useState(false); - const [position, setPosition] = useState('center'); - - const dialogFuncMap = { - 'displayBasic': setDisplayBasic, - 'displayBasic2': setDisplayBasic2, - 'displayModal': setDisplayModal, - 'displayMaximizable': setDisplayMaximizable, - 'displayPosition': setDisplayPosition, - 'displayResponsive': setDisplayResponsive - } - - const onClick = (name, position) => { - dialogFuncMap[\`\${name}\`](true); - - if (position) { - setPosition(position); - } - } - - const onHide = (name) => { - dialogFuncMap[\`\${name}\`](false); - } - - const renderFooter = (name) => { - return ( -
-
- ); - } - - return ( -
-
-
Basic
-
-
-
-
-
-
- - onHide('displayPosition')} - draggable={false} resizable={false}> -

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco - laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. - Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

-
- - - ) -} - ` - }, - ts: { - tabName: 'TS Source', - content: ` -import React, { useState } from 'react'; -import { Dialog } from 'primereact/dialog'; -import { Button } from 'primereact/button'; -import './DialogDemo.css'; - -const DialogDemo = () => { - const [displayBasic, setDisplayBasic] = useState(false); - const [displayBasic2, setDisplayBasic2] = useState(false); - const [displayModal, setDisplayModal] = useState(false); - const [displayMaximizable, setDisplayMaximizable] = useState(false); - const [displayPosition, setDisplayPosition] = useState(false); - const [displayResponsive, setDisplayResponsive] = useState(false); - const [position, setPosition] = useState('center'); - - const dialogFuncMap = { - 'displayBasic': setDisplayBasic, - 'displayBasic2': setDisplayBasic2, - 'displayModal': setDisplayModal, - 'displayMaximizable': setDisplayMaximizable, - 'displayPosition': setDisplayPosition, - 'displayResponsive': setDisplayResponsive - } - - const onClick = (name, position) => { - dialogFuncMap[\`\${name}\`](true); - - if (position) { - setPosition(position); - } - } - - const onHide = (name) => { - dialogFuncMap[\`\${name}\`](false); - } - - const renderFooter = (name) => { - return ( -
-
- ); - } - - return ( -
-
-
Basic
-
-
-
-
-
-
- - onHide('displayPosition')} - draggable={false} resizable={false}> -

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco - laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. - Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

-
- - - ) -} - ` - }, - browser: { - tabName: 'Browser Source', - imports: ` - - - `, - content: ` -const { useState } = React; -const { Dialog } = primereact.dialog; -const { Button } = primereact.button; - -const DialogDemo = () => { - const [displayBasic, setDisplayBasic] = useState(false); - const [displayBasic2, setDisplayBasic2] = useState(false); - const [displayModal, setDisplayModal] = useState(false); - const [displayMaximizable, setDisplayMaximizable] = useState(false); - const [displayPosition, setDisplayPosition] = useState(false); - const [displayResponsive, setDisplayResponsive] = useState(false); - const [position, setPosition] = useState('center'); - - const dialogFuncMap = { - 'displayBasic': setDisplayBasic, - 'displayBasic2': setDisplayBasic2, - 'displayModal': setDisplayModal, - 'displayMaximizable': setDisplayMaximizable, - 'displayPosition': setDisplayPosition, - 'displayResponsive': setDisplayResponsive - } - - const onClick = (name, position) => { - dialogFuncMap[\`\${name}\`](true); - - if (position) { - setPosition(position); - } - } - - const onHide = (name) => { - dialogFuncMap[\`\${name}\`](false); - } - - const renderFooter = (name) => { - return ( -
-
- ); - } - - return ( -
-
-
Basic
-
-
-
-
-
-
- - onHide('displayPosition')} - draggable={false} resizable={false}> -

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco - laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. - Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

-
- - - ) -} - ` - } - }; - - const extFiles = { - 'demo/DialogDemo.css': { - content: ` -.dialog-demo .p-button { - margin: 0 .5rem 0 0; - min-width: 10rem; -} - -.dialog-demo p { - margin: 0; - line-height: 1.5; -} - -.dialog-demo .p-dialog .p-button { - min-width: 6rem; -} - ` - } - }; - - return ( -
- - -
Import via Module
- - {` -import { Dialog } from 'primereact/dialog'; -`} - - -
Import via CDN
- - {` - -`} - - -
Getting Started
-

- Dialog is used as a container and visibility is managed with visible property where onHide event is required to update the visibility state. -

- - {` -
-); - -const myIcon = ( - -) - - - Content - -`} - - -
Responsive
-

- Dialog width can be adjusted per screen size with the breakpoints option. In example below, default width is set to 50vw and below 961px, width would be 75vw and finally below 641px width becomes 100%. The value of{' '} - breakpoints should be an object literal whose keys are the maximum screen sizes and values are the widths per screen. -

- - - {` - - Content - -`} - - -
Dynamic Content
-

- Dynamic content may move the dialog boundaries outside of the viewport. Common solution is defining max-height via contentStyle so longer content displays a scrollbar. -

- -
Properties
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
idstringnullUnique identifier of the element.
headeranynullTitle content of the dialog.
footeranynullFooter content of the dialog.
visiblebooleanfalseSpecifies the visibility of the dialog.
positionstringcenterPosition of the dialog, options are "center", "top", "bottom", "left", "right", "top-left", "top-right", "bottom-left" or "bottom-right".
modalbooleantrueDefines if background should be blocked when dialog is displayed.
resizablebooleantrueEnables resizing of the content.
draggablebooleantrueEnables dragging to change the position using header.
minXnumber0Minimum value for the left coordinate of dialog in dragging.
minYnumber0Minimum value for the top coordinate of dialog in dragging.
keepInViewportbooleantrueKeeps dialog in the viewport.
headerStyleobjectnullStyle of the header section.
headerClassNamestringnullStyle class of the header section.
contentStyleobjectnullStyle of the content section.
contentClassNamestringnullStyle class of the content section.
closeOnEscapebooleantrueSpecifies if pressing escape key should hide the dialog.
dismissableMaskbooleanfalseSpecifies if clicking the modal background should hide the dialog.
rtlbooleanfalseWhen enabled dialog is displayed in RTL direction.
closablebooleantrueAdds a close icon to the header to hide the dialog.
stylestringnullInline style of the component.
classNamestringnullStyle class of the component.
maskStylestringnullInline style of the mask.
maskClassNamestringnullStyle class of the mask.
showHeaderbooleantrueWhether to show the header or not.
appendToDOM element | stringdocument.body - DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located. -
baseZIndexnumber0Base zIndex value to use in layering.
maximizablebooleanfalseWhether the dialog can be displayed full screen.
blockScrollbooleanfalseWhether background scroll should be blocked when dialog is visible.
iconsanynullCustom icons template for the header.
ariaCloseIconLabelstringnullDefines a string that labels the close icon.
focusOnShowbooleantrueWhen enabled, first button receives focus on show.
maximizedbooleanfalseWhen enabled, the dialog is initially displayed full screen.
breakpointsobjectnullObject literal to define widths per screen size.
transitionOptionsobjectnull - The properties of{' '} - - CSSTransition - {' '} - can be customized, except for "nodeRef" and "in" properties. -
-
- -
Events
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameParametersDescription
onHidenullCallback to invoke when dialog is hidden (Required).
onShownullCallback to invoke when dialog is showed.
onMaximize - event.originalEvent: Browser event
- event.maximized: Whether to show the dialog or not on fullscreen. -
Callback to invoke when toggle maximize icon is clicked.
onDragStartevent: Browser eventCallback to invoke when dialog dragging is initiated.
onDragevent: Browser eventCallback to invoke when dragging dialog.
onDragEndevent: Browser eventCallback to invoke when dialog dragging is completed.
onResizeStartevent: Browser eventCallback to invoke when dialog resizing is initiated.
onResizeevent: Browser eventCallback to invoke while resizing dialog.
onResizeEndevent: Browser eventCallback to invoke when dialog resizing is completed.
onMaskClickevent: Browser eventCallback to invoke when the mask is clicked.
onClickevent: Browser eventCallback to invoke when dialog is clicked.
-
- -
Styling
-

- Following is the list of structural style classes, for theming classes visit theming page. -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameElement
p-dialogContainer element.
p-dialog-titlebarContainer of header.
p-dialog-titleHeader element.
p-dialog-titlebar-iconIcon container inside header.
p-dialog-titlebar-closeClose icon element.
p-dialog-contentContent element
-
- -
Accessibility
- -
Screen Reader
-

- Dialog component uses dialog role along with aria-labelledby referring to the header element however any attribute is passed to the root element so you may use aria-labelledby to override this default - behavior. In addition aria-modal is added since focus is kept within the popup. -

-

- It is recommended to use a trigger component that can be accessed with keyboard such as a button, if not adding tabIndex would be necessary. -

-

- Trigger element also requires aria-expanded and aria-controls to be handled explicitly. -

-

- Close element is a button with an aria-label that refers to the aria.close property of the locale API by default, you may use - closeButtonProps to customize the element and override the default aria-label. -

- - - {` -