Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
1ebbff4
getSlots: infer slot names from state.components
behowell Dec 28, 2021
ece07de
Remove (component)ShorthandProps arrays
behowell Dec 29, 2021
018163f
Change files
behowell Dec 29, 2021
39bc103
Update comment for components state prop
behowell Dec 29, 2021
00718ea
Fix getSlots tests
behowell Dec 29, 2021
f127e6e
Tweak getSlots tests
behowell Dec 29, 2021
e88065e
Fix ARIA button stories
behowell Dec 29, 2021
531aaaa
Clean up formatting of components with just root
behowell Dec 29, 2021
702a71a
Revert "Clean up formatting of components with just root"
behowell Dec 29, 2021
ebe6a64
Merge branch 'master' of https://github.com/microsoft/fluentui into g…
behowell Dec 30, 2021
5860fe5
Merge branch 'master' of https://github.com/microsoft/fluentui into g…
behowell Jan 3, 2022
d1cfb63
Remove Dialog's shorthandProps array
behowell Jan 3, 2022
8f3f1d8
Remove yarn change from private react-tabs package
behowell Jan 3, 2022
68cf21e
Revert "Remove yarn change from private react-tabs package"
behowell Jan 3, 2022
44017f5
Merge branch 'master' of https://github.com/microsoft/fluentui into g…
behowell Jan 4, 2022
c92fe13
Merge branch 'master' of https://github.com/microsoft/fluentui into g…
behowell Jan 6, 2022
4878447
Change files
behowell Jan 6, 2022
9d794d9
Merge branch 'master' of https://github.com/microsoft/fluentui into g…
behowell Jan 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-accordion",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-aria",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-avatar",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-badge",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-button",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-card",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-checkbox",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove components' shorthandProps array exports",
"packageName": "@fluentui/react-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-divider",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-image",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-input",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-label",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-link",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-menu",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-popover",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-provider",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-slider",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-switch",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove component's shorthandProps array",
"packageName": "@fluentui/react-tooltip",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "getSlots: remove slotNames param, and infer from state.components instead",
"packageName": "@fluentui/react-utilities",
"email": "[email protected]",
"dependentChangeType": "patch"
}
12 changes: 0 additions & 12 deletions packages/react-accordion/etc/react-accordion.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ export type AccordionHeaderExpandIconProps = IntrinsicShorthandProps<'span'>;
// @public (undocumented)
export type AccordionHeaderProps = ComponentProps<AccordionHeaderSlots> & Partial<AccordionHeaderCommons>;

// @public
export const accordionHeaderShorthandProps: Array<keyof AccordionHeaderSlots>;

// @public (undocumented)
export type AccordionHeaderSize = 'small' | 'medium' | 'large' | 'extra-large';

