Skip to content

Commit 858d6cd

Browse files
authored
feat: Add render prop to allow customizing DOM element (#9499)
* prototype: Add render prop to allow customizing DOM element * Implement all components * Omit from Spectrum * Add render props as a second argument * review comments
1 parent 6add5b7 commit 858d6cd

160 files changed

Lines changed: 1141 additions & 413 deletions

File tree

Some content is hidden

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

packages/@react-spectrum/accordion/chromatic/Accordion.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ const meta: Meta = {
2222

2323
export default meta;
2424

25-
export type AccordionStory = StoryObj<SpectrumAccordionProps>;
25+
export type AccordionStory = StoryObj<Partial<SpectrumAccordionProps>>;
2626

27-
export const Template = (args: SpectrumAccordionProps): JSX.Element => (
27+
export const Template = (args: Partial<SpectrumAccordionProps>): JSX.Element => (
2828
<Accordion {...args}>
2929
<Disclosure id="files">
3030
<DisclosureTitle>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import styles from '@adobe/spectrum-css-temp/components/accordion/vars.css';
2020
import {useLocale} from '@react-aria/i18n';
2121
import {useProviderProps} from '@react-spectrum/provider';
2222

23-
export interface SpectrumAccordionProps extends Omit<DisclosureGroupProps, 'className' | 'style' | 'children'>, StyleProps, DOMProps {
23+
export interface SpectrumAccordionProps extends Omit<DisclosureGroupProps, 'className' | 'style' | 'render' | 'children'>, StyleProps, DOMProps {
2424
/** Whether the Accordion should be displayed with a quiet style. */
2525
isQuiet?: boolean,
2626
/** The disclosures within the accordion group. */
@@ -47,7 +47,7 @@ export const Accordion = /*#__PURE__*/(forwardRef as forwardRefType)(function Ac
4747
);
4848
});
4949

50-
export interface SpectrumDisclosureProps extends Omit<DisclosureProps, 'className' | 'style' | 'children'>, AriaLabelingProps, StyleProps {
50+
export interface SpectrumDisclosureProps extends Omit<DisclosureProps, 'className' | 'style' | 'render' | 'children'>, AriaLabelingProps, StyleProps {
5151
/** Whether the Disclosure should be displayed with a quiet style. */
5252
isQuiet?: boolean,
5353
/** The contents of the disclosure. The first child should be the header, and the second child should be the panel. */
@@ -76,7 +76,7 @@ export const Disclosure = /*#__PURE__*/(forwardRef as forwardRefType)(function D
7676
);
7777
});
7878

79-
export interface SpectrumDisclosurePanelProps extends Omit<DisclosurePanelProps, 'className' | 'style' | 'children'>, DOMProps, AriaLabelingProps, StyleProps {
79+
export interface SpectrumDisclosurePanelProps extends Omit<DisclosurePanelProps, 'className' | 'style' | 'render' | 'children'>, DOMProps, AriaLabelingProps, StyleProps {
8080
/** The contents of the accordion panel. */
8181
children: React.ReactNode
8282
}

packages/@react-spectrum/dropzone/src/DropZone.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import React, {ReactNode} from 'react';
2020
import styles from '@adobe/spectrum-css-temp/components/dropzone/vars.css';
2121
import {useLocalizedStringFormatter} from '@react-aria/i18n';
2222

23-
export interface SpectrumDropZoneProps extends Omit<DropZoneProps, 'onHoverStart' | 'onHoverChange' | 'onHoverEnd' | 'isDisabled' | 'className' | 'style'>, DOMProps, StyleProps, AriaLabelingProps {
23+
export interface SpectrumDropZoneProps extends Omit<DropZoneProps, 'onHoverStart' | 'onHoverChange' | 'onHoverEnd' | 'isDisabled' | 'className' | 'style' | 'render'>, DOMProps, StyleProps, AriaLabelingProps {
2424
/** The content to display in the drop zone. */
2525
children: ReactNode,
2626
/** Whether the drop zone has been filled. */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export interface AccordionItemRenderProps {
122122
state: AccordionItemState
123123
}
124124

125-
export interface AccordionItemProps extends Omit<RenderProps<AccordionItemRenderProps>, 'className' | 'style'>, SlotProps, StyleProps {
125+
export interface AccordionItemProps extends Omit<RenderProps<AccordionItemRenderProps>, 'className' | 'style' | 'render'>, SlotProps, StyleProps {
126126
/**
127127
* The size of the accordion item.
128128
* @default 'M'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ interface ActionGroupItemStyleProps {
5959
isJustified?: boolean
6060
}
6161

62-
export interface ActionButtonProps extends Omit<ButtonProps, 'className' | 'style' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange' | 'onClick' | keyof GlobalDOMAttributes>, StyleProps, ActionButtonStyleProps {
62+
export interface ActionButtonProps extends Omit<ButtonProps, 'className' | 'style' | 'render' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange' | 'onClick' | keyof GlobalDOMAttributes>, StyleProps, ActionButtonStyleProps {
6363
/** The content to display in the ActionButton. */
6464
children: ReactNode
6565
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ interface BreadcrumbsStyleProps {
6363
// TODO: showRoot?: boolean,
6464
}
6565

66-
export interface BreadcrumbsProps<T> extends Omit<AriaBreadcrumbsProps<T>, 'children' | 'style' | 'className' | keyof GlobalDOMAttributes>, BreadcrumbsStyleProps, StyleProps {
66+
export interface BreadcrumbsProps<T> extends Omit<AriaBreadcrumbsProps<T>, 'children' | 'style' | 'className' | 'render' | keyof GlobalDOMAttributes>, BreadcrumbsStyleProps, StyleProps {
6767
/** The children of the Breadcrumbs. */
6868
children: ReactNode | ((item: T) => ReactNode)
6969
}
@@ -296,7 +296,7 @@ const heading = style({
296296
fontWeight: 'extra-bold'
297297
});
298298

299-
export interface BreadcrumbProps extends Omit<AriaBreadcrumbItemProps, 'children' | 'style' | 'className' | 'autoFocus' | 'onClick' | keyof GlobalDOMAttributes>, LinkDOMProps {
299+
export interface BreadcrumbProps extends Omit<AriaBreadcrumbItemProps, 'children' | 'style' | 'className' | 'render' | 'autoFocus' | 'onClick' | keyof GlobalDOMAttributes>, LinkDOMProps {
300300
/** The children of the breadcrumb item. */
301301
children: ReactNode
302302
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ interface ButtonStyleProps {
5252
staticColor?: 'white' | 'black' | 'auto'
5353
}
5454

55-
export interface ButtonProps extends Omit<RACButtonProps, 'className' | 'style' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange' | 'onClick' | keyof GlobalDOMAttributes>, StyleProps, ButtonStyleProps {
55+
export interface ButtonProps extends Omit<RACButtonProps, 'className' | 'style' | 'render' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange' | 'onClick' | keyof GlobalDOMAttributes>, StyleProps, ButtonStyleProps {
5656
/** The content to display in the Button. */
5757
children: ReactNode
5858
}
5959

60-
export interface LinkButtonProps extends Omit<LinkProps, 'className' | 'style' | 'children' | 'onClick' | keyof GlobalDOMAttributes>, StyleProps, ButtonStyleProps {
60+
export interface LinkButtonProps extends Omit<LinkProps, 'className' | 'style' | 'render' | 'children' | 'onClick' | keyof GlobalDOMAttributes>, StyleProps, ButtonStyleProps {
6161
/** The content to display in the Button. */
6262
children: ReactNode
6363
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import {useSpectrumContextProps} from './useSpectrumContextProps';
5555

5656

5757
export interface CalendarProps<T extends DateValue>
58-
extends Omit<AriaCalendarProps<T>, 'visibleDuration' | 'style' | 'className' | 'styles' | 'children' | keyof GlobalDOMAttributes>,
58+
extends Omit<AriaCalendarProps<T>, 'visibleDuration' | 'style' | 'className' | 'render' | 'styles' | 'children' | keyof GlobalDOMAttributes>,
5959
StyleProps {
6060
/**
6161
* The error message to display when the calendar is invalid.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ interface CardRenderProps {
3636
size: 'XS' | 'S' | 'M' | 'L' | 'XL'
3737
}
3838

39-
export interface CardProps extends Omit<GridListItemProps, 'className' | 'style' | 'children' | 'onHoverChange' | 'onHoverStart' | 'onHoverEnd' | 'onClick' | keyof GlobalDOMAttributes>, StyleProps {
39+
export interface CardProps extends Omit<GridListItemProps, 'className' | 'style' | 'render' | 'children' | 'onHoverChange' | 'onHoverStart' | 'onHoverEnd' | 'onClick' | keyof GlobalDOMAttributes>, StyleProps {
4040
/** The children of the Card. */
4141
children: ReactNode | ((renderProps: CardRenderProps) => ReactNode),
4242
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {useDOMRef} from '@react-spectrum/utils';
3434
import {useEffectEvent, useLayoutEffect, useResizeObserver} from '@react-aria/utils';
3535
import {useSpectrumContextProps} from './useSpectrumContextProps';
3636

37-
export interface CardViewProps<T> extends Omit<GridListProps<T>, 'layout' | 'keyboardNavigationBehavior' | 'selectionBehavior' | 'className' | 'style' | 'isLoading' | keyof GlobalDOMAttributes>, UnsafeStyles {
37+
export interface CardViewProps<T> extends Omit<GridListProps<T>, 'layout' | 'keyboardNavigationBehavior' | 'selectionBehavior' | 'className' | 'style' | 'render' | 'isLoading' | keyof GlobalDOMAttributes>, UnsafeStyles {
3838
/**
3939
* The layout of the cards.
4040
* @default 'grid'

0 commit comments

Comments
 (0)