Skip to content

Commit 2e13868

Browse files
committed
Merge branch 'main' of github.com:adobe/react-spectrum into style_macro_docs
2 parents 4b38f98 + 860b46c commit 2e13868

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+552
-477
lines changed

packages/@react-spectrum/s2/src/Provider.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ export interface ProviderProps extends UnsafeStyles {
5151

5252
export const ColorSchemeContext = createContext<ColorScheme | 'light dark' | null>(null);
5353

54+
/**
55+
* Provider is the container for all React Spectrum components.
56+
* It loads the font and sets the colorScheme, locale, and other application level settings.
57+
*/
5458
export function Provider(props: ProviderProps): JSX.Element {
5559
let result = <ProviderInner {...props} />;
5660
let parentColorScheme = useContext(ColorSchemeContext);

packages/dev/s2-docs/pages/react-aria/DropTarget.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import React, {JSX} from 'react';
3+
import React, {JSX, ReactNode} from 'react';
44
import type {TextDropItem} from '@react-aria/dnd';
55
import {useDrop} from '@react-aria/dnd';
66

@@ -18,7 +18,7 @@ export function DropTarget() {
1818
let items = await Promise.all(
1919
(e.items as TextDropItem[])
2020
.filter(item => item.kind === 'text' && (item.types.has('text/plain') || item.types.has('my-app-custom-type')))
21-
.map(async item => {
21+
.map(async (item: TextDropItem) => {
2222
if (item.types.has('my-app-custom-type')) {
2323
return JSON.parse(await item.getText('my-app-custom-type'));
2424
} else {
@@ -30,16 +30,16 @@ export function DropTarget() {
3030
}
3131
});
3232

33-
let message: JSX.Element[] = [<div>{`Drop here`}</div>];
33+
let message: ReactNode = <div key="drop here">'Drop here'</div>;
3434
if (dropped) {
3535
message = dropped.map((d, index) => {
36-
let m = d.message;
36+
let m: ReactNode = d.message;
3737
if (d.style === 'bold') {
38-
message = [<strong>{m}</strong>];
38+
m = <strong key={index}>{m}</strong>;
3939
} else if (d.style === 'italic') {
40-
message = [<em>{m}</em>];
40+
m = <em key={index}>{m}</em>;
4141
}
42-
return <div key={index}>{message}</div>;
42+
return <div key={index}>{m}</div>;
4343
});
4444
}
4545

packages/dev/s2-docs/pages/react-aria/FocusRing.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {GroupedPropTable} from '../../src/PropTable';
1313
import {FunctionAPI} from '../../src/FunctionAPI';
1414
import docs from 'docs:@react-aria/focus';
1515

16-
export const section = 'Focus';
16+
export const section = 'Interactions';
1717

1818
# FocusRing
1919

@@ -29,10 +29,6 @@ switching in from a different tab, we show the focus ring.
2929

3030
If CSS classes are not being used for styling, see [useFocusRing](useFocusRing.html) for a hooks version.
3131

32-
## Props
33-
34-
<PropTable links={docs.links} component={docs.exports.FocusRing} />
35-
3632
## Example
3733

3834
This example shows how to use `<FocusRing>` to apply a CSS class when keyboard focus is on a button.
@@ -46,3 +42,7 @@ import './FocusRingExample.css';
4642
<button className="button">Test</button>
4743
</FocusRing>
4844
```
45+
46+
## API
47+
48+
<PropTable links={docs.links} component={docs.exports.FocusRing} />

packages/dev/s2-docs/pages/react-aria/FocusScope.mdx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {GroupedPropTable} from '../../src/PropTable';
1313
import {FunctionAPI} from '../../src/FunctionAPI';
1414
import docs from 'docs:@react-aria/focus';
1515

16-
export const section = 'Focus';
16+
export const section = 'Interactions';
1717

1818
# FocusScope
1919

@@ -34,17 +34,6 @@ in combination with a FocusScope to programmatically move focus within the scope
3434
arrow key navigation could be implemented by handling keyboard events and using a focus manager
3535
to move focus to the next and previous elements.
3636

37-
## Props
38-
39-
<PropTable links={docs.links} component={docs.exports.FocusScope} />
40-
41-
## FocusManager Interface
42-
43-
To get a focus manager, call the <TypeLink links={docs.links} type={docs.exports.useFocusManager} /> hook
44-
from a component within the FocusScope. A focus manager supports the following methods:
45-
46-
<ClassAPI links={docs.links} class={docs.exports.FocusManager} />
47-
4837
## Example
4938

5039
A basic example of a focus scope that contains focus within it is below. Clicking the "Open"
@@ -128,3 +117,16 @@ function ToolbarButton(props) {
128117
<ToolbarButton>Paste</ToolbarButton>
129118
</Toolbar>
130119
```
120+
121+
## API
122+
123+
### Props
124+
125+
<PropTable links={docs.links} component={docs.exports.FocusScope} />
126+
127+
### FocusManager Interface
128+
129+
To get a focus manager, call the <TypeLink links={docs.links} type={docs.exports.useFocusManager} /> hook
130+
from a component within the FocusScope. A focus manager supports the following methods:
131+
132+
<ClassAPI links={docs.links} class={docs.exports.FocusManager} />

packages/dev/s2-docs/pages/react-aria/I18nProvider.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default Layout;
1212
import {FunctionAPI} from '../../src/FunctionAPI';
1313
import docs from 'docs:@react-aria/i18n';
1414

15-
export const section = 'Internationalization';
15+
export const section = 'Utilities';
1616
export const description = 'Implementing collections in React Aria';
1717

1818

@@ -25,10 +25,6 @@ with a locale defined by your application (e.g. application setting). This shoul
2525
your entire application in the provider, which will be cause all child elements to receive the new locale
2626
information via [useLocale](useLocale.html).
2727

28-
## Props
29-
30-
<PropTable component={docs.exports.I18nProvider} links={docs.links} />
31-
3228
## Example
3329

3430
```tsx
@@ -38,3 +34,7 @@ import {I18nProvider} from '@react-aria/i18n';
3834
<YourApp />
3935
</I18nProvider>
4036
```
37+
38+
## Props
39+
40+
<PropTable component={docs.exports.I18nProvider} links={docs.links} />

packages/dev/s2-docs/pages/react-aria/PortalProvider.mdx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default Layout;
1212
import docs from 'docs:@react-aria/overlays';
1313
import {FunctionAPI} from '../../src/FunctionAPI';
1414

15-
export const section = 'Server Side Rendering';
15+
export const section = 'Utilities';
1616

1717
# PortalProvider
1818

@@ -32,10 +32,6 @@ outside of any possible overflow or stacking contexts. We envision `UNSAFE_Porta
3232
elements into a single container at the root of the app or to control the order of children of the `body` element, but you may have use cases
3333
that need to do otherwise.
3434

35-
## Props
36-
37-
<PropTable links={docs.links} component={docs.exports.UNSAFE_PortalProvider} />
38-
3935
## Example
4036

4137
The example below shows how you can use `UNSAFE_PortalProvider` to portal your Toasts to an arbitrary container. Note that
@@ -169,3 +165,8 @@ function MyOverlay(props) {
169165
return ReactDOM.createPortal(children, getContainer());
170166
}
171167
```
168+
169+
## Props
170+
171+
<PropTable links={docs.links} component={docs.exports.UNSAFE_PortalProvider} />
172+

packages/dev/s2-docs/pages/react-aria/SSRProvider.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {Layout} from '../../src/Layout';
1111
export default Layout;
1212
import docs from 'docs:@react-aria/ssr';
1313

14-
export const section = 'Server Side Rendering';
14+
export const section = 'Utilities';
1515
export const description = 'Implementing collections in React Aria';
1616

1717
# SSRProvider
@@ -26,10 +26,6 @@ See the [server side rendering](ssr.html) docs for more information.
2626
**Note**: if you're using React 18 or newer, `SSRProvider` is not necessary and can be removed from your app. React Aria uses the
2727
[React.useId](https://react.dev/reference/react/useId) hook internally when using React 18, which ensures ids are consistent.
2828

29-
## Props
30-
31-
<PropTable component={docs.exports.SSRProvider} links={docs.links} />
32-
3329
## Example
3430

3531
```tsx
@@ -39,3 +35,7 @@ import {SSRProvider} from '@react-aria/ssr';
3935
<YourApp />
4036
</SSRProvider>
4137
```
38+
39+
## Props
40+
41+
<PropTable component={docs.exports.SSRProvider} links={docs.links} />

packages/dev/s2-docs/pages/react-aria/VisuallyHidden.mdx

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,29 @@ export const section = 'Utilities';
1818

1919
<PageDescription>{docs.exports.VisuallyHidden.description}</PageDescription>
2020

21-
## Introduction
22-
23-
`VisuallyHidden` is a utility component that can be used to hide its children visually,
24-
while keeping them visible to screen readers and other assistive technology. This would
25-
typically be used when you want to take advantage of the behavior and semantics of a
26-
native element like a checkbox or radio button, but replace it with a custom styled
27-
element visually.
28-
29-
## Props
30-
31-
<PropTable links={docs.links} component={docs.exports.VisuallyHidden} />
21+
## Gotchas
3222

33-
{/* not implemented yet */}
34-
{/* ## Example
23+
VisuallyHidden is positioned absolutely, so it needs a positioned ancestor. Otherwise, it will be positioned relative to the nearest positioned ancestor, which may be the body, causing undesired scroll bars to appear.
3524

36-
See [useRadioGroup](useRadioGroup.html#styling) and [useCheckbox](useCheckbox.html#styling)
37-
for examples of using `VisuallyHidden` to hide native form elements visually. */}
25+
```tsx
26+
<label style={{position: 'relative'}}>
27+
<VisuallyHidden>
28+
<input type="checkbox" />
29+
</VisuallyHidden>
30+
<span>Subscribe to our newsletter</span>
31+
</label>
32+
```
3833

39-
## Hook
34+
## Hook
4035

4136
In order to allow additional rendering flexibility, the `useVisuallyHidden` hook can be
4237
used in custom components instead of the `VisuallyHidden` component. It supports the same
4338
options as the component, and returns props to spread onto the element that should be hidden.
4439

4540
<FunctionAPI links={docs.links} function={docs.exports.useVisuallyHidden} />
4641

42+
### Example
43+
4744
```tsx
4845
import {useVisuallyHidden} from '@react-aria/visually-hidden';
4946

@@ -52,16 +49,12 @@ let {visuallyHiddenProps} = useVisuallyHidden();
5249
<div {...visuallyHiddenProps}>I am hidden</div>
5350
```
5451

55-
## Gotchas
52+
## API
5653

57-
VisuallyHidden is positioned absolutely, so it needs a positioned ancestor. Otherwise, it will be positioned relative to the nearest positioned ancestor, which may be the body, causing undesired scroll bars to appear.
54+
<PropTable links={docs.links} component={docs.exports.VisuallyHidden} />
5855

59-
```tsx
60-
<label style={{position: 'relative'}}>
61-
<VisuallyHidden>
62-
<input type="checkbox" />
63-
</VisuallyHidden>
64-
<span>Subscribe to our newsletter</span>
65-
</label>
66-
```
56+
{/* not implemented yet */}
57+
{/* ## Example
6758
59+
See [useRadioGroup](useRadioGroup.html#styling) and [useCheckbox](useCheckbox.html#styling)
60+
for examples of using `VisuallyHidden` to hide native form elements visually. */}

packages/dev/s2-docs/pages/react-aria/mergeProps.mdx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,11 @@ export const section = 'Utilities';
1818

1919
<PageDescription>{docs.exports.mergeProps.description}</PageDescription>
2020

21-
## API
22-
23-
<FunctionAPI function={docs.exports.mergeProps} links={docs.links} />
24-
2521
## Introduction
2622

2723
`mergeProps` is a utility function that combines multiple props objects together in a smart way.
2824
This can be useful when you need to combine the results of multiple react-aria hooks onto a single
29-
element. For example, both hooks may return the same event handlers, class names, or ids, and only
30-
one of these can be applied. `mergeProps` handles combining these props together so that multiple
25+
element. `mergeProps` handles combining these props together so that multiple
3126
event handlers will be chained, multiple classes will be combined, and ids will be deduplicated.
3227
For all other props, the last prop object overrides all previous ones.
3328

@@ -68,3 +63,7 @@ let merged = {
6863
}
6964
};
7065
```
66+
67+
## API
68+
69+
<FunctionAPI function={docs.exports.mergeProps} links={docs.links} />

packages/dev/s2-docs/pages/react-aria/releases/v1-0-0.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default Layout;
1313
import docs from 'docs:@react-spectrum/s2';
1414
import {Time} from '../../../src/ReleasesList';
1515

16-
export const section = '';
16+
export const section = 'Releases';
1717
export const tags = ['release', 'React Aria'];
1818
export const date = 'December 20, 2023';
1919
export const title = 'v1.0.0';

0 commit comments

Comments
 (0)