Skip to content

Commit 308c63b

Browse files
authored
Merge branch 'main' into november24-v3-release-notes
2 parents 0f75d19 + 5107e17 commit 308c63b

28 files changed

+108
-75
lines changed

packages/@react-aria/focus/src/FocusScope.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,6 @@ function useRestoreFocus(scopeRef: RefObject<Element[] | null>, restoreFocus?: b
692692
restoreFocus
693693
&& nodeToRestore
694694
&& (
695-
// eslint-disable-next-line react-hooks/exhaustive-deps
696695
((ownerDocument.activeElement && isElementInChildScope(ownerDocument.activeElement, scopeRef)) || (ownerDocument.activeElement === ownerDocument.body && shouldRestoreFocus(scopeRef)))
697696
)
698697
) {

packages/@react-spectrum/accordion/docs/Accordion.mdx

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import {Accordion, Disclosure, DisclosureTitle, DisclosurePanel} from '@react-sp
2929

3030
<HeaderInfo
3131
packageData={packageData}
32-
componentNames={['Accordion', 'Disclosure', 'DisclosureTitle', 'DisclosurePanel']} />
32+
componentNames={['Accordion', 'Disclosure', 'DisclosureTitle', 'DisclosurePanel']}
33+
since="3.38.0" />
3334

3435
## Example
3536

@@ -67,7 +68,7 @@ import {Key} from "@react-types/shared";
6768

6869
function ControlledExpansion() {
6970
let [expandedKeys, setExpandedKeys] = React.useState<Set<Key>>(new Set(['personal']))
70-
71+
7172
return (
7273
<>
7374
<Accordion expandedKeys={expandedKeys} onExpandedChange={setExpandedKeys}>

packages/@react-spectrum/accordion/docs/Disclosure.mdx

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import {Disclosure, DisclosureTitle, DisclosurePanel} from '@react-spectrum/acco
2929

3030
<HeaderInfo
3131
packageData={packageData}
32-
componentNames={['Disclosure', 'DisclosureTitle', 'DisclosurePanel']} />
32+
componentNames={['Disclosure', 'DisclosureTitle', 'DisclosurePanel']}
33+
since="3.38.0" />
3334

3435
## Example
3536

@@ -44,7 +45,7 @@ import {Disclosure, DisclosureTitle, DisclosurePanel} from '@react-spectrum/acco
4445

4546
## Content
4647

47-
Disclosure follows the [ARIA Disclosure pattern](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/) and consists of two children: `DisclosureTitle` and `DisclosurePanel`. The `DisclosureTitle` controls the expansion of the `DisclosurePanel` and the contents inside.
48+
Disclosure follows the [ARIA Disclosure pattern](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/) and consists of two children: `DisclosureTitle` and `DisclosurePanel`. The `DisclosureTitle` controls the expansion of the `DisclosurePanel` and the contents inside.
4849

4950
Disclosure can be used as a standalone collapsible section of content. However, multiple discosures can be combined to form an [Accordion](Accordion.html).
5051

@@ -59,7 +60,7 @@ Disclosure accepts an `onExpandedChange` prop which is triggered when it is expa
5960
```tsx example
6061
function ControlledExpansion() {
6162
let [isExpanded, setIsExpanded] = React.useState<boolean>(false);
62-
63+
6364
return (
6465
<>
6566
<Disclosure isExpanded={isExpanded} onExpandedChange={setIsExpanded}>

packages/@react-spectrum/color/docs/ColorArea.mdx

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ keywords: [color area]
3737
componentNames={['ColorArea']}
3838
sourceData={[
3939
{type: 'Spectrum', url: 'https://spectrum.adobe.com/page/color-area/'}
40-
]} />
40+
]}
41+
since="3.35.0" />
4142

4243
## Example
4344

packages/@react-spectrum/color/docs/ColorField.mdx

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ keywords: [color field, input]
3333
<HeaderInfo
3434
packageData={packageData}
3535
componentNames={['ColorField']}
36-
sourceData={[]} />
36+
sourceData={[]}
37+
since="3.35.0" />
3738

3839
## Example
3940

@@ -44,7 +45,7 @@ keywords: [color field, input]
4445
## Value
4546

4647
A ColorField's `value` is empty by default, but an initial, uncontrolled, value can be provided using the `defaultValue` prop.
47-
Alternatively, a controlled value can be provided using the `value` prop. The value provided to either of these props should be a color string or <TypeLink links={colorTypes.links} type={colorTypes.exports.Color} /> object.
48+
Alternatively, a controlled value can be provided using the `value` prop. The value provided to either of these props should be a color string or <TypeLink links={colorTypes.links} type={colorTypes.exports.Color} /> object.
4849

4950
In the example below, the <TypeLink links={statelyDocs.links} type={statelyDocs.exports.parseColor} /> function is used to parse the initial color
5051
from a hex value, stored in state.

packages/@react-spectrum/color/docs/ColorPicker.mdx

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ keywords: [color picker]
3232

3333
<HeaderInfo
3434
packageData={packageData}
35-
componentNames={['ColorPicker', 'ColorEditor']} />
35+
componentNames={['ColorPicker', 'ColorEditor']}
36+
since="3.35.0" />
3637

3738
## Example
3839

@@ -142,7 +143,7 @@ import {ColorWheel, ColorArea} from '@react-spectrum/color';
142143

143144
<ColorPicker label="Fill" defaultValue="#08f">
144145
<ColorWheel />
145-
<ColorArea
146+
<ColorArea
146147
colorSpace="hsb"
147148
xChannel="saturation"
148149
yChannel="brightness"

packages/@react-spectrum/color/docs/ColorSlider.mdx

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ keywords: [color slider]
3535
componentNames={['ColorSlider']}
3636
sourceData={[
3737
{type: 'Spectrum', url: 'https://spectrum.adobe.com/page/color-slider/'}
38-
]} />
38+
]}
39+
since="3.35.0" />
3940

4041
## Example
4142

packages/@react-spectrum/color/docs/ColorSwatch.mdx

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ keywords: [color swatch]
3535
componentNames={['ColorSwatch']}
3636
sourceData={[
3737
{type: 'Spectrum', url: 'https://spectrum.adobe.com/page/swatch/'}
38-
]} />
38+
]}
39+
since="3.35.0" />
3940

4041
## Example
4142

packages/@react-spectrum/color/docs/ColorSwatchPicker.mdx

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ keywords: [color swatch]
3434
componentNames={['ColorSwatchPicker']}
3535
sourceData={[
3636
{type: 'Spectrum', url: 'https://spectrum.adobe.com/page/swatch-group/'}
37-
]} />
37+
]}
38+
since="3.35.0" />
3839

3940
## Example
4041

packages/@react-spectrum/color/docs/ColorWheel.mdx

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ keywords: [color wheel, slider]
3535
componentNames={['ColorWheel']}
3636
sourceData={[
3737
{type: 'Spectrum', url: 'https://spectrum.adobe.com/page/color-wheel/'}
38-
]} />
38+
]}
39+
since="3.35.0" />
3940

4041
## Example
4142

packages/@react-spectrum/color/src/ColorThumb.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
import {classNames} from '@react-spectrum/utils';
1414
import {Color} from '@react-types/color';
15-
import {Context} from '@react-spectrum/provider';
1615
import {DOMProps, RefObject} from '@react-types/shared';
1716
import {Overlay} from '@react-spectrum/overlays';
18-
import React, {CSSProperties, ReactElement, useContext, useRef, useState} from 'react';
17+
import React, {CSSProperties, ReactElement, useRef, useState} from 'react';
1918
import stylesHandle from '@adobe/spectrum-css-temp/components/colorhandle/vars.css';
2019
import stylesLoupe from '@adobe/spectrum-css-temp/components/colorloupe/vars.css';
2120
import {useId, useLayoutEffect} from '@react-aria/utils';
21+
import {useProvider} from '@react-spectrum/provider';
2222

2323
interface ColorThumbProps extends DOMProps {
2424
value: Color,
@@ -36,7 +36,7 @@ function ColorThumb(props: ColorThumbProps) {
3636

3737
let valueCSS = value.toString('css');
3838
let loupeRef = useRef<HTMLElement | null>(null);
39-
let provider = useContext(Context);
39+
let provider = useProvider();
4040

4141
return (
4242
<div className={classNames(stylesHandle, 'spectrum-ColorHandle', {'is-focused': isFocused, 'is-disabled': isDisabled}) + ' ' + className} style={style} {...otherProps}>

packages/@react-spectrum/color/test/ColorArea.test.tsx

+6-10
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212

1313
import {ColorArea} from '../';
1414
import {composeStories} from '@storybook/react';
15-
import {defaultTheme} from '@adobe/react-spectrum';
16-
import {fireEvent, installMouseEvent, installPointerEvent, pointerMap, render} from '@react-spectrum/test-utils-internal';
15+
import {fireEvent, installMouseEvent, installPointerEvent, pointerMap, renderv3 as render} from '@react-spectrum/test-utils-internal';
1716
import {parseColor} from '@react-stately/color';
18-
import {Provider} from '@react-spectrum/provider';
1917
import React from 'react';
2018
import * as stories from '../stories/ColorArea.stories';
2119
import userEvent from '@testing-library/user-event';
@@ -207,13 +205,11 @@ describe('ColorArea', () => {
207205
${'home/end'} | ${{defaultValue: parseColor('#f000f0')}} | ${{forward: (elem) => pressKey(elem, {key: 'End'}), backward: (elem) => pressKey(elem, {key: 'Home'})}} | ${parseColor('#df00f0')}
208206
`('$Name RTL', async ({props, actions: {forward, backward}, result}) => {
209207
let {getAllByRole} = render(
210-
<Provider locale="ar-AE" theme={defaultTheme}>
211-
<Component
212-
{...props}
213-
onChange={onChangeSpy}
214-
onChangeEnd={onChangeEndSpy} />
215-
</Provider>
216-
);
208+
<Component
209+
{...props}
210+
onChange={onChangeSpy}
211+
onChangeEnd={onChangeEndSpy} />
212+
, undefined, {locale: 'ar-AE'});
217213
let [xSlider, ySlider] = getAllByRole('slider', {hidden: true});
218214

219215
expect(xSlider.getAttribute('aria-valuetext')).toBe([

packages/@react-spectrum/color/test/ColorPicker.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {act, pointerMap, render, within} from '@react-spectrum/test-utils-internal';
13+
import {act, pointerMap, renderv3 as render, within} from '@react-spectrum/test-utils-internal';
1414
import {ColorEditor, ColorPicker} from '../src';
1515
import {Provider} from '@react-spectrum/provider';
1616
import React from 'react';

packages/@react-spectrum/color/test/ColorSlider.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {act, fireEvent, installMouseEvent, installPointerEvent, pointerMap, render} from '@react-spectrum/test-utils-internal';
13+
import {act, fireEvent, installMouseEvent, installPointerEvent, pointerMap, renderv3 as render} from '@react-spectrum/test-utils-internal';
1414
import {ColorSlider} from '../';
1515
import {parseColor} from '@react-stately/color';
1616
import React from 'react';

packages/@react-spectrum/color/test/ColorWheel.test.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {act, fireEvent, installMouseEvent, installPointerEvent, pointerMap, render} from '@react-spectrum/test-utils-internal';
13+
import {act, fireEvent, installMouseEvent, installPointerEvent, pointerMap, renderv3 as render} from '@react-spectrum/test-utils-internal';
1414
import {ColorWheel} from '../';
1515
import {ControlledHSL} from '../stories/ColorWheel.stories';
1616
import {parseColor} from '@react-stately/color';
@@ -297,7 +297,7 @@ describe('ColorWheel', () => {
297297
let {container: _container, getByRole} = render(<ColorWheel defaultValue={defaultColor} onChange={onChangeSpy} />);
298298
let slider = getByRole('slider');
299299
let thumb = slider.parentElement;
300-
let container = _container?.firstChild?.firstChild as HTMLElement;
300+
let container = _container?.firstChild?.firstChild?.firstChild as HTMLElement;
301301
container.getBoundingClientRect = getBoundingClientRect;
302302

303303
expect(document.activeElement).not.toBe(slider);
@@ -320,7 +320,7 @@ describe('ColorWheel', () => {
320320
let defaultColor = parseColor('hsl(0, 100%, 50%)');
321321
let {container: _container, getByRole} = render(<ColorWheel defaultValue={defaultColor} onChange={onChangeSpy} isDisabled />);
322322
let slider = getByRole('slider');
323-
let container = _container?.firstChild?.firstChild as HTMLElement;
323+
let container = _container?.firstChild?.firstChild?.firstChild as HTMLElement;
324324
container.getBoundingClientRect = getBoundingClientRect;
325325

326326
expect(document.activeElement).not.toBe(slider);
@@ -341,7 +341,7 @@ describe('ColorWheel', () => {
341341
let defaultColor = parseColor('hsl(0, 100%, 50%)');
342342
let {container: _container, getByRole} = render(<ControlledHSL defaultValue={defaultColor} onChange={onChangeSpy} onChangeEnd={onChangeEndSpy} />);
343343
let slider = getByRole('slider');
344-
let container = _container?.firstChild?.firstChild?.firstChild as HTMLElement;
344+
let container = _container?.firstChild?.firstChild?.firstChild?.firstChild as HTMLElement;
345345
container.getBoundingClientRect = getBoundingClientRect;
346346

347347
expect(document.activeElement).not.toBe(slider);
@@ -372,7 +372,7 @@ describe('ColorWheel', () => {
372372
...
373373
input.spectrum-ColorWheel-slider
374374
*/
375-
let handleColorElement = _container?.firstChild?.firstChild?.nextSibling?.firstChild as HTMLElement;
375+
let handleColorElement = _container?.firstChild?.firstChild?.firstChild?.nextSibling?.firstChild as HTMLElement;
376376
let thumbColor = parseColor(handleColorElement.style.backgroundColor);
377377
expect(defaultColor.getChannelValue('alpha')).toEqual(0.5);
378378
expect(thumbColor.getChannelValue('alpha')).toEqual(1);

packages/@react-spectrum/dropzone/docs/DropZone.mdx

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ category: Drag and drop
3535
<HeaderInfo
3636
packageData={packageData}
3737
componentNames={['DropZone']}
38+
since="3.35.0"
3839
/>
3940

4041
## Example
@@ -340,7 +341,7 @@ function Example() {
340341

341342
A DropZone displays visual feedback to the user when a drag hovers over the drop target by passing the `getDropOperation` function. If a drop target only supports data of specific types (e.g. images, videos, text, etc.), then it should implement the `getDropOperation` prop and return `'cancel'` for types that aren't supported. This will prevent visual feedback indicating that the drop target accepts the dragged data when this is not true. [Read more about getDropOperation.](../react-aria/useDrop.html#getdropoperation)
342343

343-
In the below example, the drop zone only supports dropping JPEG images. If a JPEG is dragged over the drop zone, it will be highlighted and the operating system will display a copy cursor. If another type is dragged over the drop zone, then there is no visual feedback, indicating that a drop is not accepted.
344+
In the below example, the drop zone only supports dropping JPEG images. If a JPEG is dragged over the drop zone, it will be highlighted and the operating system will display a copy cursor. If another type is dragged over the drop zone, then there is no visual feedback, indicating that a drop is not accepted.
344345

345346
```tsx example
346347
import {FileTrigger} from '@adobe/react-spectrum';

packages/@react-spectrum/filetrigger/docs/FileTrigger.mdx

+4-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ category: Buttons
3232

3333
<HeaderInfo
3434
packageData={packageData}
35-
componentNames={['FileTrigger']} />
35+
componentNames={['FileTrigger']}
36+
since="3.35.0" />
3637

3738
## Example
3839

@@ -94,9 +95,9 @@ A file trigger can accept multiple files by passsing the `allowsMultiple` proper
9495

9596
## Directory selection
9697

97-
To enable selecting directories instead of files, use the `acceptDirectory` property.
98+
To enable selecting directories instead of files, use the `acceptDirectory` property.
9899

99-
This reflects the [webkitdirectory](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory) HTML attribute and allows users to select directories and their contents. Please note that support for this feature varies from browser to browser.
100+
This reflects the [webkitdirectory](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory) HTML attribute and allows users to select directories and their contents. Please note that support for this feature varies from browser to browser.
100101

101102

102103
```tsx example

packages/@react-spectrum/icon/docs/custom-icons.mdx

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Custom icons can be used by wrapping them in an Icon component.
3232
componentNames={['Icon']}
3333
sourceData={[
3434
{type: 'Spectrum', url: 'https://spectrum.adobe.com/page/iconography/'}
35-
]} />
35+
]}
36+
since="3.0.0" />
3637

3738
## Example
3839

packages/@react-spectrum/icon/src/Icon.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
import {AriaLabelingProps, DOMProps, IconColorValue, StyleProps} from '@react-types/shared';
1414
import {baseStyleProps, classNames, StyleHandlers, useSlotProps, useStyleProps} from '@react-spectrum/utils';
15-
import {Context} from '@react-spectrum/provider';
1615
import {filterDOMProps} from '@react-aria/utils';
17-
import React, {ReactElement, useContext} from 'react';
16+
import {ProviderContext, useProvider} from '@react-spectrum/provider';
17+
import React, {ReactElement} from 'react';
1818
import styles from '@adobe/spectrum-css-temp/components/icon/vars.css';
1919

2020
export interface IconProps extends DOMProps, AriaLabelingProps, StyleProps {
@@ -70,9 +70,15 @@ export function Icon(props: IconProps) {
7070
} = props;
7171
let {styleProps} = useStyleProps(otherProps, iconStyleProps);
7272

73-
let provider = useContext(Context);
73+
let provider: undefined | ProviderContext;
74+
try {
75+
// eslint-disable-next-line react-hooks/rules-of-hooks
76+
provider = useProvider();
77+
} catch {
78+
// ignore
79+
}
7480
let scale = 'M';
75-
if (provider !== null) {
81+
if (provider != null) {
7682
scale = provider.scale === 'large' ? 'L' : 'M';
7783
}
7884
if (!ariaHidden) {

packages/@react-spectrum/icon/src/UIIcon.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
import {AriaLabelingProps, DOMProps, StyleProps} from '@react-types/shared';
1414
import {classNames, useSlotProps, useStyleProps} from '@react-spectrum/utils';
15-
import {Context} from '@react-spectrum/provider';
1615
import {filterDOMProps} from '@react-aria/utils';
17-
import React, {ReactElement, useContext} from 'react';
16+
import {ProviderContext, useProvider} from '@react-spectrum/provider';
17+
import React, {ReactElement} from 'react';
1818
import styles from '@adobe/spectrum-css-temp/components/icon/vars.css';
1919

2020
export interface UIIconProps extends DOMProps, AriaLabelingProps, StyleProps {
@@ -38,9 +38,15 @@ export function UIIcon(props: UIIconProps) {
3838
} = props;
3939

4040
let {styleProps} = useStyleProps(otherProps);
41-
let provider = useContext(Context);
41+
let provider: undefined | ProviderContext;
42+
try {
43+
// eslint-disable-next-line react-hooks/rules-of-hooks
44+
provider = useProvider();
45+
} catch {
46+
// ignore
47+
}
4248
let scale = 'M';
43-
if (provider !== null) {
49+
if (provider != null) {
4450
scale = provider.scale === 'large' ? 'L' : 'M';
4551
}
4652

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {DOMRef} from '@react-types/shared';
2323
import {filterDOMProps, RouterProvider} from '@react-aria/utils';
2424
import {I18nProvider, useLocale} from '@react-aria/i18n';
2525
import {ModalProvider, useModalProvider} from '@react-aria/overlays';
26-
import {ProviderProps} from '@react-types/provider';
26+
import {ProviderContext, ProviderProps} from '@react-types/provider';
2727
import React, {useContext, useEffect, useRef} from 'react';
2828
import styles from '@adobe/spectrum-css-temp/components/page/vars.css';
2929
import typographyStyles from '@adobe/spectrum-css-temp/components/typography/index.css';
@@ -195,7 +195,7 @@ const ProviderWrapper = React.forwardRef(function ProviderWrapper(props: Provide
195195
* Returns the various settings and styles applied by the nearest parent Provider.
196196
* Properties explicitly set by the nearest parent Provider override those provided by preceeding Providers.
197197
*/
198-
export function useProvider() {
198+
export function useProvider(): ProviderContext {
199199
let context = useContext(Context);
200200
if (!context) {
201201
throw new Error(

packages/@react-spectrum/provider/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@
1313
/// <reference types="css-module-types" />
1414

1515
export {Provider, useProvider, useProviderProps} from './Provider';
16-
export {Context} from './context';
1716
export type {ProviderContext} from '@react-types/provider';
1817
export type {ProviderProps} from '@react-types/provider';

0 commit comments

Comments
 (0)