Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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": "minor",
"comment": "feat: add base hooks for Switch",
"packageName": "@fluentui/react-switch",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ import type { Slot } from '@fluentui/react-utilities';
import type { SlotClassNames } from '@fluentui/react-utilities';

// @public
export const renderSwitch_unstable: (state: SwitchState) => JSXElement;
export const renderSwitch_unstable: (state: SwitchBaseState) => JSXElement;

// @public
export const Switch: ForwardRefComponent<SwitchProps>;

// @public
export type SwitchBaseProps = Omit<SwitchProps, 'size'>;

// @public
export type SwitchBaseState = Omit<SwitchState, 'size'>;

// @public @deprecated (undocumented)
export const switchClassName: string;

Expand Down Expand Up @@ -54,6 +60,9 @@ export type SwitchState = ComponentState<SwitchSlots> & Required<Pick<SwitchProp
// @public
export const useSwitch_unstable: (props: SwitchProps, ref: React_2.Ref<HTMLInputElement>) => SwitchState;

// @public
export const useSwitchBase_unstable: (props: SwitchBaseProps, ref?: React_2.Ref<HTMLInputElement>) => SwitchBaseState;

// @public
export const useSwitchStyles_unstable: (state: SwitchState) => SwitchState;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import { assertSlots } from '@fluentui/react-utilities';
import type { JSXElement } from '@fluentui/react-utilities';
import type { SwitchState, SwitchSlots } from './Switch.types';
import type { SwitchBaseState, SwitchSlots } from './Switch.types';

/**
* Render a Switch component by passing the state defined props to the appropriate slots.
*/
export const renderSwitch_unstable = (state: SwitchState): JSXElement => {
export const renderSwitch_unstable = (state: SwitchBaseState): JSXElement => {
assertSlots<SwitchSlots>(state);
const { labelPosition } = state;

Expand Down
14 changes: 9 additions & 5 deletions packages/react-components/react-switch/library/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ export {
switchClassNames,
useSwitchStyles_unstable,
useSwitch_unstable,
useSwitchBase_unstable,
} from './Switch';
export type {
SwitchOnChangeData,
SwitchProps,
SwitchSlots,
SwitchState,
SwitchBaseProps,
SwitchBaseState,
} from './Switch';
export type { SwitchOnChangeData, SwitchProps, SwitchSlots, SwitchState } from './Switch';

// Experimental APIs - will be uncommented in experimental branch
// export { useSwitchBase_unstable } from './Switch';
// export type { SwitchBaseProps, SwitchBaseState } from './Switch';
Loading