Expand Down Expand Up @@ -128,9 +125,6 @@ export type AccordionItemContextValues = {
// @public (undocumented)
export type AccordionItemProps = ComponentProps<AccordionItemSlots> & Partial<AccordionItemCommons> & Pick<AccordionItemCommons, 'value'>;

// @public
export const accordionItemShorthandProps: Array<keyof AccordionItemSlots>;

// @public (undocumented)
export type AccordionItemSlots = {
root: IntrinsicShorthandProps<'div'>;
Expand All @@ -151,9 +145,6 @@ export const accordionPanelClassName = "fui-AccordionPanel";
// @public (undocumented)
export type AccordionPanelProps = ComponentProps<AccordionPanelSlots>;

// @public
export const accordionPanelShorthandProps: Array<keyof AccordionPanelSlots>;

// @public (undocumented)
export type AccordionPanelSlots = {
root: IntrinsicShorthandProps<'div'>;
Expand All @@ -171,9 +162,6 @@ export type AccordionProps = ComponentProps<AccordionSlots> & Partial<AccordionC
onToggle?: AccordionToggleEventHandler;
};

// @public (undocumented)
export const accordionShorthandProps: Array<keyof AccordionSlots>;

// @public (undocumented)
export type AccordionSlots = {
root: IntrinsicShorthandProps<'div'>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import * as React from 'react';
import { getNativeElementProps, useControllableState, useEventCallback } from '@fluentui/react-utilities';
import type {
AccordionProps,
AccordionSlots,
AccordionState,
AccordionToggleData,
AccordionToggleEvent,
} from './Accordion.types';
import type { AccordionProps, AccordionState, AccordionToggleData, AccordionToggleEvent } from './Accordion.types';
import type { AccordionItemValue } from '../AccordionItem/AccordionItem.types';

export const accordionShorthandProps: Array<keyof AccordionSlots> = ['root'];

/**
* Returns the props and state required to render the component
* @param props - Accordion properties
Expand Down Expand Up @@ -47,6 +39,9 @@ export const useAccordion = (props: AccordionProps, ref: React.Ref<HTMLElement>)
navigable,
openItems,
requestToggle,
components: {
root: 'div',
},
root: getNativeElementProps('div', {
...props,
ref,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import * as React from 'react';
import { getSlots } from '@fluentui/react-utilities';
import { accordionHeaderShorthandProps } from './useAccordionHeader';
import { AccordionHeaderContext } from './AccordionHeaderContext';
import type { AccordionHeaderState, AccordionHeaderSlots, AccordionHeaderContextValues } from './AccordionHeader.types';

/**
* Function that renders the final JSX of the component
*/
export const renderAccordionHeader = (state: AccordionHeaderState, contextValues: AccordionHeaderContextValues) => {
const { slots, slotProps } = getSlots<AccordionHeaderSlots>(state, accordionHeaderShorthandProps);
const { slots, slotProps } = getSlots<AccordionHeaderSlots>(state);

return (
<AccordionHeaderContext.Provider value={contextValues.accordionHeader}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ import type { AccordionHeaderProps, AccordionHeaderState, AccordionHeaderSlots }
import { useContextSelector } from '@fluentui/react-context-selector';
import { AccordionContext } from '../Accordion/AccordionContext';

/**
* Const listing which props are shorthand props.
*/
export const accordionHeaderShorthandProps: Array<keyof AccordionHeaderSlots> = [
'root',
'icon',
'button',
'children',
'expandIcon',
];

/**
* Returns the props and state required to render the component
* @param props - AccordionHeader properties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import * as React from 'react';
import { getSlots } from '@fluentui/react-utilities';
import { accordionItemShorthandProps } from './useAccordionItem';
import { AccordionItemContext } from './AccordionItemContext';
import type { AccordionItemState, AccordionItemSlots, AccordionItemContextValues } from './AccordionItem.types';

/**
* Function that renders the final JSX of the component
*/
export const renderAccordionItem = (state: AccordionItemState, contextValues: AccordionItemContextValues) => {
const { slots, slotProps } = getSlots<AccordionItemSlots>(state, accordionItemShorthandProps);
const { slots, slotProps } = getSlots<AccordionItemSlots>(state);

return (
<slots.root {...slotProps.root}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ import { getNativeElementProps } from '@fluentui/react-utilities';
import { useTabsterAttributes } from '@fluentui/react-tabster';
import { useContextSelector } from '@fluentui/react-context-selector';
import { AccordionContext } from '../Accordion/AccordionContext';
import type { AccordionItemProps, AccordionItemState, AccordionItemSlots } from './AccordionItem.types';
import type { AccordionItemProps, AccordionItemState } from './AccordionItem.types';
import type { AccordionToggleEvent } from '../Accordion/Accordion.types';

/**
* Const listing which props are shorthand props.
*/
export const accordionItemShorthandProps: Array<keyof AccordionItemSlots> = ['root'];

/**
* Returns the props and state required to render the component
* @param props - AccordionItem properties
Expand All @@ -35,6 +30,9 @@ export const useAccordionItem = (props: AccordionItemProps, ref: React.Ref<HTMLE
value,
disabled,
onHeaderClick: onAccordionHeaderClick,
components: {
root: 'div',
},
root: getNativeElementProps('div', {
ref: ref,
...(navigable ? tabsterAttributes : {}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import * as React from 'react';
import { getSlots } from '@fluentui/react-utilities';
import { accordionPanelShorthandProps } from './useAccordionPanel';
import type { AccordionPanelState, AccordionPanelSlots } from './AccordionPanel.types';

/**
* Function that renders the final JSX of the component
*/
export const renderAccordionPanel = (state: AccordionPanelState) => {
const { slots, slotProps } = getSlots<AccordionPanelSlots>(state, accordionPanelShorthandProps);
const { slots, slotProps } = getSlots<AccordionPanelSlots>(state);
return state.open ? <slots.root {...slotProps.root}>{slotProps.root.children}</slots.root> : null;
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import * as React from 'react';
import { getNativeElementProps } from '@fluentui/react-utilities';
import { useAccordionItemContext } from '../AccordionItem/index';
import type { AccordionPanelProps, AccordionPanelSlots, AccordionPanelState } from './AccordionPanel.types';

/**
* Const listing which props are shorthand props.
*/
export const accordionPanelShorthandProps: Array<keyof AccordionPanelSlots> = ['root'];
import type { AccordionPanelProps, AccordionPanelState } from './AccordionPanel.types';

/**
* Returns the props and state required to render the component
Expand All @@ -17,6 +12,9 @@ export const useAccordionPanel = (props: AccordionPanelProps, ref: React.Ref<HTM
const { open } = useAccordionItemContext();
return {
open,
components: {
root: 'div',
},
root: getNativeElementProps('div', {
ref,
role: 'region',
Expand Down
11 changes: 9 additions & 2 deletions packages/react-aria/src/hooks/useARIAButton.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ interface DefaultArgs {

export const Default = (args: DefaultArgs) => {
const state: State = {
components: { root: 'div', button: 'button' },
root: {},
button: {
...useARIAButton({ as: 'button', onClick: args.onClick }, { required: true }),
children: React.Fragment,
},
};
const { slots, slotProps } = getSlots<Slots>(state, ['button', 'root']);
const { slots, slotProps } = getSlots<Slots>(state);
return (
<slots.root {...slotProps.root}>
<slots.button {...slotProps.button}>this is a button</slots.button>
Expand All @@ -32,6 +33,9 @@ export const Default = (args: DefaultArgs) => {
};

export const Anchor = (args: DefaultArgs) => {
type AnchorSlots = {
root: ARIAButtonShorthandProps;
};
const props = useARIAButton(
{
as: 'a',
Expand All @@ -43,7 +47,10 @@ export const Anchor = (args: DefaultArgs) => {
},
{ required: true },
);
const { slots, slotProps } = getSlots({ root: props }, ['root']);
const { slots, slotProps } = getSlots<AnchorSlots>({
components: { root: 'a' },
root: props,
});
return <slots.root {...slotProps.root}>this is an anchor</slots.root>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getSlots } from '@fluentui/react-utilities';
import type { AvatarSlots, AvatarState } from './Avatar.types';

export const renderAvatar = (state: AvatarState) => {
const { slots, slotProps } = getSlots<AvatarSlots>(state, ['root', 'label', 'image', 'badge', 'icon']);
const { slots, slotProps } = getSlots<AvatarSlots>(state);

return (
<slots.root {...slotProps.root}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getSlots } from '@fluentui/react-utilities';
import type { BadgeState, BadgeSlots } from './Badge.types';

export const renderBadge = (state: BadgeState) => {
const { slots, slotProps } = getSlots<BadgeSlots>(state, ['icon', 'root']);
const { slots, slotProps } = getSlots<BadgeSlots>(state);

return (
<slots.root {...slotProps.root}>
Expand Down
Loading