Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Mark teams-prg owned APIs with @internal #23689

Merged
merged 3 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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": "prerelease",
"comment": "chore: Mark internal APIs with @internal",
"packageName": "@fluentui/priority-overflow",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "chore: Mark internal APIs with @internal",
"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": "chore: Mark teams-prg owned APIs with @internal",
"packageName": "@fluentui/react-context-selector",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "chore: Mark teams-prg owned APIs with @internal",
"packageName": "@fluentui/react-overflow",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "chore: Mark teams-prg owned APIs with @internal",
"packageName": "@fluentui/react-positioning",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "chore: Mark teams-prg owned APIs with @internal",
"packageName": "@fluentui/react-shared-contexts",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "chore: Mark teams-prg owned APIs with @internal",
"packageName": "@fluentui/react-tabster",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "chore: Mark teams-prg owned APIs with @internal",
"packageName": "@fluentui/react-utilities",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createPriorityQueue } from './priorityQueue';
import type { OverflowGroupState, OverflowItemEntry, OverflowManager, ObserveOptions } from './types';

/**
* @internal
* @returns overflow manager instance
*/
export function createOverflowManager(): OverflowManager {
Expand Down
3 changes: 3 additions & 0 deletions packages/react-components/priority-overflow/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export interface ObserveOptions {
onUpdateOverflow: OnUpdateOverflow;
}

/**
* @internal
*/
export interface OverflowManager {
/**
* Starts observing the container and managing the overflow state
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
* @internal
* Merges disabled declaration with `aria-disabled`
*/
export function mergeARIADisabled(shorthand: { 'aria-disabled'?: string | boolean; disabled?: boolean }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const createProvider = <Value>(Original: React.Provider<ContextValue<Value>>) =>
return (Provider as unknown) as React.Provider<ContextValue<Value>>;
};

/**
* @internal
*/
export const createContext = <Value>(defaultValue: Value): Context<Value> => {
const context = React.createContext<ContextValue<Value>>({
value: { current: defaultValue },
Expand Down
15 changes: 15 additions & 0 deletions packages/react-components/react-context-selector/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import * as React from 'react';

/**
* @internal
*/
export type Context<Value> = React.Context<Value> & {
Provider: React.FC<React.ProviderProps<Value>>;
Consumer: never;
};

/**
* @internal
*/
export type ContextSelector<Value, SelectedValue> = (value: Value) => SelectedValue;

/**
* @internal
*/
export type ContextVersion = number;

/**
* @internal
*/
export type ContextValue<Value> = {
/** Holds a set of subscribers from components. */
listeners: ((payload: readonly [ContextVersion, Value]) => void)[];
Expand All @@ -20,6 +32,9 @@ export type ContextValue<Value> = {
version: React.MutableRefObject<ContextVersion>;
};

/**
* @internal
*/
export type ContextValues<Value> = ContextValue<Value> & {
/** List of listners to publish changes */
listeners: ((payload: readonly [ContextVersion, Record<string, Value>]) => void)[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type ContextReducer<Value, SelectedValue> = React.Reducer<
>;

/**
* @internal
* This hook returns context selected value by selector.
* It will only accept context created by `createContext`.
* It will trigger re-render if only the selected value is referencially changed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import { Context, ContextValue } from './types';

/**
* @internal
* Utility hook for contexts created by react-context-selector to determine if a parent context exists
* WARNING: This hook will not work for native React contexts
*
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/react-overflow/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export { DATA_OVERFLOWING, DATA_OVERFLOW_ITEM, DATA_OVERFLOW_MENU } from './cons
export type { UseOverflowContainerReturn } from './types';
export { useIsOverflowGroupVisible } from './useIsOverflowGroupVisible';
export { useIsOverflowItemVisible } from './useIsOverflowItemVisible';
export { updateVisibilityAttribute, useOverflowContainer } from './useOverflowContainer';
export { useOverflowContainer } from './useOverflowContainer';
export { useOverflowCount } from './useOverflowCount';
export { useOverflowItem } from './useOverflowItem';
export { useOverflowMenu } from './useOverflowMenu';
Expand Down
3 changes: 3 additions & 0 deletions packages/react-components/react-overflow/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as React from 'react';
import { OverflowContextValue } from './overflowContext';

/**
* @internal
*/
export interface UseOverflowContainerReturn<TElement extends HTMLElement> {
/**
* Ref to apply to the container that will overflow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as React from 'react';
import { createOverflowManager } from '@fluentui/priority-overflow';

/**
* @internal
*/
import type {
OnUpdateItemVisibility,
OnUpdateOverflow,
Expand All @@ -13,7 +16,7 @@ import { UseOverflowContainerReturn } from './types';
import { DATA_OVERFLOWING, DATA_OVERFLOW_ITEM } from './constants';

/**
*
* @internal
* @param update - Callback when overflow state changes
* @param options - Options to configure the overflow container
* @returns - ref to attach to an intrinsic HTML element and imperative functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
import { useOverflowContext } from './overflowContext';

/**
* @internal
* Registers an overflow item
* @param id - unique identifier for the item used by the overflow manager
* @param priority - higher priority means the item overflows later
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { tokens } from '@fluentui/react-theme';
import type { GriffelStyle } from '@griffel/react';

/**
* @internal
* Options parameter for the createArrowStyles function
*/
export type CreateArrowStylesOptions = {
Expand Down Expand Up @@ -37,6 +38,7 @@ export type CreateArrowStylesOptions = {
};

/**
* @internal
* Helper that creates a makeStyles rule for an arrow element.
* For runtime arrow size toggling simply create extra classnames to apply to the arrow element
*
Expand Down Expand Up @@ -113,6 +115,7 @@ export function createArrowStyles(options: CreateArrowStylesOptions): GriffelSty
}

/**
* @internal
* Creates CSS styles to size the arrow created by createArrowStyles to the given height.
*
* Use this when you need to create classes for several different arrow sizes. If you only need a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ function usePopperOptions(options: PositioningOptions, popperOriginalPositionRef
}

/**
* @internal
* Exposes Popper positioning API via React hook. Contains few important differences between an official "react-popper"
* package:
* - style attributes are applied directly on DOM to avoid re-renders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createVirtualElementFromClick } from './createVirtualElementFromClick';
import { PositioningVirtualElement } from './types';

/**
* @internal
* A state hook that manages a popper virtual element from mouseevents.
* Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)
* React synthetic events are not persisted by this hook
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Offset, OffsetObject } from '../types';

/**
* @internal
* Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the
* height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ export type ProviderContextValue = {
targetDocument?: Document;
};

/**
* @internal
*/
const ProviderContext = React.createContext<ProviderContextValue>({
targetDocument: typeof document === 'object' ? document : undefined,
dir: 'ltr',
});

export const { Provider } = ProviderContext;
/**
* @internal
*/
export const Provider = ProviderContext.Provider;

export function useFluent(): ProviderContextValue {
return React.useContext(ProviderContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import * as React from 'react';
export type ThemeClassNameContextValue = string;

/**
* @internal
* Used to provide a CSS class that applies theme css variables
*
* Useful for elements in the React tree (can read context) but not in the DOM Tree. E.g. Portals
*/
const ThemeClassNameContext = React.createContext<ThemeClassNameContextValue>('');

export const { Provider: ThemeClassNameProvider } = ThemeClassNameContext;
export const ThemeClassNameProvider = ThemeClassNameContext.Provider;

/**
* @internal
* @returns CSS class that applies css variables
*/
export function useThemeClassName(): ThemeClassNameContextValue {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import * as React from 'react';
import type { Theme } from '@fluentui/react-theme';

/**
* @internal
*/
export type ThemeContextValue = Theme | Partial<Theme> | undefined;

/**
* @internal
*/
export const ThemeContext = React.createContext<ThemeContextValue>(undefined);

export const { Provider: ThemeProvider } = ThemeContext;
/**
* @internal
*/
export const ThemeProvider = ThemeContext.Provider;
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';

/**
* @internal
* The context provided by TooltipProvider
*/
export type TooltipVisibilityContextValue = {
Expand All @@ -14,12 +15,19 @@ export type TooltipVisibilityContextValue = {
};

/**
* @internal
* Context shared by all of the tooltips in the app
*/
const TooltipVisibilityContext = React.createContext<TooltipVisibilityContextValue>({});

export const { Provider: TooltipVisibilityProvider } = TooltipVisibilityContext;
/**
* @internal
*/
export const TooltipVisibilityProvider = TooltipVisibilityContext.Provider;

/**
* @internal
*/
export function useTooltipVisibility(): TooltipVisibilityContextValue {
return React.useContext(TooltipVisibilityContext);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getTabsterAttribute, Types as TabsterTypes } from 'tabster';
import { useTabster } from './useTabster';

/**
* @internal
* Hook that returns tabster attributes while ensuring tabster exists
*/
export const useTabsterAttributes = (props: TabsterTypes.TabsterAttributeProps): TabsterTypes.TabsterDOMAttribute => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as React from 'react';

/**
* @internal
*/
export type UseControllableStateOptions<State> = {
/**
* User-provided default state or initializer, for uncontrolled usage.
Expand All @@ -21,6 +24,8 @@ function isFactoryDispatch<State>(newState: React.SetStateAction<State>): newSta
}

/**
* @internal
*
* A `useState`-like hook to manage a value that could be either controlled or uncontrolled,
* such as a checked state or text input string.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';

/**
* @internal
* https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
*
* Modified `useCallback` that can be used when dependencies change too frequently. Can occur when
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';

/**
* @internal
* Checks if components was mounted the first time.
* Since concurrent mode will be released in the future this needs to be verified
* Currently (React 17) will always render the initial mount once
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useReducer } from 'react';

/**
* @internal
* Forces a re-render, similar to `forceUpdate` in class components.
*/
export function useForceUpdate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { defaultSSRContextValue, useSSRContext } from '../ssr/index';

/**
* Resets generated IDs, should be used only in tests.
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is no longer internal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be internal actually, because in order to have deterministic ids in unit tests, users will need to invoke this utility

* @private
*/
export function resetIdsForTests(): void {
defaultSSRContextValue.current = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import { canUseDOM } from '../ssr/index';

/**
* @internal
* React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally
* useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to
* ensure we don't get a render flash for certain operations, but we may also need affected components to render on
Expand Down
Loading