@fluentui/react-utilities
Advanced tools
Comparing version 9.0.0-alpha.10 to 9.0.0-alpha.11
@@ -5,3 +5,18 @@ { | ||
{ | ||
"date": "Tue, 23 Mar 2021 07:29:14 GMT", | ||
"date": "Thu, 25 Mar 2021 07:29:52 GMT", | ||
"tag": "@fluentui/react-utilities_v9.0.0-alpha.11", | ||
"version": "9.0.0-alpha.11", | ||
"comments": { | ||
"prerelease": [ | ||
{ | ||
"comment": "Move descendants to react-utilities", | ||
"author": "lingfan.gao@microsoft.com", | ||
"commit": "31b7b0d625e40f818d33c5df0890b584caaf0e6c", | ||
"package": "@fluentui/react-utilities" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Tue, 23 Mar 2021 07:31:43 GMT", | ||
"tag": "@fluentui/react-utilities_v9.0.0-alpha.10", | ||
@@ -8,0 +23,0 @@ "version": "9.0.0-alpha.10", |
# Change Log - @fluentui/react-utilities | ||
This log was last generated on Tue, 23 Mar 2021 07:29:14 GMT and should not be manually modified. | ||
This log was last generated on Thu, 25 Mar 2021 07:29:52 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## [9.0.0-alpha.11](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.0.0-alpha.11) | ||
Thu, 25 Mar 2021 07:29:52 GMT | ||
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.0.0-alpha.10..@fluentui/react-utilities_v9.0.0-alpha.11) | ||
### Changes | ||
- Move descendants to react-utilities ([PR #17528](https://github.com/microsoft/fluentui/pull/17528) by lingfan.gao@microsoft.com) | ||
## [9.0.0-alpha.10](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.0.0-alpha.10) | ||
Tue, 23 Mar 2021 07:29:14 GMT | ||
Tue, 23 Mar 2021 07:31:43 GMT | ||
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.0.0-alpha.9..@fluentui/react-utilities_v9.0.0-alpha.10) | ||
@@ -11,0 +20,0 @@ |
@@ -59,2 +59,6 @@ import * as React from 'react'; | ||
export declare function createDescendantContext<DescendantType extends Descendant>(name: string, initialValue?: {}): React.Context<DescendantContextValue<DescendantType>>; | ||
export declare function createNamedContext<ContextValueType>(name: string, defaultValue: ContextValueType): React.Context<ContextValueType>; | ||
/** | ||
@@ -65,2 +69,20 @@ * Default value can be a value or an initializer | ||
export declare type Descendant<ElementType = HTMLElement> = { | ||
element: SomeElement<ElementType> | null; | ||
index: number; | ||
}; | ||
export declare interface DescendantContextValue<DescendantType extends Descendant> { | ||
descendants: DescendantType[]; | ||
registerDescendant(descendant: DescendantType): void; | ||
unregisterDescendant(element: DescendantType['element']): void; | ||
} | ||
export declare const DescendantProvider: <DescendantType extends Descendant<HTMLElement>>({ context: Ctx, children, items, set, }: { | ||
context: React.Context<DescendantContextValue<DescendantType>>; | ||
children: React.ReactNode; | ||
items: DescendantType[]; | ||
set: React.Dispatch<React.SetStateAction<DescendantType[]>>; | ||
}) => JSX.Element; | ||
/** | ||
@@ -261,2 +283,4 @@ * An array of DIV tag properties and events. | ||
declare type SomeElement<T> = T extends Element ? T : HTMLElement; | ||
/** | ||
@@ -345,2 +369,52 @@ * An array of TABLE tag properties and events. | ||
/** | ||
* This hook registers our descendant by passing it into an array. We can then | ||
* search that array by to find its index when registering it in the component. | ||
* We use this for focus management, keyboard navigation, and typeahead | ||
* functionality for some components. | ||
* | ||
* The hook accepts the element node and (optionally) a key. The key is useful | ||
* if multiple descendants have identical text values and we need to | ||
* differentiate siblings for some reason. | ||
* | ||
* Our main goals with this are: | ||
* 1) maximum composability, | ||
* 2) minimal API friction | ||
* 3) SSR compatibility* | ||
* 4) concurrent safe | ||
* 5) index always up-to-date with the tree despite changes | ||
* 6) works with memoization of any component in the tree (hopefully) | ||
* | ||
* * As for SSR, the good news is that we don't actually need the index on the | ||
* server for most use-cases, as we are only using it to determine the order of | ||
* composed descendants for keyboard navigation. However, in the few cases where | ||
* this is not the case, we can require an explicit index from the app. | ||
*/ | ||
export declare function useDescendant<DescendantType extends Descendant>(descendant: Omit<DescendantType, 'index'>, context: React.Context<DescendantContextValue<DescendantType>>, indexProp?: number): number; | ||
/** | ||
* Testing this as an abstraction for compound components that use keyboard | ||
* navigation. Hoping this will help us prevent bugs and mismatched behavior | ||
* across various components, but it may also prove to be too messy of an | ||
* abstraction in the end. | ||
* | ||
* Currently used in: | ||
* - Tabs | ||
* - Accordion | ||
* | ||
*/ | ||
export declare function useDescendantKeyDown<DescendantType extends Descendant, K extends keyof DescendantType = keyof DescendantType>(context: React.Context<DescendantContextValue<DescendantType>>, options: { | ||
currentIndex: number | null | undefined; | ||
key?: K | 'option'; | ||
filter?: (descendant: DescendantType) => boolean; | ||
orientation?: 'vertical' | 'horizontal' | 'both'; | ||
rotate?: boolean; | ||
rtl?: boolean; | ||
callback(nextOption: DescendantType | DescendantType[K]): void; | ||
}): (event: React.KeyboardEvent<Element>) => void; | ||
export declare function useDescendants<DescendantType extends Descendant>(ctx: React.Context<DescendantContextValue<DescendantType>>): DescendantType[]; | ||
export declare function useDescendantsInit<DescendantType extends Descendant>(): [DescendantType[], React.Dispatch<React.SetStateAction<DescendantType[]>>]; | ||
/** | ||
* https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback | ||
@@ -372,2 +446,7 @@ * | ||
/** | ||
* Forces a re-render, similar to `forceUpdate` in class components. | ||
*/ | ||
export declare function useForceUpdate(): () => void; | ||
/** | ||
* Hook to generate a unique ID in the global scope (spanning across duplicate copies of the same library). | ||
@@ -412,2 +491,4 @@ * | ||
export declare function usePrevious<ValueType = unknown>(value: ValueType): ValueType | null; | ||
/** | ||
@@ -414,0 +495,0 @@ * An array of VIDEO tag properties and events. |
@@ -52,2 +52,32 @@ ## API Report File for "@fluentui/react-utilities" | ||
// @public (undocumented) | ||
export function createDescendantContext<DescendantType extends Descendant>(name: string, initialValue?: {}): React.Context<DescendantContextValue<DescendantType>>; | ||
// @public (undocumented) | ||
export function createNamedContext<ContextValueType>(name: string, defaultValue: ContextValueType): React.Context<ContextValueType>; | ||
// @public (undocumented) | ||
export type Descendant<ElementType = HTMLElement> = { | ||
element: SomeElement<ElementType> | null; | ||
index: number; | ||
}; | ||
// @public (undocumented) | ||
export interface DescendantContextValue<DescendantType extends Descendant> { | ||
// (undocumented) | ||
descendants: DescendantType[]; | ||
// (undocumented) | ||
registerDescendant(descendant: DescendantType): void; | ||
// (undocumented) | ||
unregisterDescendant(element: DescendantType['element']): void; | ||
} | ||
// @public (undocumented) | ||
export const DescendantProvider: <DescendantType extends Descendant<HTMLElement>>({ context: Ctx, children, items, set, }: { | ||
context: React.Context<DescendantContextValue<DescendantType>>; | ||
children: React.ReactNode; | ||
items: DescendantType[]; | ||
set: React.Dispatch<React.SetStateAction<DescendantType[]>>; | ||
}) => JSX.Element; | ||
// @public | ||
@@ -181,2 +211,22 @@ export const divProperties: Record<string, number>; | ||
// @public | ||
export function useDescendant<DescendantType extends Descendant>(descendant: Omit<DescendantType, 'index'>, context: React.Context<DescendantContextValue<DescendantType>>, indexProp?: number): number; | ||
// @public | ||
export function useDescendantKeyDown<DescendantType extends Descendant, K extends keyof DescendantType = keyof DescendantType>(context: React.Context<DescendantContextValue<DescendantType>>, options: { | ||
currentIndex: number | null | undefined; | ||
key?: K | 'option'; | ||
filter?: (descendant: DescendantType) => boolean; | ||
orientation?: 'vertical' | 'horizontal' | 'both'; | ||
rotate?: boolean; | ||
rtl?: boolean; | ||
callback(nextOption: DescendantType | DescendantType[K]): void; | ||
}): (event: React.KeyboardEvent<Element>) => void; | ||
// @public (undocumented) | ||
export function useDescendants<DescendantType extends Descendant>(ctx: React.Context<DescendantContextValue<DescendantType>>): DescendantType[]; | ||
// @public (undocumented) | ||
export function useDescendantsInit<DescendantType extends Descendant>(): [DescendantType[], React.Dispatch<React.SetStateAction<DescendantType[]>>]; | ||
// @public | ||
export const useEventCallback: <Args extends unknown[], Return>(fn: (...args: Args) => Return) => (...args: Args) => Return; | ||
@@ -188,2 +238,5 @@ | ||
// @public | ||
export function useForceUpdate(): () => void; | ||
// @public | ||
export function useId(prefix?: string, providedId?: string): string; | ||
@@ -207,2 +260,5 @@ | ||
// @public (undocumented) | ||
export function usePrevious<ValueType = unknown>(value: ValueType): ValueType | null; | ||
// @public | ||
@@ -212,4 +268,8 @@ export const videoProperties: Record<string, number>; | ||
// Warnings were encountered during analysis: | ||
// | ||
// lib/descendants/descendants.d.ts:64:5 - (ae-forgotten-export) The symbol "SomeElement" needs to be exported by the entry point index.d.ts | ||
// (No @packageDocumentation comment for this package) | ||
``` |
export * from './compose/index'; | ||
export * from './descendants/index'; | ||
export * from './hooks/index'; | ||
export * from './utils/index'; |
@@ -1,2 +0,2 @@ | ||
define(["require", "exports", "tslib", "./compose/index", "./hooks/index", "./utils/index"], function (require, exports, tslib_1, index_1, index_2, index_3) { | ||
define(["require", "exports", "tslib", "./compose/index", "./descendants/index", "./hooks/index", "./utils/index"], function (require, exports, tslib_1, index_1, index_2, index_3, index_4) { | ||
"use strict"; | ||
@@ -7,3 +7,4 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
tslib_1.__exportStar(index_3, exports); | ||
tslib_1.__exportStar(index_4, exports); | ||
}); | ||
//# sourceMappingURL=index.js.map |
export * from './compose/index'; | ||
export * from './descendants/index'; | ||
export * from './hooks/index'; | ||
export * from './utils/index'; |
@@ -5,4 +5,5 @@ "use strict"; | ||
tslib_1.__exportStar(require("./compose/index"), exports); | ||
tslib_1.__exportStar(require("./descendants/index"), exports); | ||
tslib_1.__exportStar(require("./hooks/index"), exports); | ||
tslib_1.__exportStar(require("./utils/index"), exports); | ||
//# sourceMappingURL=index.js.map |
export * from './compose/index'; | ||
export * from './descendants/index'; | ||
export * from './hooks/index'; | ||
export * from './utils/index'; |
export * from './compose/index'; | ||
export * from './descendants/index'; | ||
export * from './hooks/index'; | ||
export * from './utils/index'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@fluentui/react-utilities", | ||
"version": "9.0.0-alpha.10", | ||
"version": "9.0.0-alpha.11", | ||
"description": "A set of general React-specific utilities.", | ||
@@ -5,0 +5,0 @@ "main": "lib-commonjs/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
531730
229
6355