Skip to content

Commit 735b275

Browse files
authored
chore(s2): fix S2 children and context types (#7668)
* fix S2 children and context types * fix chromatic types? * missed one * switch some children types back to optional * fix types * fix types * types * review comment
1 parent 4b8b33a commit 735b275

Some content is hidden

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

53 files changed

+89
-86
lines changed

packages/@react-spectrum/s2/chromatic/ActionMenu.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {DynamicExample, Example} from '../stories/ActionMenu.stories';
1515
import type {Meta, StoryObj} from '@storybook/react';
1616
import {userEvent, within} from '@storybook/testing-library';
1717

18-
const meta: Meta<typeof ActionMenu> = {
18+
const meta: Meta<typeof ActionMenu<any>> = {
1919
component: ActionMenu,
2020
parameters: {
2121
chromaticProvider: {colorSchemes: ['light'], backgrounds: ['base'], locales: ['en-US'], disableAnimations: true}

packages/@react-spectrum/s2/chromatic/ActionMenuRTL.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {ActionMenu} from '../src';
1414

1515
import type {Meta} from '@storybook/react';
1616

17-
const meta: Meta<typeof ActionMenu> = {
17+
const meta: Meta<typeof ActionMenu<any>> = {
1818
component: ActionMenu,
1919
parameters: {
2020
chromaticProvider: {colorSchemes: ['dark'], backgrounds: ['base'], locales: ['ar-AE'], disableAnimations: true}

packages/@react-spectrum/s2/chromatic/Menu.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {Menu} from '../src';
1515
import type {Meta} from '@storybook/react';
1616
import {userEvent, within} from '@storybook/testing-library';
1717

18-
const meta: Meta<typeof Menu> = {
18+
const meta: Meta<typeof Menu<any>> = {
1919
component: Menu,
2020
parameters: {
2121
chromaticProvider: {colorSchemes: ['light'], backgrounds: ['base'], locales: ['en-US'], disableAnimations: true}

packages/@react-spectrum/s2/chromatic/MenuRTL.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {Menu} from '../src';
1414

1515
import type {Meta} from '@storybook/react';
1616

17-
const meta: Meta<typeof Menu> = {
17+
const meta: Meta<typeof Menu<any>> = {
1818
component: Menu,
1919
parameters: {
2020
chromaticProvider: {colorSchemes: ['dark'], backgrounds: ['base'], locales: ['ar-AE'], disableAnimations: true}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const accordion = style({
4343
flexDirection: 'column'
4444
}, getAllowedOverrides({height: true}));
4545

46-
export const AccordionContext = createContext<ContextValue<AccordionProps, DOMRefValue<HTMLDivElement>>>(null);
46+
export const AccordionContext = createContext<ContextValue<Partial<AccordionProps>, DOMRefValue<HTMLDivElement>>>(null);
4747

4848
/**
4949
* An accordion is a container for multiple disclosures.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ interface ActionGroupItemStyleProps {
5454

5555
export interface ActionButtonProps extends Omit<ButtonProps, 'className' | 'style' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange' | 'isPending'>, StyleProps, ActionButtonStyleProps {
5656
/** The content to display in the ActionButton. */
57-
children?: ReactNode
57+
children: ReactNode
5858
}
5959

6060
// These styles handle both ActionButton and ToggleButton
@@ -228,7 +228,7 @@ const avatarSize = {
228228
X: 26
229229
} as const;
230230

231-
export const ActionButtonContext = createContext<ContextValue<ActionButtonProps, FocusableRefValue<HTMLButtonElement>>>(null);
231+
export const ActionButtonContext = createContext<ContextValue<Partial<ActionButtonProps>, FocusableRefValue<HTMLButtonElement>>>(null);
232232

233233
/**
234234
* ActionButtons allow users to perform an action.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export interface ActionMenuProps<T> extends
3232
menuSize?: 'S' | 'M' | 'L' | 'XL'
3333
}
3434

35-
export const ActionMenuContext = createContext<ContextValue<ActionMenuProps<any>, FocusableRefValue<HTMLButtonElement>>>(null);
35+
export const ActionMenuContext = createContext<ContextValue<Partial<ActionMenuProps<any>>, FocusableRefValue<HTMLButtonElement>>>(null);
3636

3737
/**
3838
* ActionMenu combines an ActionButton with a Menu for simple "more actions" use cases.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const imageStyles = style({
5353
}
5454
}, getAllowedOverrides({width: false}));
5555

56-
export const AvatarContext = createContext<ContextValue<AvatarProps, DOMRefValue<HTMLImageElement>>>(null);
56+
export const AvatarContext = createContext<ContextValue<Partial<AvatarProps>, DOMRefValue<HTMLImageElement>>>(null);
5757

5858
/**
5959
* An avatar is a thumbnail representation of an entity, such as a user or an organization.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export interface AvatarGroupProps extends UnsafeStyles, DOMProps, AriaLabelingPr
3535
styles?: StylesPropWithoutWidth
3636
}
3737

38-
export const AvatarGroupContext = createContext<ContextValue<AvatarGroupProps, DOMRefValue<HTMLDivElement>>>(null);
38+
export const AvatarGroupContext = createContext<ContextValue<Partial<AvatarGroupProps>, DOMRefValue<HTMLDivElement>>>(null);
3939

4040
const avatar = style({
4141
marginStart: {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ interface BreadcrumbsStyleProps {
6262

6363
export interface BreadcrumbsProps<T> extends Omit<AriaBreadcrumbsProps<T>, 'children' | 'items' | 'style' | 'className'>, BreadcrumbsStyleProps, StyleProps {
6464
/** The children of the Breadcrumbs. */
65-
children?: ReactNode
65+
children: ReactNode
6666
}
6767

68-
export const BreadcrumbsContext = createContext<ContextValue<BreadcrumbsProps<any>, DOMRefValue<HTMLOListElement>>>(null);
68+
export const BreadcrumbsContext = createContext<ContextValue<Partial<BreadcrumbsProps<any>>, DOMRefValue<HTMLOListElement>>>(null);
6969

7070
const wrapper = style<BreadcrumbsStyleProps>({
7171
position: 'relative',
@@ -95,7 +95,7 @@ const wrapper = style<BreadcrumbsStyleProps>({
9595
}
9696
}, getAllowedOverrides());
9797

98-
const InternalBreadcrumbsContext = createContext<BreadcrumbsProps<any>>({});
98+
const InternalBreadcrumbsContext = createContext<Partial<BreadcrumbsProps<any>>>({});
9999

100100
/** Breadcrumbs show hierarchy and navigational context for a user’s location within an application. */
101101
export const Breadcrumbs = /*#__PURE__*/ (forwardRef as forwardRefType)(function Breadcrumbs<T extends object>(props: BreadcrumbsProps<T>, ref: DOMRef<HTMLOListElement>) {
@@ -290,7 +290,7 @@ const heading = style({
290290

291291
export interface BreadcrumbProps extends Omit<AriaBreadcrumbItemProps, 'children' | 'style' | 'className' | 'autoFocus'>, LinkDOMProps {
292292
/** The children of the breadcrumb item. */
293-
children?: ReactNode
293+
children: ReactNode
294294
}
295295

296296
/** An individual Breadcrumb for Breadcrumbs. */

0 commit comments

Comments
 (0)