diff --git a/package.json b/package.json index d6a22d33b56..03cdedf9ff6 100644 --- a/package.json +++ b/package.json @@ -159,6 +159,7 @@ "react-axe": "^3.0.2", "react-dom": "^18.0.0", "react-test-renderer": "^16.9.0", + "recast": "^0.20", "recursive-readdir": "^2.2.2", "regenerator-runtime": "0.13.3", "rimraf": "^2.6.3", diff --git a/packages/dev/docs/pages/react-aria/getting-started.mdx b/packages/dev/docs/pages/react-aria/getting-started.mdx index a445aad537c..34c0f736744 100644 --- a/packages/dev/docs/pages/react-aria/getting-started.mdx +++ b/packages/dev/docs/pages/react-aria/getting-started.mdx @@ -28,18 +28,32 @@ screen readers. ## Installation -React Aria is **incrementally adoptable**. Each component is published as a separate package, so you can try it -out in a single component and gradually add more over time. All of these packages are published under the -[@react-aria](https://www.npmjs.com/org/react-aria) scope on npm. - -You can install any React Aria package using a package manager like [npm](https://docs.npmjs.com/cli/npm) or +React Aria can be installed using a package manager like [npm](https://docs.npmjs.com/cli/npm) or [yarn](https://classic.yarnpkg.com/lang/en/). +``` +yarn add react-aria +``` + +If you prefer, you can also use our hooks from individually versioned packages. This allows you to only +install the hooks you use, or more granularly manage their versions. The individual packages are published +under the [@react-aria](https://www.npmjs.com/org/react-aria) scope on npm. For example: + ``` yarn add @react-aria/button ``` -We also offer a single package containing all React Aria hooks. See [below](#mono-package) for details. +Once installed, hooks can be used from the monopackage or individual packages the same way. + +```tsx +// Monopackage +import {useButton} from 'react-aria'; +``` + +```tsx keepIndividualImports +// Individual packages +import {useButton} from '@react-aria/button'; +``` ## Building a component @@ -123,31 +137,6 @@ function Checkbox(props) { See the [useCheckbox](useCheckbox.html) docs for a full example of a custom styled checkbox. -## Mono-package - -In addition to individual packages, we also offer a mono-package containing all of the React Aria hooks in a single -package. This ensures that all packages use compatible versions and are upgraded together. If you release all components -in your component library in a single package, or just want to get started easily without installing a lot of packages, -the mono-package may be the way to go. It is available as the [react-aria](https://npmjs.com/package/react-aria) package -on npm. - -``` -yarn add react-aria -``` - -Once installed, all hooks work the same way as the individual packages, but are imported from the `react-aria` package -instead of individual packages. - -```tsx -// Individual packages -import {useButton} from '@react-aria/button'; -``` - -```tsx -// Monopackage -import {useButton} from 'react-aria'; -``` - ## Next steps Now that you understand how to use the hooks in React Aria to build your own components, you can read the documentation diff --git a/packages/dev/docs/pages/react-stately/getting-started.mdx b/packages/dev/docs/pages/react-stately/getting-started.mdx index e109a28d1b6..664cbbaf8da 100644 --- a/packages/dev/docs/pages/react-stately/getting-started.mdx +++ b/packages/dev/docs/pages/react-stately/getting-started.mdx @@ -31,18 +31,32 @@ and user interactions for many components, while React Stately provides state ma ## Installation -React Stately is **incrementally adoptable**. Each component is published as a separate package, so you can try it -out in a single component and gradually add more over time. All of these packages are published under the -[@react-stately](https://www.npmjs.com/org/react-stately) scope on npm. - -You can install any React Stately package using a package manager like [npm](https://docs.npmjs.com/cli/npm) or +React Stately can be installed using a package manager like [npm](https://docs.npmjs.com/cli/npm) or [yarn](https://classic.yarnpkg.com/lang/en/). +``` +yarn add react-stately +``` + +If you prefer, you can also use our hooks from individually versioned packages. This allows you to only +install the hooks you use, or more granularly manage their versions. The individual packages are published +under the [@react-stately](https://www.npmjs.com/org/react-stately) scope on npm. For example: + ``` yarn add @react-stately/radio ``` -We also offer a single package containing all React Stately hooks. See [below](#mono-package) for details. +Once installed, hooks can be used from the monopackage or individual packages the same way. + +```tsx +// Monopackage +import {useRadioGroupState} from 'react-stately'; +``` + +```tsx keepIndividualImports +// Individual packages +import {useRadioGroupState} from '@react-stately/radio'; +``` ## Building a component @@ -88,31 +102,6 @@ If you're using React Stately on the web, see [useRadioGroup](../react-aria/useR handle more of this behavior and accessibility for you. To see an example of how React Stately manages more complex state, see [useSelectState](useSelectState.html). -## Mono-package - -In addition to individual packages, we also offer a mono-package containing all of the React Stately hooks in a single -package. This ensures that all packages use compatible versions and are upgraded together. If you release all components -in your component library in a single package, or just want to get started easily without installing a lot of packages, -the mono-package may be the way to go. It is available as the [react-stately](https://npmjs.com/package/react-stately) package -on npm. - -``` -yarn add react-stately -``` - -Once installed, all hooks work the same way as the individual packages, but are imported from the `react-stately` package -instead of individual packages. - -```tsx -// Individual packages -import {useRadioGroupState} from '@react-stately/radio'; -``` - -```tsx -// Monopackage -import {useRadioGroupState} from 'react-stately'; -``` - ## Next steps Now that you understand how to use the hooks in React Stately to build your own components, you can read the documentation diff --git a/packages/dev/docs/src/HeaderInfo.js b/packages/dev/docs/src/HeaderInfo.js index 2ced37fdaec..a7643d777af 100644 --- a/packages/dev/docs/src/HeaderInfo.js +++ b/packages/dev/docs/src/HeaderInfo.js @@ -10,16 +10,34 @@ * governing permissions and limitations under the License. */ +import ariaMonopackage from 'react-aria/package.json'; import {Flex} from '@react-spectrum/layout'; import js from 'highlight.js/lib/languages/javascript'; import Lowlight from 'react-lowlight'; import React from 'react'; import {ResourceCard} from './ResourceCard'; +import rspMonopackage from '@adobe/react-spectrum/package.json'; +import statelyMonopackage from 'react-stately/package.json'; import styles from './headerInfo.css'; import typographyStyles from '@adobe/spectrum-css-temp/components/typography/vars.css'; Lowlight.registerLanguage('js', js); +const monopackages = { + '@react-spectrum': { + importName: '@adobe/react-spectrum', + version: rspMonopackage.version + }, + '@react-aria': { + importName: 'react-aria', + version: ariaMonopackage.version + }, + '@react-stately': { + importName: 'react-stately', + version: statelyMonopackage.version + } +}; + export function HeaderInfo(props) { let { packageData, @@ -29,8 +47,12 @@ export function HeaderInfo(props) { let preRelease = packageData.version.match(/(alpha)|(beta)|(rc)/); let importName = packageData.name; - if (importName.startsWith('@react-spectrum') && process.env.DOCS_ENV === 'production' && !preRelease) { - importName = '@adobe/react-spectrum'; + let version = packageData.version; + if (!preRelease) { + let scope = importName.split('/')[0]; + if (monopackages[scope]) { + ({importName, version} = monopackages[scope]); + } } return ( @@ -43,7 +65,7 @@ export function HeaderInfo(props) {