diff --git a/src/components/ComponentDemo/KnobContainer.js b/src/components/ComponentDemo/KnobContainer.js index b4724f501a4..e8071a7f8d2 100644 --- a/src/components/ComponentDemo/KnobContainer.js +++ b/src/components/ComponentDemo/KnobContainer.js @@ -242,7 +242,7 @@ const KnobContainer = ({ knobs, code, setCode, initialCode, variantId }) => { } knobs[component].forEach((knob) => { - if (fullComponent.props[knob].type) { + if (fullComponent.props[knob]?.type) { requestedProps[knob] = fullComponent.props[knob]; } else { console.error( diff --git a/src/components/ModalStateManager/ModalStateManager.js b/src/components/ModalStateManager/ModalStateManager.js new file mode 100644 index 00000000000..5646e626a5e --- /dev/null +++ b/src/components/ModalStateManager/ModalStateManager.js @@ -0,0 +1,35 @@ +import PropTypes from 'prop-types'; +import React, { useState } from 'react'; +import ReactDOM from 'react-dom'; + +/** + * Simple state manager for modals. + */ +const ModalStateManager = ({ + renderLauncher: LauncherContent, + children: ModalContent, +}) => { + const [open, setOpen] = useState(false); + return ( + <> + {!ModalContent || typeof document === 'undefined' + ? null + : ReactDOM.createPortal( + , + document.body + )} + {LauncherContent && } + + ); +}; + +ModalStateManager.propTypes = { + children: PropTypes.elementType, + + /** + * The component to render the launcher UI. + */ + renderLauncher: PropTypes.elementType, +}; + +export default ModalStateManager; diff --git a/src/components/ModalStateManager/index.js b/src/components/ModalStateManager/index.js new file mode 100644 index 00000000000..812891432d3 --- /dev/null +++ b/src/components/ModalStateManager/index.js @@ -0,0 +1 @@ +export { default } from './ModalStateManager'; diff --git a/src/data/docgen/react-docgen.json b/src/data/docgen/react-docgen.json index d4603ee1159..86b6a488a81 100644 --- a/src/data/docgen/react-docgen.json +++ b/src/data/docgen/react-docgen.json @@ -3,6 +3,18 @@ "description": "", "displayName": "Accordion", "props": { + "align": { + "defaultValue": { "value": "'end'", "computed": false }, + "type": { + "name": "enum", + "value": [ + { "value": "'start'", "computed": false }, + { "value": "'end'", "computed": false } + ] + }, + "required": false, + "description": "Specify the alignment of the accordion heading title and chevron." + }, "children": { "type": { "name": "node" }, "required": false, @@ -162,7 +174,11 @@ "as": { "type": { "name": "union", - "value": [{ "name": "func" }, { "name": "string" }] + "value": [ + { "name": "func" }, + { "name": "string" }, + { "name": "elementType" } + ] }, "required": false, "description": "Specify how the button itself should be rendered.\nMake sure to apply all props to the root node and render children appropriately" @@ -254,6 +270,12 @@ "description": "", "displayName": "Checkbox", "props": { + "title": { + "defaultValue": { "value": "''", "computed": false }, + "type": { "name": "string" }, + "required": false, + "description": "Specify a title for the