@patternfly/react-core 5.2.0-prerelease.40 → 5.2.0-prerelease.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/AboutModal/package.json +1 -1
- package/dist/dynamic/components/Accordion/package.json +1 -1
- package/dist/dynamic/components/ActionList/package.json +1 -1
- package/dist/dynamic/components/Alert/package.json +1 -1
- package/dist/dynamic/components/Avatar/package.json +1 -1
- package/dist/dynamic/components/BackToTop/package.json +1 -1
- package/dist/dynamic/components/Backdrop/package.json +1 -1
- package/dist/dynamic/components/BackgroundImage/package.json +1 -1
- package/dist/dynamic/components/Badge/package.json +1 -1
- package/dist/dynamic/components/Banner/package.json +1 -1
- package/dist/dynamic/components/Brand/package.json +1 -1
- package/dist/dynamic/components/Breadcrumb/package.json +1 -1
- package/dist/dynamic/components/Button/package.json +1 -1
- package/dist/dynamic/components/CalendarMonth/package.json +1 -1
- package/dist/dynamic/components/Card/package.json +1 -1
- package/dist/dynamic/components/Checkbox/package.json +1 -1
- package/dist/dynamic/components/Chip/package.json +1 -1
- package/dist/dynamic/components/ClipboardCopy/package.json +1 -1
- package/dist/dynamic/components/CodeBlock/package.json +1 -1
- package/dist/dynamic/components/DataList/package.json +1 -1
- package/dist/dynamic/components/DatePicker/package.json +1 -1
- package/dist/dynamic/components/DescriptionList/package.json +1 -1
- package/dist/dynamic/components/Divider/package.json +1 -1
- package/dist/dynamic/components/DragDrop/package.json +1 -1
- package/dist/dynamic/components/Drawer/package.json +1 -1
- package/dist/dynamic/components/Dropdown/package.json +1 -1
- package/dist/dynamic/components/DualListSelector/package.json +1 -1
- package/dist/dynamic/components/EmptyState/package.json +1 -1
- package/dist/dynamic/components/ExpandableSection/package.json +1 -1
- package/dist/dynamic/components/FileUpload/package.json +1 -1
- package/dist/dynamic/components/Form/package.json +1 -1
- package/dist/dynamic/components/FormSelect/package.json +1 -1
- package/dist/dynamic/components/HelperText/package.json +1 -1
- package/dist/dynamic/components/Hint/package.json +1 -1
- package/dist/dynamic/components/Icon/package.json +1 -1
- package/dist/dynamic/components/InputGroup/package.json +1 -1
- package/dist/dynamic/components/JumpLinks/package.json +1 -1
- package/dist/dynamic/components/Label/package.json +1 -1
- package/dist/dynamic/components/List/package.json +1 -1
- package/dist/dynamic/components/LoginPage/package.json +1 -1
- package/dist/dynamic/components/Masthead/package.json +1 -1
- package/dist/dynamic/components/Menu/package.json +1 -1
- package/dist/dynamic/components/MenuToggle/package.json +1 -1
- package/dist/dynamic/components/Modal/package.json +1 -1
- package/dist/dynamic/components/MultipleFileUpload/package.json +1 -1
- package/dist/dynamic/components/Nav/package.json +1 -1
- package/dist/dynamic/components/NotificationBadge/package.json +1 -1
- package/dist/dynamic/components/NotificationDrawer/package.json +1 -1
- package/dist/dynamic/components/NumberInput/package.json +1 -1
- package/dist/dynamic/components/OverflowMenu/package.json +1 -1
- package/dist/dynamic/components/Page/package.json +1 -1
- package/dist/dynamic/components/Pagination/package.json +1 -1
- package/dist/dynamic/components/Panel/package.json +1 -1
- package/dist/dynamic/components/Popover/package.json +1 -1
- package/dist/dynamic/components/Progress/package.json +1 -1
- package/dist/dynamic/components/ProgressStepper/package.json +1 -1
- package/dist/dynamic/components/Radio/package.json +1 -1
- package/dist/dynamic/components/SearchInput/package.json +1 -1
- package/dist/dynamic/components/Select/package.json +1 -1
- package/dist/dynamic/components/Sidebar/package.json +1 -1
- package/dist/dynamic/components/SimpleList/package.json +1 -1
- package/dist/dynamic/components/Skeleton/package.json +1 -1
- package/dist/dynamic/components/SkipToContent/package.json +1 -1
- package/dist/dynamic/components/Slider/package.json +1 -1
- package/dist/dynamic/components/Spinner/package.json +1 -1
- package/dist/dynamic/components/Switch/package.json +1 -1
- package/dist/dynamic/components/Tabs/package.json +1 -1
- package/dist/dynamic/components/Text/package.json +1 -1
- package/dist/dynamic/components/TextArea/package.json +1 -1
- package/dist/dynamic/components/TextInput/package.json +1 -1
- package/dist/dynamic/components/TextInputGroup/package.json +1 -1
- package/dist/dynamic/components/Tile/package.json +1 -1
- package/dist/dynamic/components/TimePicker/package.json +1 -1
- package/dist/dynamic/components/Timestamp/package.json +1 -1
- package/dist/dynamic/components/Title/package.json +1 -1
- package/dist/dynamic/components/ToggleGroup/package.json +1 -1
- package/dist/dynamic/components/Toolbar/package.json +1 -1
- package/dist/dynamic/components/Tooltip/package.json +1 -1
- package/dist/dynamic/components/TreeView/package.json +1 -1
- package/dist/dynamic/components/Truncate/package.json +1 -1
- package/dist/dynamic/components/Wizard/hooks/package.json +1 -1
- package/dist/dynamic/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/ApplicationLauncher/package.json +1 -1
- package/dist/dynamic/deprecated/components/ContextSelector/package.json +1 -1
- package/dist/dynamic/deprecated/components/Dropdown/package.json +1 -1
- package/dist/dynamic/deprecated/components/OptionsMenu/package.json +1 -1
- package/dist/dynamic/deprecated/components/PageHeader/package.json +1 -1
- package/dist/dynamic/deprecated/components/Select/package.json +1 -1
- package/dist/dynamic/deprecated/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/dynamic/helpers/FocusTrap/FocusTrap/package.json +1 -1
- package/dist/dynamic/helpers/GenerateId/GenerateId/package.json +1 -1
- package/dist/dynamic/helpers/KeyboardHandler/package.json +1 -1
- package/dist/dynamic/helpers/OUIA/ouia/package.json +1 -1
- package/dist/dynamic/helpers/Popper/Popper/package.json +1 -1
- package/dist/dynamic/helpers/constants/package.json +1 -1
- package/dist/dynamic/helpers/datetimeUtils/package.json +1 -1
- package/dist/dynamic/helpers/favorites/package.json +1 -1
- package/dist/dynamic/helpers/fileUtils/package.json +1 -1
- package/dist/dynamic/helpers/htmlConstants/package.json +1 -1
- package/dist/dynamic/helpers/package.json +1 -1
- package/dist/dynamic/helpers/resizeObserver/package.json +1 -1
- package/dist/dynamic/helpers/typeUtils/package.json +1 -1
- package/dist/dynamic/helpers/useInterval/package.json +1 -1
- package/dist/dynamic/helpers/useIsomorphicLayout/package.json +1 -1
- package/dist/dynamic/helpers/useUnmountEffect/package.json +1 -1
- package/dist/dynamic/helpers/util/package.json +1 -1
- package/dist/dynamic/layouts/Bullseye/package.json +1 -1
- package/dist/dynamic/layouts/Flex/package.json +1 -1
- package/dist/dynamic/layouts/Gallery/package.json +1 -1
- package/dist/dynamic/layouts/Grid/package.json +1 -1
- package/dist/dynamic/layouts/Level/package.json +1 -1
- package/dist/dynamic/layouts/Split/package.json +1 -1
- package/dist/dynamic/layouts/Stack/package.json +1 -1
- package/dist/dynamic/next/components/Modal/package.json +1 -0
- package/dist/dynamic/next/components/package.json +1 -1
- package/dist/esm/components/DragDrop/index.d.ts +1 -0
- package/dist/esm/components/DragDrop/index.d.ts.map +1 -1
- package/dist/esm/components/DragDrop/index.js +1 -0
- package/dist/esm/components/DragDrop/index.js.map +1 -1
- package/dist/esm/components/DualListSelector/index.d.ts +2 -0
- package/dist/esm/components/DualListSelector/index.d.ts.map +1 -1
- package/dist/esm/components/DualListSelector/index.js +2 -0
- package/dist/esm/components/DualListSelector/index.js.map +1 -1
- package/dist/esm/components/index.d.ts +1 -1
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/next/components/Modal/Modal.d.ts +73 -0
- package/dist/esm/next/components/Modal/Modal.d.ts.map +1 -0
- package/dist/esm/next/components/Modal/Modal.js +114 -0
- package/dist/esm/next/components/Modal/Modal.js.map +1 -0
- package/dist/esm/next/components/Modal/ModalBody.d.ts +19 -0
- package/dist/esm/next/components/Modal/ModalBody.d.ts.map +1 -0
- package/dist/esm/next/components/Modal/ModalBody.js +11 -0
- package/dist/esm/next/components/Modal/ModalBody.js.map +1 -0
- package/dist/esm/next/components/Modal/ModalBox.d.ts +21 -0
- package/dist/esm/next/components/Modal/ModalBox.d.ts.map +1 -0
- package/dist/esm/next/components/Modal/ModalBox.js +15 -0
- package/dist/esm/next/components/Modal/ModalBox.js.map +1 -0
- package/dist/esm/next/components/Modal/ModalBoxCloseButton.d.ts +14 -0
- package/dist/esm/next/components/Modal/ModalBoxCloseButton.d.ts.map +1 -0
- package/dist/esm/next/components/Modal/ModalBoxCloseButton.js +14 -0
- package/dist/esm/next/components/Modal/ModalBoxCloseButton.js.map +1 -0
- package/dist/esm/next/components/Modal/ModalBoxDescription.d.ts +11 -0
- package/dist/esm/next/components/Modal/ModalBoxDescription.d.ts.map +1 -0
- package/dist/esm/next/components/Modal/ModalBoxDescription.js +10 -0
- package/dist/esm/next/components/Modal/ModalBoxDescription.js.map +1 -0
- package/dist/esm/next/components/Modal/ModalBoxTitle.d.ts +17 -0
- package/dist/esm/next/components/Modal/ModalBoxTitle.d.ts.map +1 -0
- package/dist/esm/next/components/Modal/ModalBoxTitle.js +38 -0
- package/dist/esm/next/components/Modal/ModalBoxTitle.js.map +1 -0
- package/dist/esm/next/components/Modal/ModalContent.d.ts +42 -0
- package/dist/esm/next/components/Modal/ModalContent.d.ts.map +1 -0
- package/dist/esm/next/components/Modal/ModalContent.js +45 -0
- package/dist/esm/next/components/Modal/ModalContent.js.map +1 -0
- package/dist/esm/next/components/Modal/ModalFooter.d.ts +10 -0
- package/dist/esm/next/components/Modal/ModalFooter.d.ts.map +1 -0
- package/dist/esm/next/components/Modal/ModalFooter.js +10 -0
- package/dist/esm/next/components/Modal/ModalFooter.js.map +1 -0
- package/dist/esm/next/components/Modal/ModalHeader.d.ts +25 -0
- package/dist/esm/next/components/Modal/ModalHeader.d.ts.map +1 -0
- package/dist/esm/next/components/Modal/ModalHeader.js +21 -0
- package/dist/esm/next/components/Modal/ModalHeader.js.map +1 -0
- package/dist/esm/next/components/Modal/index.d.ts +5 -0
- package/dist/esm/next/components/Modal/index.d.ts.map +1 -0
- package/dist/esm/next/components/Modal/index.js +5 -0
- package/dist/esm/next/components/Modal/index.js.map +1 -0
- package/dist/esm/next/components/index.d.ts +1 -1
- package/dist/esm/next/components/index.d.ts.map +1 -1
- package/dist/esm/next/components/index.js +1 -1
- package/dist/esm/next/components/index.js.map +1 -1
- package/dist/js/components/DragDrop/index.d.ts +1 -0
- package/dist/js/components/DragDrop/index.d.ts.map +1 -1
- package/dist/js/components/DragDrop/index.js +1 -0
- package/dist/js/components/DragDrop/index.js.map +1 -1
- package/dist/js/components/DualListSelector/index.d.ts +2 -0
- package/dist/js/components/DualListSelector/index.d.ts.map +1 -1
- package/dist/js/components/DualListSelector/index.js +2 -0
- package/dist/js/components/DualListSelector/index.js.map +1 -1
- package/dist/js/components/index.d.ts +1 -1
- package/dist/js/components/index.d.ts.map +1 -1
- package/dist/js/components/index.js +1 -1
- package/dist/js/components/index.js.map +1 -1
- package/dist/js/next/components/Modal/Modal.d.ts +73 -0
- package/dist/js/next/components/Modal/Modal.d.ts.map +1 -0
- package/dist/js/next/components/Modal/Modal.js +117 -0
- package/dist/js/next/components/Modal/Modal.js.map +1 -0
- package/dist/js/next/components/Modal/ModalBody.d.ts +19 -0
- package/dist/js/next/components/Modal/ModalBody.d.ts.map +1 -0
- package/dist/js/next/components/Modal/ModalBody.js +15 -0
- package/dist/js/next/components/Modal/ModalBody.js.map +1 -0
- package/dist/js/next/components/Modal/ModalBox.d.ts +21 -0
- package/dist/js/next/components/Modal/ModalBox.d.ts.map +1 -0
- package/dist/js/next/components/Modal/ModalBox.js +19 -0
- package/dist/js/next/components/Modal/ModalBox.js.map +1 -0
- package/dist/js/next/components/Modal/ModalBoxCloseButton.d.ts +14 -0
- package/dist/js/next/components/Modal/ModalBoxCloseButton.d.ts.map +1 -0
- package/dist/js/next/components/Modal/ModalBoxCloseButton.js +18 -0
- package/dist/js/next/components/Modal/ModalBoxCloseButton.js.map +1 -0
- package/dist/js/next/components/Modal/ModalBoxDescription.d.ts +11 -0
- package/dist/js/next/components/Modal/ModalBoxDescription.d.ts.map +1 -0
- package/dist/js/next/components/Modal/ModalBoxDescription.js +14 -0
- package/dist/js/next/components/Modal/ModalBoxDescription.js.map +1 -0
- package/dist/js/next/components/Modal/ModalBoxTitle.d.ts +17 -0
- package/dist/js/next/components/Modal/ModalBoxTitle.d.ts.map +1 -0
- package/dist/js/next/components/Modal/ModalBoxTitle.js +43 -0
- package/dist/js/next/components/Modal/ModalBoxTitle.js.map +1 -0
- package/dist/js/next/components/Modal/ModalContent.d.ts +42 -0
- package/dist/js/next/components/Modal/ModalContent.d.ts.map +1 -0
- package/dist/js/next/components/Modal/ModalContent.js +49 -0
- package/dist/js/next/components/Modal/ModalContent.js.map +1 -0
- package/dist/js/next/components/Modal/ModalFooter.d.ts +10 -0
- package/dist/js/next/components/Modal/ModalFooter.d.ts.map +1 -0
- package/dist/js/next/components/Modal/ModalFooter.js +14 -0
- package/dist/js/next/components/Modal/ModalFooter.js.map +1 -0
- package/dist/js/next/components/Modal/ModalHeader.d.ts +25 -0
- package/dist/js/next/components/Modal/ModalHeader.d.ts.map +1 -0
- package/dist/js/next/components/Modal/ModalHeader.js +25 -0
- package/dist/js/next/components/Modal/ModalHeader.js.map +1 -0
- package/dist/js/next/components/Modal/index.d.ts +5 -0
- package/dist/js/next/components/Modal/index.d.ts.map +1 -0
- package/dist/js/next/components/Modal/index.js +8 -0
- package/dist/js/next/components/Modal/index.js.map +1 -0
- package/dist/js/next/components/index.d.ts +1 -1
- package/dist/js/next/components/index.d.ts.map +1 -1
- package/dist/js/next/components/index.js +1 -1
- package/dist/js/next/components/index.js.map +1 -1
- package/dist/umd/react-core.min.js +1 -1
- package/helpers/package.json +1 -1
- package/layouts/package.json +1 -1
- package/next/package.json +1 -1
- package/package.json +2 -2
- package/src/components/DataList/examples/DataList.md +2 -2
- package/src/components/DragDrop/examples/DragDrop.md +4 -2
- package/src/components/DragDrop/examples/DragDropBasic.tsx +4 -4
- package/src/components/DragDrop/examples/DragDropMultipleLists.tsx +7 -2
- package/src/components/DragDrop/index.ts +1 -0
- package/src/components/DualListSelector/examples/DualListSelector.md +3 -1
- package/src/components/DualListSelector/index.ts +2 -0
- package/src/components/index.ts +1 -1
- package/src/next/components/Modal/Modal.tsx +202 -0
- package/src/next/components/Modal/ModalBody.tsx +42 -0
- package/src/next/components/Modal/ModalBox.tsx +63 -0
- package/src/next/components/Modal/ModalBoxCloseButton.tsx +38 -0
- package/src/next/components/Modal/ModalBoxDescription.tsx +24 -0
- package/src/next/components/Modal/ModalBoxTitle.tsx +75 -0
- package/src/next/components/Modal/ModalContent.tsx +131 -0
- package/src/next/components/Modal/ModalFooter.tsx +23 -0
- package/src/next/components/Modal/ModalHeader.tsx +71 -0
- package/src/next/components/Modal/__tests__/Modal.test.tsx +145 -0
- package/src/next/components/Modal/__tests__/ModalBody.test.tsx +60 -0
- package/src/next/components/Modal/__tests__/ModalBox.test.tsx +58 -0
- package/src/next/components/Modal/__tests__/ModalBoxCloseButton.test.tsx +18 -0
- package/src/next/components/Modal/__tests__/ModalBoxDescription.test.tsx +8 -0
- package/src/next/components/Modal/__tests__/ModalBoxHeader.test.tsx +21 -0
- package/src/next/components/Modal/__tests__/ModalBoxTitle.test.tsx +37 -0
- package/src/next/components/Modal/__tests__/ModalContent.test.tsx +46 -0
- package/src/next/components/Modal/__tests__/ModalFooter.test.tsx +8 -0
- package/src/next/components/Modal/__tests__/__snapshots__/ModalBody.test.tsx.snap +12 -0
- package/src/next/components/Modal/__tests__/__snapshots__/ModalBox.test.tsx.snap +86 -0
- package/src/next/components/Modal/__tests__/__snapshots__/ModalBoxDescription.test.tsx.snap +12 -0
- package/src/next/components/Modal/__tests__/__snapshots__/ModalBoxHeader.test.tsx.snap +46 -0
- package/src/next/components/Modal/__tests__/__snapshots__/ModalBoxTitle.test.tsx.snap +218 -0
- package/src/next/components/Modal/__tests__/__snapshots__/ModalContent.test.tsx.snap +128 -0
- package/src/next/components/Modal/__tests__/__snapshots__/ModalFooter.test.tsx.snap +11 -0
- package/src/next/components/Modal/examples/Modal.md +148 -0
- package/src/next/components/Modal/examples/ModalBasic.tsx +43 -0
- package/src/next/components/Modal/examples/ModalCustomFocus.tsx +43 -0
- package/src/next/components/Modal/examples/ModalCustomHeader.tsx +58 -0
- package/src/next/components/Modal/examples/ModalCustomTitleIcon.tsx +54 -0
- package/src/next/components/Modal/examples/ModalCustomWidth.tsx +43 -0
- package/src/next/components/Modal/examples/ModalNoHeaderFooter.tsx +40 -0
- package/src/next/components/Modal/examples/ModalSize.tsx +63 -0
- package/src/next/components/Modal/examples/ModalTitleIcon.tsx +48 -0
- package/src/next/components/Modal/examples/ModalTopAligned.tsx +43 -0
- package/src/next/components/Modal/examples/ModalWithDescription.tsx +80 -0
- package/src/next/components/Modal/examples/ModalWithDropdown.tsx +105 -0
- package/src/next/components/Modal/examples/ModalWithForm.tsx +211 -0
- package/src/next/components/Modal/examples/ModalWithHelp.tsx +63 -0
- package/src/next/components/Modal/examples/ModalWithOverflowingContent.tsx +75 -0
- package/src/next/components/Modal/examples/ModalWithWizard.tsx +59 -0
- package/src/next/components/Modal/index.ts +4 -0
- package/src/next/components/index.ts +1 -1
package/helpers/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"5.2.0-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"5.2.0-prerelease.41","private":true}
|
package/layouts/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"5.2.0-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"5.2.0-prerelease.41","private":true}
|
package/next/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"5.2.0-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"5.2.0-prerelease.41","private":true}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "5.2.0-prerelease.
|
|
3
|
+
"version": "5.2.0-prerelease.42",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"react": "^17 || ^18",
|
|
72
72
|
"react-dom": "^17 || ^18"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "f4175ffc4c4db378d9512951f02e115128b675cb"
|
|
75
75
|
}
|
|
@@ -86,9 +86,9 @@ import global_BorderWidth_sm from '@patternfly/react-tokens/dist/esm/global_Bord
|
|
|
86
86
|
|
|
87
87
|
### Draggable
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
Note: There is a new recommended drag and drop implementation with full keyboard functionality, which replaces this implementation. To adhere to our new recommendations, refer to the [drag and drop demos](/components/drag-and-drop/react-next-demos).
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
Previously, draggable data lists had their own API for the [drag and drop component](/components/drag-and-drop), which wasn't flexible enough to allow custom styling for items as they are dragged. To address this disparity, `<DragDrop>`, `<Draggable>`, and `<Droppable>` components were added to replace our now deprecated HTML5-based API. Keyboard and screen reader accessibility for the `<DragDrop>` component is still in development.
|
|
92
92
|
|
|
93
93
|
```ts isBeta file="./DataListDraggable.tsx"
|
|
94
94
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
id: Drag and drop
|
|
3
3
|
section: components
|
|
4
4
|
propComponents: [DragDrop, Draggable, Droppable, DraggableItemPosition]
|
|
5
|
-
|
|
5
|
+
title: Drag and drop
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
You can use the
|
|
8
|
+
You can use the `<DragDrop>` component to move items in or between lists. The `<DragDrop>` component should contain `<Droppable>` components which contain `<Draggable>` components.
|
|
9
9
|
|
|
10
10
|
```ts noLive
|
|
11
11
|
import React from 'react';
|
|
@@ -35,9 +35,11 @@ Note: Keyboard accessibility and screen reader accessibility are still in develo
|
|
|
35
35
|
### Basic
|
|
36
36
|
|
|
37
37
|
```ts file="./DragDropBasic.tsx"
|
|
38
|
+
|
|
38
39
|
```
|
|
39
40
|
|
|
40
41
|
### Multiple lists
|
|
41
42
|
|
|
42
43
|
```ts file="./DragDropMultipleLists.tsx"
|
|
44
|
+
|
|
43
45
|
```
|
|
@@ -20,14 +20,14 @@ const getItems = (count: number) =>
|
|
|
20
20
|
}));
|
|
21
21
|
|
|
22
22
|
const reorder = (list: ItemType[], startIndex: number, endIndex: number) => {
|
|
23
|
-
const result = list;
|
|
23
|
+
const result = [...list];
|
|
24
24
|
const [removed] = result.splice(startIndex, 1);
|
|
25
25
|
result.splice(endIndex, 0, removed);
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
export const DragDropBasic: React.FunctionComponent = () => {
|
|
30
|
-
const [items, setItems] = React.useState(getItems(10));
|
|
30
|
+
const [items, setItems] = React.useState<ItemType[]>(getItems(10));
|
|
31
31
|
|
|
32
32
|
function onDrop(source: SourceType, dest: DestinationType) {
|
|
33
33
|
if (dest) {
|
|
@@ -42,8 +42,8 @@ export const DragDropBasic: React.FunctionComponent = () => {
|
|
|
42
42
|
return (
|
|
43
43
|
<DragDrop onDrop={onDrop}>
|
|
44
44
|
<Droppable>
|
|
45
|
-
{items.map(({ content }
|
|
46
|
-
<Draggable key={
|
|
45
|
+
{items.map(({ id, content }) => (
|
|
46
|
+
<Draggable key={id} style={{ padding: '8px' }}>
|
|
47
47
|
{content}
|
|
48
48
|
</Draggable>
|
|
49
49
|
))}
|
|
@@ -11,6 +11,11 @@ interface SourceType {
|
|
|
11
11
|
index: number;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
interface MultipleListState {
|
|
15
|
+
items1: ItemType[];
|
|
16
|
+
items2: ItemType[];
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
interface DestinationType extends SourceType {}
|
|
15
20
|
|
|
16
21
|
const getItems = (count: number, startIndex: number) =>
|
|
@@ -35,7 +40,7 @@ const move = (source: ItemType[], destination: ItemType[], sourceIndex: number,
|
|
|
35
40
|
};
|
|
36
41
|
|
|
37
42
|
export const DragDropMultipleLists: React.FunctionComponent = () => {
|
|
38
|
-
const [items, setItems] = React.useState({
|
|
43
|
+
const [items, setItems] = React.useState<MultipleListState>({
|
|
39
44
|
items1: getItems(10, 0),
|
|
40
45
|
items2: getItems(5, 10)
|
|
41
46
|
});
|
|
@@ -84,7 +89,7 @@ export const DragDropMultipleLists: React.FunctionComponent = () => {
|
|
|
84
89
|
{Object.entries(items).map(([key, subitems]) => (
|
|
85
90
|
<SplitItem key={key} style={{ flex: 1 }}>
|
|
86
91
|
<Droppable zone="multizone" droppableId={key}>
|
|
87
|
-
{subitems.map(({ id, content }) => (
|
|
92
|
+
{(subitems as ItemType[]).map(({ id, content }) => (
|
|
88
93
|
<Draggable key={id} style={{ padding: '8px' }}>
|
|
89
94
|
{content}
|
|
90
95
|
</Draggable>
|
|
@@ -87,6 +87,8 @@ The dual list selector can also be built in a composable manner to make customiz
|
|
|
87
87
|
|
|
88
88
|
### Composable with drag and drop
|
|
89
89
|
|
|
90
|
+
Note: There is a new recommended drag and drop implementation with full keyboard functionality, which replaces this implementation. To adhere to our new recommendations, refer to the [drag and drop demos](/components/drag-and-drop/react-next-demos).
|
|
91
|
+
|
|
90
92
|
This example only allows reordering the contents of the "chosen" pane with drag and drop. To make a pane able to be reordered:
|
|
91
93
|
|
|
92
94
|
- wrap the `DualListSelectorPane` in a `DragDrop` component
|
|
@@ -99,7 +101,7 @@ This example only allows reordering the contents of the "chosen" pane with drag
|
|
|
99
101
|
- define an `onDrag` callback which ensures that the drag event will not cross hairs with the `onOptionSelect` click
|
|
100
102
|
event set on the option. Note: the `ignoreNextOptionSelect` state value is used to prevent selection while dragging.
|
|
101
103
|
|
|
102
|
-
|
|
104
|
+
Keyboard and screen reader accessibility for the `<DragDrop>` component is still in development.
|
|
103
105
|
|
|
104
106
|
```ts file="DualListSelectorComposableDragDrop.tsx"
|
|
105
107
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from './DualListSelector';
|
|
2
|
+
export * from './DualListSelectorContext';
|
|
2
3
|
export * from './DualListSelectorControl';
|
|
3
4
|
export * from './DualListSelectorControlsWrapper';
|
|
4
5
|
export * from './DualListSelectorPane';
|
|
5
6
|
export * from './DualListSelectorList';
|
|
6
7
|
export * from './DualListSelectorListItem';
|
|
7
8
|
export * from './DualListSelectorTree';
|
|
9
|
+
export * from './DualListSelectorContext';
|
package/src/components/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ export * from './DataList';
|
|
|
22
22
|
export * from './DatePicker';
|
|
23
23
|
export * from './DescriptionList';
|
|
24
24
|
export * from './Divider';
|
|
25
|
+
export * from './DragDrop';
|
|
25
26
|
export * from './Drawer';
|
|
26
27
|
export * from './Dropdown';
|
|
27
28
|
export * from './DualListSelector';
|
|
@@ -76,7 +77,6 @@ export * from './Tooltip';
|
|
|
76
77
|
export * from './NumberInput';
|
|
77
78
|
export * from './TreeView';
|
|
78
79
|
export * from './Wizard';
|
|
79
|
-
export * from './DragDrop';
|
|
80
80
|
export * from './TextInputGroup';
|
|
81
81
|
export * from './Panel';
|
|
82
82
|
export * from './Truncate';
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as ReactDOM from 'react-dom';
|
|
3
|
+
import { canUseDOM, KeyTypes, PickOptional } from '../../../helpers';
|
|
4
|
+
import { css } from '@patternfly/react-styles';
|
|
5
|
+
import styles from '@patternfly/react-styles/css/components/Backdrop/backdrop';
|
|
6
|
+
import { ModalContent } from './ModalContent';
|
|
7
|
+
import { OUIAProps, getDefaultOUIAId } from '../../../helpers';
|
|
8
|
+
|
|
9
|
+
export interface ModalProps extends React.HTMLProps<HTMLDivElement>, OUIAProps {
|
|
10
|
+
/** The parent container to append the modal to. Defaults to "document.body". */
|
|
11
|
+
appendTo?: HTMLElement | (() => HTMLElement);
|
|
12
|
+
/** Id to use for the modal box description. This should match the ModalHeader labelId or descriptorId. */
|
|
13
|
+
'aria-describedby'?: string;
|
|
14
|
+
/** Adds an accessible name to the modal when there is no title in the ModalHeader. */
|
|
15
|
+
'aria-label'?: string;
|
|
16
|
+
/** Id to use for the modal box label. This should include the ModalHeader labelId. */
|
|
17
|
+
'aria-labelledby'?: string;
|
|
18
|
+
/** Content rendered inside the modal. */
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
/** Additional classes added to the modal. */
|
|
21
|
+
className?: string;
|
|
22
|
+
/** Flag to disable focus trap. */
|
|
23
|
+
disableFocusTrap?: boolean;
|
|
24
|
+
/** The element to focus when the modal opens. By default the first
|
|
25
|
+
* focusable element will receive focus.
|
|
26
|
+
*/
|
|
27
|
+
elementToFocus?: HTMLElement | SVGElement | string;
|
|
28
|
+
/** An id to use for the modal box container. */
|
|
29
|
+
id?: string;
|
|
30
|
+
/** Flag to show the modal. */
|
|
31
|
+
isOpen?: boolean;
|
|
32
|
+
/** Add callback for when the close button is clicked. This prop needs to be passed to render the close button */
|
|
33
|
+
onClose?: (event: KeyboardEvent | React.MouseEvent) => void;
|
|
34
|
+
/** Modal handles pressing of the escape key and closes the modal. If you want to handle
|
|
35
|
+
* this yourself you can use this callback function. */
|
|
36
|
+
onEscapePress?: (event: KeyboardEvent) => void;
|
|
37
|
+
/** Position of the modal. By default a modal will be positioned vertically and horizontally centered. */
|
|
38
|
+
position?: 'default' | 'top';
|
|
39
|
+
/** Offset from alternate position. Can be any valid CSS length/percentage. */
|
|
40
|
+
positionOffset?: string;
|
|
41
|
+
/** Variant of the modal. */
|
|
42
|
+
variant?: 'small' | 'medium' | 'large' | 'default';
|
|
43
|
+
/** Default width of the modal. */
|
|
44
|
+
width?: number | string;
|
|
45
|
+
/** Maximum width of the modal. */
|
|
46
|
+
maxWidth?: number | string;
|
|
47
|
+
/** Value to overwrite the randomly generated data-ouia-component-id.*/
|
|
48
|
+
ouiaId?: number | string;
|
|
49
|
+
/** Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. */
|
|
50
|
+
ouiaSafe?: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export enum ModalVariant {
|
|
54
|
+
small = 'small',
|
|
55
|
+
medium = 'medium',
|
|
56
|
+
large = 'large',
|
|
57
|
+
default = 'default'
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface ModalState {
|
|
61
|
+
container: HTMLElement;
|
|
62
|
+
ouiaStateId: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
class Modal extends React.Component<ModalProps, ModalState> {
|
|
66
|
+
static displayName = 'Modal';
|
|
67
|
+
static currentId = 0;
|
|
68
|
+
boxId = '';
|
|
69
|
+
|
|
70
|
+
static defaultProps: PickOptional<ModalProps> = {
|
|
71
|
+
isOpen: false,
|
|
72
|
+
variant: 'default',
|
|
73
|
+
appendTo: () => document.body,
|
|
74
|
+
ouiaSafe: true,
|
|
75
|
+
position: 'default'
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
constructor(props: ModalProps) {
|
|
79
|
+
super(props);
|
|
80
|
+
const boxIdNum = Modal.currentId++;
|
|
81
|
+
this.boxId = props.id || `pf-modal-part-${boxIdNum}`;
|
|
82
|
+
|
|
83
|
+
this.state = {
|
|
84
|
+
container: undefined,
|
|
85
|
+
ouiaStateId: getDefaultOUIAId(Modal.displayName, props.variant)
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
handleEscKeyClick = (event: KeyboardEvent): void => {
|
|
90
|
+
const { onEscapePress } = this.props;
|
|
91
|
+
if (event.key === KeyTypes.Escape && this.props.isOpen) {
|
|
92
|
+
onEscapePress ? onEscapePress(event) : this.props.onClose?.(event);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
getElement = (appendTo: HTMLElement | (() => HTMLElement)) => {
|
|
97
|
+
if (typeof appendTo === 'function') {
|
|
98
|
+
return appendTo();
|
|
99
|
+
}
|
|
100
|
+
return appendTo || document.body;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
toggleSiblingsFromScreenReaders = (hide: boolean) => {
|
|
104
|
+
const { appendTo } = this.props;
|
|
105
|
+
const target: HTMLElement = this.getElement(appendTo);
|
|
106
|
+
const bodyChildren = target.children;
|
|
107
|
+
for (const child of Array.from(bodyChildren)) {
|
|
108
|
+
if (child !== this.state.container) {
|
|
109
|
+
hide ? child.setAttribute('aria-hidden', '' + hide) : child.removeAttribute('aria-hidden');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
isEmpty = (value: string | null | undefined) => value === null || value === undefined || value === '';
|
|
115
|
+
|
|
116
|
+
componentDidMount() {
|
|
117
|
+
const {
|
|
118
|
+
appendTo,
|
|
119
|
+
'aria-describedby': ariaDescribedby,
|
|
120
|
+
'aria-label': ariaLabel,
|
|
121
|
+
'aria-labelledby': ariaLabelledby
|
|
122
|
+
} = this.props;
|
|
123
|
+
const target: HTMLElement = this.getElement(appendTo);
|
|
124
|
+
const container = document.createElement('div');
|
|
125
|
+
this.setState({ container });
|
|
126
|
+
target.appendChild(container);
|
|
127
|
+
target.addEventListener('keydown', this.handleEscKeyClick, false);
|
|
128
|
+
|
|
129
|
+
if (this.props.isOpen) {
|
|
130
|
+
target.classList.add(css(styles.backdropOpen));
|
|
131
|
+
} else {
|
|
132
|
+
target.classList.remove(css(styles.backdropOpen));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (!ariaDescribedby && !ariaLabel && !ariaLabelledby) {
|
|
136
|
+
// eslint-disable-next-line no-console
|
|
137
|
+
console.error('Modal: Specify at least one of: aria-describedby, aria-label, aria-labelledby.');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
componentDidUpdate() {
|
|
142
|
+
const { appendTo } = this.props;
|
|
143
|
+
const target: HTMLElement = this.getElement(appendTo);
|
|
144
|
+
if (this.props.isOpen) {
|
|
145
|
+
target.classList.add(css(styles.backdropOpen));
|
|
146
|
+
this.toggleSiblingsFromScreenReaders(true);
|
|
147
|
+
} else {
|
|
148
|
+
target.classList.remove(css(styles.backdropOpen));
|
|
149
|
+
this.toggleSiblingsFromScreenReaders(false);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
componentWillUnmount() {
|
|
154
|
+
const { appendTo } = this.props;
|
|
155
|
+
const target: HTMLElement = this.getElement(appendTo);
|
|
156
|
+
if (this.state.container) {
|
|
157
|
+
target.removeChild(this.state.container);
|
|
158
|
+
}
|
|
159
|
+
target.removeEventListener('keydown', this.handleEscKeyClick, false);
|
|
160
|
+
target.classList.remove(css(styles.backdropOpen));
|
|
161
|
+
this.toggleSiblingsFromScreenReaders(false);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
render() {
|
|
165
|
+
const {
|
|
166
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
167
|
+
appendTo,
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
169
|
+
onEscapePress,
|
|
170
|
+
'aria-labelledby': ariaLabelledby,
|
|
171
|
+
'aria-label': ariaLabel,
|
|
172
|
+
'aria-describedby': ariaDescribedby,
|
|
173
|
+
ouiaId,
|
|
174
|
+
ouiaSafe,
|
|
175
|
+
position,
|
|
176
|
+
elementToFocus,
|
|
177
|
+
...props
|
|
178
|
+
} = this.props;
|
|
179
|
+
const { container } = this.state;
|
|
180
|
+
|
|
181
|
+
if (!canUseDOM || !container) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return ReactDOM.createPortal(
|
|
186
|
+
<ModalContent
|
|
187
|
+
boxId={this.boxId}
|
|
188
|
+
aria-label={ariaLabel}
|
|
189
|
+
aria-describedby={ariaDescribedby}
|
|
190
|
+
aria-labelledby={ariaLabelledby}
|
|
191
|
+
ouiaId={ouiaId !== undefined ? ouiaId : this.state.ouiaStateId}
|
|
192
|
+
ouiaSafe={ouiaSafe}
|
|
193
|
+
position={position}
|
|
194
|
+
elementToFocus={elementToFocus}
|
|
195
|
+
{...props}
|
|
196
|
+
/>,
|
|
197
|
+
container
|
|
198
|
+
) as React.ReactElement;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export { Modal };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { css } from '@patternfly/react-styles';
|
|
3
|
+
import styles from '@patternfly/react-styles/css/components/ModalBox/modal-box';
|
|
4
|
+
|
|
5
|
+
/** Renders content in the body of the modal */
|
|
6
|
+
|
|
7
|
+
export interface ModalBodyProps extends React.HTMLProps<HTMLDivElement> {
|
|
8
|
+
/** Content rendered inside the modal body. */
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
/** Additional classes added to the modal body. */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Accessible label applied to the modal body. This should be used to communicate
|
|
13
|
+
* important information about the modal body div element if needed, such as when it is scrollable.
|
|
14
|
+
*/
|
|
15
|
+
'aria-label'?: string;
|
|
16
|
+
/** Accessible role applied to the modal body. This will default to "region" if the
|
|
17
|
+
* aria-label property is passed in. Set to a more appropriate role as applicable
|
|
18
|
+
* based on the modal content and context.
|
|
19
|
+
*/
|
|
20
|
+
role?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const ModalBody: React.FunctionComponent<ModalBodyProps> = ({
|
|
24
|
+
children,
|
|
25
|
+
className,
|
|
26
|
+
'aria-label': ariaLabel,
|
|
27
|
+
role,
|
|
28
|
+
...props
|
|
29
|
+
}: ModalBodyProps) => {
|
|
30
|
+
const defaultModalBodyRole = ariaLabel ? 'region' : undefined;
|
|
31
|
+
return (
|
|
32
|
+
<div
|
|
33
|
+
aria-label={ariaLabel}
|
|
34
|
+
role={role || defaultModalBodyRole}
|
|
35
|
+
className={css(styles.modalBoxBody, className)}
|
|
36
|
+
{...props}
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
ModalBody.displayName = 'ModalBody';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { css } from '@patternfly/react-styles';
|
|
3
|
+
import styles from '@patternfly/react-styles/css/components/ModalBox/modal-box';
|
|
4
|
+
import topSpacer from '@patternfly/react-tokens/dist/esm/c_modal_box_m_align_top_spacer';
|
|
5
|
+
|
|
6
|
+
export interface ModalBoxProps extends React.HTMLProps<HTMLDivElement> {
|
|
7
|
+
/** Id to use for the modal box description. This should match the ModalHeader labelId or descriptorId */
|
|
8
|
+
'aria-describedby'?: string;
|
|
9
|
+
/** Adds an accessible name to the modal when there is no title in the ModalHeader. */
|
|
10
|
+
'aria-label'?: string;
|
|
11
|
+
/** Id to use for the modal box label. */
|
|
12
|
+
'aria-labelledby'?: string;
|
|
13
|
+
/** Content rendered inside the modal box. */
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
/** Additional classes added to the modal box. */
|
|
16
|
+
className?: string;
|
|
17
|
+
/** Position of the modal. By default a modal will be positioned vertically and horizontally centered. */
|
|
18
|
+
position?: 'default' | 'top';
|
|
19
|
+
/** Offset from alternate position. Can be any valid CSS length/percentage. */
|
|
20
|
+
positionOffset?: string;
|
|
21
|
+
/** Variant of the modal. */
|
|
22
|
+
variant?: 'small' | 'medium' | 'large' | 'default';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const ModalBox: React.FunctionComponent<ModalBoxProps> = ({
|
|
26
|
+
children,
|
|
27
|
+
className,
|
|
28
|
+
variant = 'default',
|
|
29
|
+
position,
|
|
30
|
+
positionOffset,
|
|
31
|
+
'aria-labelledby': ariaLabelledby,
|
|
32
|
+
'aria-label': ariaLabel,
|
|
33
|
+
'aria-describedby': ariaDescribedby,
|
|
34
|
+
style,
|
|
35
|
+
...props
|
|
36
|
+
}: ModalBoxProps) => {
|
|
37
|
+
if (positionOffset) {
|
|
38
|
+
style = style || {};
|
|
39
|
+
(style as any)[topSpacer.name] = positionOffset;
|
|
40
|
+
}
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
role="dialog"
|
|
44
|
+
aria-label={ariaLabel || null}
|
|
45
|
+
aria-labelledby={ariaLabelledby || null}
|
|
46
|
+
aria-describedby={ariaDescribedby}
|
|
47
|
+
aria-modal="true"
|
|
48
|
+
className={css(
|
|
49
|
+
styles.modalBox,
|
|
50
|
+
className,
|
|
51
|
+
position === 'top' && styles.modifiers.alignTop,
|
|
52
|
+
variant === 'large' && styles.modifiers.lg,
|
|
53
|
+
variant === 'small' && styles.modifiers.sm,
|
|
54
|
+
variant === 'medium' && styles.modifiers.md
|
|
55
|
+
)}
|
|
56
|
+
style={style}
|
|
57
|
+
{...props}
|
|
58
|
+
>
|
|
59
|
+
{children}
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
ModalBox.displayName = 'ModalBox';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { css } from '@patternfly/react-styles';
|
|
3
|
+
import styles from '@patternfly/react-styles/css/components/ModalBox/modal-box';
|
|
4
|
+
import { Button } from '../../../components/Button';
|
|
5
|
+
import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
|
|
6
|
+
import { OUIAProps } from '../../../helpers';
|
|
7
|
+
|
|
8
|
+
export interface ModalBoxCloseButtonProps extends OUIAProps {
|
|
9
|
+
/** Additional classes added to the close button. */
|
|
10
|
+
className?: string;
|
|
11
|
+
/** A callback for when the close button is clicked. */
|
|
12
|
+
onClose?: (event: KeyboardEvent | React.MouseEvent) => void;
|
|
13
|
+
/** Accessible descriptor of the close button. */
|
|
14
|
+
'aria-label'?: string;
|
|
15
|
+
/** Value to set the data-ouia-component-id.*/
|
|
16
|
+
ouiaId?: number | string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const ModalBoxCloseButton: React.FunctionComponent<ModalBoxCloseButtonProps> = ({
|
|
20
|
+
className,
|
|
21
|
+
onClose,
|
|
22
|
+
'aria-label': ariaLabel = 'Close',
|
|
23
|
+
ouiaId,
|
|
24
|
+
...props
|
|
25
|
+
}: ModalBoxCloseButtonProps) => (
|
|
26
|
+
<div className={css(styles.modalBoxClose, className)}>
|
|
27
|
+
<Button
|
|
28
|
+
variant="plain"
|
|
29
|
+
onClick={(event) => onClose(event)}
|
|
30
|
+
aria-label={ariaLabel}
|
|
31
|
+
{...(ouiaId && { ouiaId: `${ouiaId}-${ModalBoxCloseButton.displayName}` })}
|
|
32
|
+
{...props}
|
|
33
|
+
>
|
|
34
|
+
<TimesIcon />
|
|
35
|
+
</Button>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
ModalBoxCloseButton.displayName = 'ModalBoxCloseButton';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { css } from '@patternfly/react-styles';
|
|
3
|
+
import styles from '@patternfly/react-styles/css/components/ModalBox/modal-box';
|
|
4
|
+
|
|
5
|
+
export interface ModalBoxDescriptionProps {
|
|
6
|
+
/** Content rendered inside the description. */
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** Additional classes added to the description. */
|
|
9
|
+
className?: string;
|
|
10
|
+
/** Id of the description. */
|
|
11
|
+
id?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const ModalBoxDescription: React.FunctionComponent<ModalBoxDescriptionProps> = ({
|
|
15
|
+
children = null,
|
|
16
|
+
className = '',
|
|
17
|
+
id = '',
|
|
18
|
+
...props
|
|
19
|
+
}: ModalBoxDescriptionProps) => (
|
|
20
|
+
<div {...props} id={id} className={css(styles.modalBoxDescription, className)}>
|
|
21
|
+
{children}
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
ModalBoxDescription.displayName = 'ModalBoxDescription';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import modalStyles from '@patternfly/react-styles/css/components/ModalBox/modal-box';
|
|
3
|
+
import { css } from '@patternfly/react-styles';
|
|
4
|
+
import { capitalize } from '../../../helpers';
|
|
5
|
+
import { Tooltip } from '../../../components/Tooltip';
|
|
6
|
+
import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
|
|
7
|
+
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
|
|
8
|
+
import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';
|
|
9
|
+
import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
|
|
10
|
+
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
11
|
+
import { useIsomorphicLayoutEffect } from '../../../helpers';
|
|
12
|
+
|
|
13
|
+
export const isVariantIcon = (icon: any): icon is string =>
|
|
14
|
+
['success', 'danger', 'warning', 'info', 'custom'].includes(icon as string);
|
|
15
|
+
|
|
16
|
+
export interface ModalBoxTitleProps {
|
|
17
|
+
/** Additional classes added to the modal box title. */
|
|
18
|
+
className?: string;
|
|
19
|
+
/** Id of the modal box title. */
|
|
20
|
+
id?: string;
|
|
21
|
+
/** Content rendered inside the modal box title. */
|
|
22
|
+
title: React.ReactNode;
|
|
23
|
+
/** Optional alert icon (or other) to show before the title. When the predefined alert types
|
|
24
|
+
* are used the default styling will be automatically applied. */
|
|
25
|
+
titleIconVariant?: 'success' | 'danger' | 'warning' | 'info' | 'custom' | React.ComponentType<any>;
|
|
26
|
+
/** Optional title label text for screen readers. */
|
|
27
|
+
titleScreenReaderText?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const ModalBoxTitle: React.FunctionComponent<ModalBoxTitleProps> = ({
|
|
31
|
+
className,
|
|
32
|
+
id,
|
|
33
|
+
title,
|
|
34
|
+
titleIconVariant,
|
|
35
|
+
titleScreenReaderText,
|
|
36
|
+
...props
|
|
37
|
+
}: ModalBoxTitleProps) => {
|
|
38
|
+
const [hasTooltip, setHasTooltip] = React.useState(false);
|
|
39
|
+
const h1 = React.useRef<HTMLHeadingElement>(null);
|
|
40
|
+
const label =
|
|
41
|
+
titleScreenReaderText ||
|
|
42
|
+
(isVariantIcon(titleIconVariant) ? `${capitalize(titleIconVariant)} alert:` : titleScreenReaderText);
|
|
43
|
+
const variantIcons = {
|
|
44
|
+
success: <CheckCircleIcon />,
|
|
45
|
+
danger: <ExclamationCircleIcon />,
|
|
46
|
+
warning: <ExclamationTriangleIcon />,
|
|
47
|
+
info: <InfoCircleIcon />,
|
|
48
|
+
custom: <BellIcon />
|
|
49
|
+
};
|
|
50
|
+
const CustomIcon = !isVariantIcon(titleIconVariant) && titleIconVariant;
|
|
51
|
+
|
|
52
|
+
useIsomorphicLayoutEffect(() => {
|
|
53
|
+
setHasTooltip(h1.current && h1.current.offsetWidth < h1.current.scrollWidth);
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
56
|
+
const content = (
|
|
57
|
+
<h1
|
|
58
|
+
id={id}
|
|
59
|
+
ref={h1}
|
|
60
|
+
className={css(modalStyles.modalBoxTitle, titleIconVariant && modalStyles.modifiers.icon, className)}
|
|
61
|
+
{...props}
|
|
62
|
+
>
|
|
63
|
+
{titleIconVariant && (
|
|
64
|
+
<span className={css(modalStyles.modalBoxTitleIcon)}>
|
|
65
|
+
{isVariantIcon(titleIconVariant) ? variantIcons[titleIconVariant] : <CustomIcon />}
|
|
66
|
+
</span>
|
|
67
|
+
)}
|
|
68
|
+
{label && <span className="pf-v5-screen-reader">{label}</span>}
|
|
69
|
+
<span className={css(modalStyles.modalBoxTitleText)}>{title}</span>
|
|
70
|
+
</h1>
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
return hasTooltip ? <Tooltip content={title}>{content}</Tooltip> : content;
|
|
74
|
+
};
|
|
75
|
+
ModalBoxTitle.displayName = 'ModalBoxTitle';
|