Skip to content

Commit 8e30822

Browse files
committed
perf(react-aria-components): import from individual package instead of react-aria and react-stately
1 parent a8dbaf6 commit 8e30822

Some content is hidden

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

55 files changed

+543
-182
lines changed

eslint.config.mjs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,4 +504,19 @@ export default [{
504504
rules: {
505505
"react/react-in-jsx-scope": OFF,
506506
},
507-
}];
507+
}, {
508+
files: ["packages/react-aria-components/src/**"],
509+
510+
rules: {
511+
"no-restricted-imports": [ERROR, {
512+
"name": "react-aria",
513+
"message": "Use individual packages from @react-aria scope instead."
514+
}, {
515+
"name": "react-stately",
516+
"message": "Use individual packages from @react-stately scope instead"
517+
}, {
518+
"name": "react-spectrum",
519+
"message": "Use individual packages from @react-spectrum scope instead."
520+
}]
521+
},
522+
}];

packages/react-aria-components/package.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,97 @@
4444
"@internationalized/date": "^3.8.2",
4545
"@internationalized/string": "^3.2.7",
4646
"@react-aria/autocomplete": "3.0.0-beta.6",
47+
"@react-aria/breadcrumbs": "^3.5.27",
48+
"@react-aria/button": "^3.14.0",
49+
"@react-aria/calendar": "^3.9.0",
50+
"@react-aria/checkbox": "^3.16.0",
4751
"@react-aria/collections": "3.0.0-rc.4",
52+
"@react-aria/color": "^3.1.0",
53+
"@react-aria/combobox": "^3.13.0",
54+
"@react-aria/datepicker": "^3.15.0",
55+
"@react-aria/dialog": "^3.5.28",
56+
"@react-aria/disclosure": "^3.0.7",
4857
"@react-aria/dnd": "^3.11.0",
4958
"@react-aria/focus": "^3.21.0",
59+
"@react-aria/gridlist": "^3.13.3",
60+
"@react-aria/i18n": "^3.12.11",
5061
"@react-aria/interactions": "^3.25.4",
62+
"@react-aria/link": "^3.8.4",
63+
"@react-aria/listbox": "^3.14.7",
5164
"@react-aria/live-announcer": "^3.4.4",
65+
"@react-aria/menu": "^3.19.0",
66+
"@react-aria/meter": "^3.4.25",
67+
"@react-aria/numberfield": "^3.12.0",
5268
"@react-aria/overlays": "^3.28.0",
69+
"@react-aria/progress": "^3.4.25",
70+
"@react-aria/radio": "^3.12.0",
71+
"@react-aria/searchfield": "^3.8.7",
72+
"@react-aria/select": "^3.16.0",
73+
"@react-aria/selection": "^3.25.0",
74+
"@react-aria/separator": "^3.4.11",
75+
"@react-aria/slider": "^3.8.0",
5376
"@react-aria/ssr": "^3.9.10",
77+
"@react-aria/switch": "^3.7.6",
78+
"@react-aria/table": "^3.17.6",
79+
"@react-aria/tabs": "^3.10.6",
80+
"@react-aria/tag": "^3.7.0",
81+
"@react-aria/textfield": "^3.18.0",
82+
"@react-aria/toast": "^3.0.6",
5483
"@react-aria/toolbar": "3.0.0-beta.19",
84+
"@react-aria/tooltip": "^3.8.6",
85+
"@react-aria/tree": "^3.1.2",
5586
"@react-aria/utils": "^3.30.0",
5687
"@react-aria/virtualizer": "^4.1.8",
88+
"@react-aria/visually-hidden": "^3.8.26",
5789
"@react-stately/autocomplete": "3.0.0-beta.3",
90+
"@react-stately/calendar": "^3.8.3",
91+
"@react-stately/checkbox": "^3.7.0",
92+
"@react-stately/collections": "^3.12.6",
93+
"@react-stately/color": "^3.9.0",
94+
"@react-stately/combobox": "^3.11.0",
95+
"@react-stately/datepicker": "^3.15.0",
96+
"@react-stately/disclosure": "^3.0.6",
97+
"@react-stately/dnd": "^3.6.1",
98+
"@react-stately/form": "^3.2.0",
5899
"@react-stately/layout": "^4.4.0",
100+
"@react-stately/list": "^3.12.4",
101+
"@react-stately/menu": "^3.9.6",
102+
"@react-stately/numberfield": "^3.10.0",
103+
"@react-stately/overlays": "^3.6.18",
104+
"@react-stately/radio": "^3.11.0",
105+
"@react-stately/searchfield": "^3.5.14",
106+
"@react-stately/select": "^3.7.0",
59107
"@react-stately/selection": "^3.20.4",
108+
"@react-stately/slider": "^3.7.0",
60109
"@react-stately/table": "^3.14.4",
110+
"@react-stately/tabs": "^3.8.4",
111+
"@react-stately/toast": "^3.1.2",
112+
"@react-stately/toggle": "^3.9.0",
113+
"@react-stately/tooltip": "^3.5.6",
114+
"@react-stately/tree": "^3.9.1",
61115
"@react-stately/utils": "^3.10.8",
62116
"@react-stately/virtualizer": "^4.4.2",
117+
"@react-types/button": "^3.13.0",
118+
"@react-types/checkbox": "^3.10.0",
119+
"@react-types/color": "^3.1.0",
120+
"@react-types/combobox": "^3.13.7",
121+
"@react-types/datepicker": "^3.13.0",
122+
"@react-types/dialog": "^3.5.20",
63123
"@react-types/form": "^3.7.14",
64124
"@react-types/grid": "^3.3.4",
125+
"@react-types/listbox": "^3.7.2",
126+
"@react-types/numberfield": "^3.8.13",
127+
"@react-types/overlays": "^3.9.0",
128+
"@react-types/radio": "^3.9.0",
129+
"@react-types/searchfield": "^3.6.4",
130+
"@react-types/select": "^3.10.0",
65131
"@react-types/shared": "^3.31.0",
132+
"@react-types/slider": "^3.8.0",
133+
"@react-types/switch": "^3.5.13",
66134
"@react-types/table": "^3.13.2",
135+
"@react-types/tabs": "^3.3.17",
136+
"@react-types/textfield": "^3.12.4",
137+
"@react-types/tooltip": "^3.4.19",
67138
"@swc/helpers": "^0.5.0",
68139
"client-only": "^0.0.1",
69140
"react-aria": "^3.42.0",

