├── .nvmrc ├── www ├── docs │ ├── usePopper.mdx │ ├── .prettierrc │ ├── useRootClose.mdx │ ├── Portal.mdx │ ├── useWindow.mdx │ ├── getting-started.md │ ├── Button.mdx │ ├── Modal.mdx │ ├── Overlay.mdx │ ├── Waypoint.mdx │ ├── Nav.mdx │ └── transitions.mdx ├── static │ ├── .nojekyll │ └── refresh-dot.svg ├── postcss.config.js ├── .gitignore ├── tsconfig.json ├── src │ ├── css │ │ ├── transitions.css │ │ └── tailwind.css │ ├── Button.tsx │ ├── Tooltip.tsx │ ├── theme │ │ └── CodeBlock │ │ │ └── index.tsx │ ├── Dropdown.tsx │ ├── LiveCodeBlock.module.css │ ├── LiveCodeblock.tsx │ └── WaypointExample.tsx ├── plugins │ └── webpack.js ├── sidebars.js ├── tailwind.config.js ├── README.md ├── package.json └── docusaurus.config.js ├── codecov.yml ├── .gitattributes ├── renovate.json ├── test ├── setup.ts ├── types.test.tsx ├── tsconfig.json ├── utilsSpec.tsx ├── helpers.ts ├── NavSpec.tsx ├── PortalSpec.tsx ├── DropdownItemSpec.tsx ├── WaitForContainerSpec.tsx ├── AnchorSpec.tsx ├── usePopperSpec.tsx ├── NavItemSpec.tsx ├── ButtonSpec.tsx ├── ModalManagerSpec.ts └── useRootCloseSpec.tsx ├── .babelrc.js ├── src ├── getScrollbarWidth.ts ├── DataKey.tsx ├── SelectableContext.tsx ├── NavContext.tsx ├── useWindow.ts ├── TabContext.tsx ├── useScrollParent.tsx ├── getWindowEvent.ts ├── DropdownContext.ts ├── RTGTransition.tsx ├── utils.ts ├── Portal.tsx ├── NoopTransition.tsx ├── Anchor.tsx ├── popper.ts ├── Waypoint.tsx ├── index.ts ├── useWaitForDOMRef.ts ├── useRootClose.ts ├── mergeOptionsWithPopperConfig.ts ├── tabbable.ts ├── useRTGTransitionProps.ts ├── DropdownToggle.tsx ├── useFocusTrap.tsx ├── DropdownItem.tsx ├── types.ts ├── Tabs.tsx ├── ImperativeTransition.tsx ├── NavItem.tsx ├── Button.tsx ├── ModalManager.ts ├── TabPanel.tsx ├── useWaypoint.tsx ├── useClickOutside.ts ├── Nav.tsx ├── usePopper.ts ├── Overlay.tsx └── DropdownMenu.tsx ├── .github ├── workflows │ ├── deploy-docs.yml │ └── ci.yml └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── tsconfig.json ├── vitest.config.mts ├── .gitignore ├── README.md ├── LICENSE ├── eslint.config.mjs └── package.json /.nvmrc: -------------------------------------------------------------------------------- 1 | 20 -------------------------------------------------------------------------------- /www/docs/usePopper.mdx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /www/static/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: off 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf -------------------------------------------------------------------------------- /www/docs/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 60 3 | } 4 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["github>4Catalyzer/renovate-config:library"] 3 | } 4 | -------------------------------------------------------------------------------- /test/setup.ts: -------------------------------------------------------------------------------- 1 | import { cleanup } from '@testing-library/react'; 2 | import { afterEach } from 'vitest'; 3 | 4 | afterEach(cleanup); 5 | -------------------------------------------------------------------------------- /test/types.test.tsx: -------------------------------------------------------------------------------- 1 | import { Button } from '../src'; 2 | 3 | const _1 = 19 | 20 | {show && ( 21 |
25 | Click anywhere to dismiss me! 26 |
27 | )} 28 | 29 | ); 30 | } 31 | ``` 32 | -------------------------------------------------------------------------------- /www/README.md: -------------------------------------------------------------------------------- 1 | # Website 2 | 3 | This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator. 4 | 5 | ## Installation 6 | 7 | ```console 8 | yarn install 9 | ``` 10 | 11 | ## Local Development 12 | 13 | ```console 14 | yarn start 15 | ``` 16 | 17 | This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server. 18 | 19 | ## Build 20 | 21 | ```console 22 | yarn build 23 | ``` 24 | 25 | This command generates static content into the `build` directory and can be served using any static contents hosting service. 26 | 27 | ## Deployment 28 | 29 | ```console 30 | GIT_USER= USE_SSH=true yarn deploy 31 | ``` 32 | 33 | If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. 34 | -------------------------------------------------------------------------------- /www/src/Tooltip.tsx: -------------------------------------------------------------------------------- 1 | import clsx from 'clsx'; 2 | import React from 'react'; 3 | 4 | const Tooltip = React.forwardRef( 5 | ({ children, arrowProps, popper, show: _, ...props }: any, ref: any) => ( 6 |
7 |
19 |
20 | {children} 21 |
22 |
23 | ), 24 | ); 25 | 26 | export default Tooltip; 27 | -------------------------------------------------------------------------------- /src/Portal.tsx: -------------------------------------------------------------------------------- 1 | import ReactDOM from 'react-dom'; 2 | 3 | import * as React from 'react'; 4 | import useWaitForDOMRef, { type DOMContainer } from './useWaitForDOMRef.js'; 5 | 6 | export interface PortalProps { 7 | children: React.ReactElement; 8 | 9 | /** 10 | * A DOM element, Ref to an element, or function that returns either. The `container` will have the Portal children 11 | * appended to it. 12 | */ 13 | container: DOMContainer; 14 | 15 | /** 16 | * Callback that is triggered when the portal content is rendered. 17 | */ 18 | onRendered?: (element: any) => void; 19 | } 20 | 21 | /** 22 | * @public 23 | */ 24 | const Portal = ({ container, children, onRendered }: PortalProps) => { 25 | const resolvedContainer = useWaitForDOMRef(container, onRendered); 26 | 27 | return resolvedContainer ? ( 28 | <>{ReactDOM.createPortal(children, resolvedContainer)} 29 | ) : null; 30 | }; 31 | 32 | Portal.displayName = 'Portal'; 33 | 34 | export default Portal; 35 | -------------------------------------------------------------------------------- /www/src/theme/CodeBlock/index.tsx: -------------------------------------------------------------------------------- 1 | import { type ReactNode } from 'react'; 2 | import { usePrismTheme } from '@docusaurus/theme-common'; 3 | // @ts-ignore 4 | import CodeBlock from '@theme-original/CodeBlock'; 5 | // @ts-ignore 6 | import type CodeBlockType from '@theme/CodeBlock'; 7 | import type { WrapperProps } from '@docusaurus/types'; 8 | import { LiveCodeblock } from '../../LiveCodeblock'; 9 | 10 | type Props = WrapperProps; 11 | 12 | function getLanguage(className = '') { 13 | const [, mode] = className.match(/language-(\w+)/) || []; 14 | return mode; 15 | } 16 | 17 | export default function CodeBlockWrapper(props: Props): ReactNode { 18 | const prismTheme = usePrismTheme(); 19 | 20 | if (props.live) { 21 | const language = props.language || getLanguage(props.className); 22 | 23 | return ; 24 | } 25 | 26 | return ( 27 | <> 28 | 29 | 30 | ); 31 | } 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | 5 |

Restart UI

6 | 7 | A set of full featured, extensible, and accessible UI components, designed to integrate into any styling 8 | framework or system. Restart components, are "headless", meaning they don't provide any styles. Components encapsulate 9 | the complicated logic and and state without being prescriptive about their look and feel. 10 | 11 | ## Documentation 12 | 13 | https://react-restart.github.io/ui/ 14 | 15 | ## Installation 16 | 17 | ```sh 18 | npm install --save @restart/ui 19 | ``` 20 | 21 | ## Contributing 22 | 23 | Checkout the repo and setup the project: 24 | 25 | 1. Bootstrap your environment `yarn bootstrap` 26 | 2. Start the development server `yarn start` 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | --- 8 | 9 | ## Describe the bug 10 | 11 | A clear and concise description of what the bug is. 12 | 13 | ## To Reproduce 14 | 15 | Steps to reproduce the behavior: 16 | 17 | 1. Go to '...' 18 | 2. Click on '....' 19 | 3. Scroll down to '....' 20 | 4. See error 21 | 22 | ## Reproducible Example 23 | 24 | Minimal example by using [CodeSandbox](https://codesandbox.io/s/github/react-bootstrap/code-sandbox-examples/tree/master/basic). 25 | 26 | ## Expected behavior 27 | 28 | A clear and concise description of what you expected to happen. 29 | 30 | ## Screenshots 31 | 32 | If applicable, add screenshots to help explain your problem. 33 | 34 | ## Environment (please complete the following information) 35 | 36 | - Operating System: [e.g. macOS] 37 | - Browser, Version [e.g. Chrome 74] 38 | - react-overlays Version [e.g. 2.0.0] 39 | 40 | ## Additional context 41 | 42 | Add any other context about the problem here. 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 react-bootstrap 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /src/NoopTransition.tsx: -------------------------------------------------------------------------------- 1 | import useEventCallback from '@restart/hooks/useEventCallback'; 2 | import useMergedRefs from '@restart/hooks/useMergedRefs'; 3 | import { cloneElement, useEffect, useRef } from 'react'; 4 | import type { TransitionProps } from './types.js'; 5 | import { getChildRef } from './utils.js'; 6 | 7 | function NoopTransition({ 8 | children, 9 | in: inProp, 10 | onExited, 11 | mountOnEnter, 12 | unmountOnExit, 13 | }: TransitionProps) { 14 | const ref = useRef(null); 15 | const hasEnteredRef = useRef(inProp); 16 | const handleExited = useEventCallback(onExited); 17 | 18 | useEffect(() => { 19 | if (inProp) hasEnteredRef.current = true; 20 | else { 21 | handleExited(ref.current!); 22 | } 23 | }, [inProp, handleExited]); 24 | 25 | const combinedRef = useMergedRefs(ref, getChildRef(children)); 26 | 27 | const child = cloneElement(children, { ref: combinedRef }); 28 | 29 | if (inProp) return child; 30 | 31 | if (unmountOnExit) { 32 | return null; 33 | } 34 | if (!hasEnteredRef.current && mountOnEnter) { 35 | return null; 36 | } 37 | 38 | return child; 39 | } 40 | 41 | export default NoopTransition; 42 | -------------------------------------------------------------------------------- /test/NavSpec.tsx: -------------------------------------------------------------------------------- 1 | import { fireEvent, render, screen } from '@testing-library/react'; 2 | import { expect, describe, beforeEach, afterEach, it } from 'vitest'; 3 | import Tabs from '../src/Tabs'; 4 | import Nav from '../src/Nav'; 5 | import NavItem from '../src/NavItem'; 6 | 7 | describe('