packages/react-aria-components/src/Breadcrumbs.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
* OF ANY KIND, either express or implied. See the License for the specific language
1010
* governing permissions and limitations under the License.
1111
*/
12-
import {AriaBreadcrumbsProps, useBreadcrumbs} from 'react-aria';
12+
import {AriaBreadcrumbsProps, useBreadcrumbs} from '@react-aria/breadcrumbs';
1313
import {Collection, CollectionBuilder, createLeafComponent} from '@react-aria/collections';
1414
import {CollectionProps, CollectionRendererContext} from './Collection';
1515
import {ContextValue, RenderProps, SlotProps, StyleProps, useContextProps, useRenderProps, useSlottedContext} from './utils';
1616
import {filterDOMProps, mergeProps} from '@react-aria/utils';
17-
import {forwardRefType, GlobalDOMAttributes, Key} from '@react-types/shared';
17+
import {forwardRefType, GlobalDOMAttributes, Key, Node} from '@react-types/shared';
1818
import {LinkContext} from './Link';
19-
import {Node} from 'react-stately';
2019
import React, {createContext, ForwardedRef, forwardRef, useContext} from 'react';
2120

2221
export interface BreadcrumbsProps<T> extends Omit<CollectionProps<T>, 'disabledKeys'>, AriaBreadcrumbsProps, StyleProps, SlotProps, GlobalDOMAttributes<HTMLOListElement> {

packages/react-aria-components/src/Button.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@
1111
*/
1212

1313
import {announce} from '@react-aria/live-announcer';
14-
import {
15-
AriaButtonProps,
16-
HoverEvents,
17-
mergeProps,
18-
useButton,
19-
useFocusRing,
20-
useHover,
21-
useId
22-
} from 'react-aria';
14+
import {AriaButtonProps, useButton} from '@react-aria/button';
2315
import {
2416
ContextValue,
2517
RenderProps,
@@ -28,10 +20,12 @@ import {
2820
useRenderProps
2921
} from './utils';
3022
import {createHideableComponent} from '@react-aria/collections';
31-
import {filterDOMProps} from '@react-aria/utils';
23+
import {filterDOMProps, mergeProps, useId} from '@react-aria/utils';
3224
import {GlobalDOMAttributes} from '@react-types/shared';
25+
import {HoverEvents, useHover} from '@react-aria/interactions';
3326
import {ProgressBarContext} from './ProgressBar';
3427
import React, {createContext, ForwardedRef, useEffect, useRef} from 'react';
28+
import {useFocusRing} from '@react-aria/focus';
3529

3630
export interface ButtonRenderProps {
3731
/**

packages/react-aria-components/src/Calendar.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,25 @@
1111
*/
1212
import {
1313
AriaCalendarProps,
14-
AriaRangeCalendarProps,
15-
DateValue,
16-
mergeProps,
14+
AriaRangeCalendarProps, DateValue,
1715
useCalendar,
1816
useCalendarCell,
1917
useCalendarGrid,
20-
useFocusRing,
21-
useHover,
22-
useLocale,
23-
useRangeCalendar,
24-
VisuallyHidden
25-
} from 'react-aria';
18+
useRangeCalendar
19+
} from '@react-aria/calendar';
2620
import {ButtonContext} from './Button';
2721
import {CalendarDate, CalendarIdentifier, createCalendar, DateDuration, endOfMonth, Calendar as ICalendar, isSameDay, isSameMonth, isToday} from '@internationalized/date';
28-
import {CalendarState, RangeCalendarState, useCalendarState, useRangeCalendarState} from 'react-stately';
22+
import {CalendarState, RangeCalendarState, useCalendarState, useRangeCalendarState} from '@react-stately/calendar';
2923
import {ContextValue, DOMProps, Provider, RenderProps, SlotProps, StyleProps, useContextProps, useRenderProps, useSlottedContext} from './utils';
3024
import {DOMAttributes, FocusableElement, forwardRefType, GlobalDOMAttributes, HoverEvents} from '@react-types/shared';
31-
import {filterDOMProps} from '@react-aria/utils';
25+
import {filterDOMProps, mergeProps} from '@react-aria/utils';
3226
import {HeadingContext} from './RSPContexts';
3327
import React, {createContext, ForwardedRef, forwardRef, ReactElement, useContext, useRef} from 'react';
3428
import {TextContext} from './Text';
29+
import {useFocusRing} from '@react-aria/focus';
30+
import {useHover} from '@react-aria/interactions';
31+
import {useLocale} from '@react-aria/i18n';
32+
import {VisuallyHidden} from '@react-aria/visually-hidden';
3533

3634
export interface CalendarRenderProps {
3735
/**

packages/react-aria-components/src/Checkbox.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@
99
* OF ANY KIND, either express or implied. See the License for the specific language
1010
* governing permissions and limitations under the License.
1111
*/
12-
import {AriaCheckboxGroupProps, AriaCheckboxProps, HoverEvents, mergeProps, useCheckbox, useCheckboxGroup, useCheckboxGroupItem, useFocusRing, useHover, VisuallyHidden} from 'react-aria';
12+
import {AriaCheckboxGroupProps, AriaCheckboxProps} from '@react-types/checkbox';
1313
import {CheckboxContext} from './RSPContexts';
14-
import {CheckboxGroupState, useCheckboxGroupState, useToggleState} from 'react-stately';
14+
import {CheckboxGroupState, useCheckboxGroupState} from '@react-stately/checkbox';
1515
import {ContextValue, Provider, RACValidation, removeDataAttributes, RenderProps, SlotProps, useContextProps, useRenderProps, useSlot, useSlottedContext} from './utils';
1616
import {FieldErrorContext} from './FieldError';
17-
import {filterDOMProps, mergeRefs, useObjectRef} from '@react-aria/utils';
17+
import {filterDOMProps, mergeProps, mergeRefs, useObjectRef} from '@react-aria/utils';
1818
import {FormContext} from './Form';
19-
import {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';
19+
import {forwardRefType, GlobalDOMAttributes, HoverEvents, RefObject} from '@react-types/shared';
2020
import {LabelContext} from './Label';
2121
import React, {createContext, ForwardedRef, forwardRef, useContext, useMemo} from 'react';
2222
import {TextContext} from './Text';
23+
import {useCheckbox, useCheckboxGroup, useCheckboxGroupItem} from '@react-aria/checkbox';
24+
import {useFocusRing} from '@react-aria/focus';
25+
import {useHover} from '@react-aria/interactions';
26+
import {useToggleState} from '@react-stately/toggle';
27+
import {VisuallyHidden} from '@react-aria/visually-hidden';
2328

2429
export interface CheckboxGroupProps extends Omit<AriaCheckboxGroupProps, 'children' | 'label' | 'description' | 'errorMessage' | 'validationState' | 'validationBehavior'>, RACValidation, RenderProps<CheckboxGroupRenderProps>, SlotProps, GlobalDOMAttributes<HTMLDivElement> {}
2530
export interface CheckboxProps extends Omit<AriaCheckboxProps, 'children' | 'validationState' | 'validationBehavior'>, HoverEvents, RACValidation, RenderProps<CheckboxRenderProps>, SlotProps, Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {

packages/react-aria-components/src/Collection.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
* OF ANY KIND, either express or implied. See the License for the specific language
1010
* governing permissions and limitations under the License.
1111
*/
12-
import {CollectionBase, DropTargetDelegate, GlobalDOMAttributes, ItemDropTarget, Key, LayoutDelegate, RefObject} from '@react-types/shared';
12+
import {CollectionBase, DropTargetDelegate, GlobalDOMAttributes, Collection as ICollection, ItemDropTarget, Key, LayoutDelegate, Node, RefObject, SelectionBehavior, SelectionMode, SectionProps as SharedSectionProps} from '@react-types/shared';
1313
import {createBranchComponent, useCachedChildren} from '@react-aria/collections';
14-
import {Collection as ICollection, Node, SelectionBehavior, SelectionMode, SectionProps as SharedSectionProps} from 'react-stately';
1514
import React, {cloneElement, createContext, ForwardedRef, HTMLAttributes, isValidElement, JSX, ReactElement, ReactNode, useContext, useMemo} from 'react';
1615
import {StyleProps} from './utils';
1716

packages/react-aria-components/src/ColorArea.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {AriaColorAreaProps, useColorArea} from 'react-aria';
1+
import {AriaColorAreaProps, useColorArea} from '@react-aria/color';
22
import {ColorAreaContext} from './RSPContexts';
3-
import {ColorAreaState, useColorAreaState} from 'react-stately';
3+
import {ColorAreaState, useColorAreaState} from '@react-stately/color';
44
import {filterDOMProps, mergeProps} from '@react-aria/utils';
55
import {GlobalDOMAttributes} from '@react-types/shared';
66
import {InternalColorThumbContext} from './ColorThumb';

packages/react-aria-components/src/ColorField.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {AriaColorFieldProps, useColorChannelField, useColorField, useLocale} from 'react-aria';
14-
import {ColorChannel, ColorFieldState, ColorSpace, useColorChannelFieldState, useColorFieldState} from 'react-stately';
13+
import {AriaColorFieldProps, ColorChannel, ColorSpace} from '@react-types/color';
1514
import {ColorFieldContext} from './RSPContexts';
15+
import {ColorFieldState, useColorChannelFieldState, useColorFieldState} from '@react-stately/color';
1616
import {FieldErrorContext} from './FieldError';
1717
import {filterDOMProps} from '@react-aria/utils';
1818
import {GlobalDOMAttributes, InputDOMProps, ValidationResult} from '@react-types/shared';
@@ -22,6 +22,8 @@ import {LabelContext} from './Label';
2222
import {Provider, RACValidation, removeDataAttributes, RenderProps, SlotProps, useContextProps, useRenderProps, useSlot} from './utils';
2323
import React, {createContext, ForwardedRef, forwardRef, HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, Ref, useRef} from 'react';
2424
import {TextContext} from './Text';
25+
import {useColorChannelField, useColorField} from '@react-aria/color';
26+
import {useLocale} from '@react-aria/i18n';
2527

2628
export interface ColorFieldRenderProps {
2729
/**
@@ -47,7 +49,7 @@ export interface ColorFieldRenderProps {
4749

4850
export interface ColorFieldProps extends Omit<AriaColorFieldProps, 'label' | 'placeholder' | 'description' | 'errorMessage' | 'validationState' | 'validationBehavior'>, RACValidation, InputDOMProps, RenderProps<ColorFieldRenderProps>, SlotProps, GlobalDOMAttributes<HTMLDivElement> {
4951
/**
50-
* The color channel that this field edits. If not provided,
52+
* The color channel that this field edits. If not provided,
5153
* the color is edited as a hex value.
5254
*/
5355
channel?: ColorChannel,

packages/react-aria-components/src/ColorPicker.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {Color, ColorPickerState, ColorPickerProps as StatelyColorPickerProps, useColorPickerState} from 'react-stately';
13+
import {
14+
Color,
15+
ColorPickerState,
16+
ColorPickerProps as StatelyColorPickerProps,
17+
useColorPickerState
18+
} from '@react-stately/color';
1419
import {ColorAreaContext, ColorFieldContext, ColorSliderContext, ColorWheelContext} from './RSPContexts';
1520
import {ColorSwatchContext} from './ColorSwatch';
1621
import {ColorSwatchPickerContext} from './ColorSwatchPicker';
17-
import {mergeProps} from 'react-aria';
22+
import {mergeProps} from '@react-aria/utils';
1823
import {Provider, RenderProps, SlotProps, SlottedContextValue, useRenderProps, useSlottedContext} from './utils';
1924
import React, {createContext, JSX} from 'react';
2025

0 commit comments

Comments
 (0)