@fluentui/react-utilities 9.0.0-rc.8 → 9.0.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +114 -1
- package/CHANGELOG.md +47 -2
- package/dist/index.d.ts +31 -278
- package/{lib → dist}/tsdoc-metadata.json +0 -0
- package/lib/compose/getSlots.js.map +1 -1
- package/lib/compose/resolveShorthand.js.map +1 -1
- package/lib/compose/types.js.map +1 -1
- package/lib/hooks/index.js +0 -4
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useControllableState.js +3 -2
- package/lib/hooks/useControllableState.js.map +1 -1
- package/lib/hooks/useEventCallback.js +1 -0
- package/lib/hooks/useEventCallback.js.map +1 -1
- package/lib/hooks/useFirstMount.js +1 -0
- package/lib/hooks/useFirstMount.js.map +1 -1
- package/lib/hooks/useForceUpdate.js +1 -0
- package/lib/hooks/useForceUpdate.js.map +1 -1
- package/lib/hooks/useId.js +0 -2
- package/lib/hooks/useId.js.map +1 -1
- package/lib/hooks/useIsomorphicLayoutEffect.js +1 -0
- package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib/hooks/useMergedEventCallbacks.js +1 -0
- package/lib/hooks/useMergedEventCallbacks.js.map +1 -1
- package/lib/hooks/useMergedRefs.js +1 -0
- package/lib/hooks/useMergedRefs.js.map +1 -1
- package/lib/hooks/useOnClickOutside.js +2 -1
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/hooks/useOnScrollOutside.js +1 -0
- package/lib/hooks/useOnScrollOutside.js.map +1 -1
- package/lib/hooks/usePrevious.js +4 -0
- package/lib/hooks/usePrevious.js.map +1 -1
- package/lib/hooks/useTimeout.js +2 -2
- package/lib/hooks/useTimeout.js.map +1 -1
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/ssr/SSRContext.js +1 -1
- package/lib/ssr/SSRContext.js.map +1 -1
- package/lib/ssr/canUseDOM.js.map +1 -1
- package/lib/{utils → trigger}/applyTriggerPropsToChildren.js +1 -0
- package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -0
- package/lib/{utils → trigger}/getTriggerChild.js +2 -0
- package/lib/trigger/getTriggerChild.js.map +1 -0
- package/lib/trigger/index.js +5 -0
- package/lib/trigger/index.js.map +1 -0
- package/lib/{utils → trigger}/isFluentTrigger.js +0 -0
- package/lib/trigger/isFluentTrigger.js.map +1 -0
- package/lib/trigger/types.js +2 -0
- package/lib/trigger/types.js.map +1 -0
- package/lib/utils/clamp.js +1 -0
- package/lib/utils/clamp.js.map +1 -1
- package/lib/utils/getNativeElementProps.js.map +1 -1
- package/lib/utils/getRTLSafeKey.js +1 -0
- package/lib/utils/getRTLSafeKey.js.map +1 -1
- package/lib/utils/getReactCallbackName.js.map +1 -1
- package/lib/utils/index.js +0 -3
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/omit.js.map +1 -1
- package/lib/utils/properties.js +2 -6
- package/lib/utils/properties.js.map +1 -1
- package/lib/utils/shouldPreventDefaultOnKeyDown.js +1 -0
- package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
- package/lib-commonjs/compose/getSlots.js.map +1 -1
- package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
- package/lib-commonjs/hooks/index.js +0 -8
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useControllableState.js +3 -3
- package/lib-commonjs/hooks/useControllableState.js.map +1 -1
- package/lib-commonjs/hooks/useEventCallback.js +1 -0
- package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
- package/lib-commonjs/hooks/useFirstMount.js +1 -0
- package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
- package/lib-commonjs/hooks/useForceUpdate.js +1 -0
- package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
- package/lib-commonjs/hooks/useId.js +0 -2
- package/lib-commonjs/hooks/useId.js.map +1 -1
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +1 -0
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib-commonjs/hooks/useMergedEventCallbacks.js +1 -0
- package/lib-commonjs/hooks/useMergedEventCallbacks.js.map +1 -1
- package/lib-commonjs/hooks/useMergedRefs.js +1 -0
- package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
- package/lib-commonjs/hooks/useOnClickOutside.js +2 -1
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/hooks/useOnScrollOutside.js +1 -0
- package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
- package/lib-commonjs/hooks/usePrevious.js +4 -0
- package/lib-commonjs/hooks/usePrevious.js.map +1 -1
- package/lib-commonjs/hooks/useTimeout.js +2 -3
- package/lib-commonjs/hooks/useTimeout.js.map +1 -1
- package/lib-commonjs/index.js +8 -223
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/ssr/SSRContext.js +1 -1
- package/lib-commonjs/ssr/SSRContext.js.map +1 -1
- package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
- package/lib-commonjs/{utils → trigger}/applyTriggerPropsToChildren.js +1 -0
- package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -0
- package/lib-commonjs/{utils → trigger}/getTriggerChild.js +2 -0
- package/lib-commonjs/trigger/getTriggerChild.js.map +1 -0
- package/lib-commonjs/trigger/index.js +16 -0
- package/lib-commonjs/trigger/index.js.map +1 -0
- package/lib-commonjs/{utils → trigger}/isFluentTrigger.js +0 -0
- package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -0
- package/lib-commonjs/trigger/types.js +6 -0
- package/lib-commonjs/trigger/types.js.map +1 -0
- package/lib-commonjs/utils/clamp.js +1 -0
- package/lib-commonjs/utils/clamp.js.map +1 -1
- package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
- package/lib-commonjs/utils/getRTLSafeKey.js +1 -0
- package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
- package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
- package/lib-commonjs/utils/index.js +0 -6
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/omit.js.map +1 -1
- package/lib-commonjs/utils/properties.js +3 -7
- package/lib-commonjs/utils/properties.js.map +1 -1
- package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js +1 -0
- package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
- package/package.json +4 -7
- package/lib/compose/getSlots.d.ts +0 -30
- package/lib/compose/index.d.ts +0 -3
- package/lib/compose/resolveShorthand.d.ts +0 -16
- package/lib/compose/types.d.ts +0 -161
- package/lib/hooks/index.d.ts +0 -16
- package/lib/hooks/useBoolean.d.ts +0 -17
- package/lib/hooks/useBoolean.js +0 -28
- package/lib/hooks/useBoolean.js.map +0 -1
- package/lib/hooks/useConst.d.ts +0 -12
- package/lib/hooks/useConst.js +0 -30
- package/lib/hooks/useConst.js.map +0 -1
- package/lib/hooks/useControllableState.d.ts +0 -31
- package/lib/hooks/useEventCallback.d.ts +0 -13
- package/lib/hooks/useFirstMount.d.ts +0 -11
- package/lib/hooks/useForceUpdate.d.ts +0 -4
- package/lib/hooks/useId.d.ts +0 -15
- package/lib/hooks/useIsomorphicLayoutEffect.d.ts +0 -11
- package/lib/hooks/useMergedEventCallbacks.d.ts +0 -18
- package/lib/hooks/useMergedRefs.d.ts +0 -13
- package/lib/hooks/useMount.d.ts +0 -6
- package/lib/hooks/useMount.js +0 -17
- package/lib/hooks/useMount.js.map +0 -1
- package/lib/hooks/useOnClickOutside.d.ts +0 -29
- package/lib/hooks/useOnScrollOutside.d.ts +0 -5
- package/lib/hooks/usePrevious.d.ts +0 -1
- package/lib/hooks/useTimeout.d.ts +0 -8
- package/lib/hooks/useUnmount.d.ts +0 -6
- package/lib/hooks/useUnmount.js +0 -17
- package/lib/hooks/useUnmount.js.map +0 -1
- package/lib/index.d.ts +0 -8
- package/lib/ssr/SSRContext.d.ts +0 -33
- package/lib/ssr/canUseDOM.d.ts +0 -4
- package/lib/ssr/index.d.ts +0 -2
- package/lib/utils/applyTriggerPropsToChildren.d.ts +0 -5
- package/lib/utils/applyTriggerPropsToChildren.js.map +0 -1
- package/lib/utils/clamp.d.ts +0 -8
- package/lib/utils/getNativeElementProps.d.ts +0 -31
- package/lib/utils/getRTLSafeKey.d.ts +0 -4
- package/lib/utils/getReactCallbackName.d.ts +0 -25
- package/lib/utils/getTriggerChild.d.ts +0 -22
- package/lib/utils/getTriggerChild.js.map +0 -1
- package/lib/utils/index.d.ts +0 -9
- package/lib/utils/isFluentTrigger.d.ts +0 -22
- package/lib/utils/isFluentTrigger.js.map +0 -1
- package/lib/utils/omit.d.ts +0 -14
- package/lib/utils/properties.d.ts +0 -160
- package/lib/utils/shouldPreventDefaultOnKeyDown.d.ts +0 -7
- package/lib-commonjs/compose/getSlots.d.ts +0 -30
- package/lib-commonjs/compose/index.d.ts +0 -3
- package/lib-commonjs/compose/resolveShorthand.d.ts +0 -16
- package/lib-commonjs/compose/types.d.ts +0 -161
- package/lib-commonjs/hooks/index.d.ts +0 -16
- package/lib-commonjs/hooks/useBoolean.d.ts +0 -17
- package/lib-commonjs/hooks/useBoolean.js +0 -39
- package/lib-commonjs/hooks/useBoolean.js.map +0 -1
- package/lib-commonjs/hooks/useConst.d.ts +0 -12
- package/lib-commonjs/hooks/useConst.js +0 -40
- package/lib-commonjs/hooks/useConst.js.map +0 -1
- package/lib-commonjs/hooks/useControllableState.d.ts +0 -31
- package/lib-commonjs/hooks/useEventCallback.d.ts +0 -13
- package/lib-commonjs/hooks/useFirstMount.d.ts +0 -11
- package/lib-commonjs/hooks/useForceUpdate.d.ts +0 -4
- package/lib-commonjs/hooks/useId.d.ts +0 -15
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.d.ts +0 -11
- package/lib-commonjs/hooks/useMergedEventCallbacks.d.ts +0 -18
- package/lib-commonjs/hooks/useMergedRefs.d.ts +0 -13
- package/lib-commonjs/hooks/useMount.d.ts +0 -6
- package/lib-commonjs/hooks/useMount.js +0 -27
- package/lib-commonjs/hooks/useMount.js.map +0 -1
- package/lib-commonjs/hooks/useOnClickOutside.d.ts +0 -29
- package/lib-commonjs/hooks/useOnScrollOutside.d.ts +0 -5
- package/lib-commonjs/hooks/usePrevious.d.ts +0 -1
- package/lib-commonjs/hooks/useTimeout.d.ts +0 -8
- package/lib-commonjs/hooks/useUnmount.d.ts +0 -6
- package/lib-commonjs/hooks/useUnmount.js +0 -27
- package/lib-commonjs/hooks/useUnmount.js.map +0 -1
- package/lib-commonjs/index.d.ts +0 -8
- package/lib-commonjs/ssr/SSRContext.d.ts +0 -33
- package/lib-commonjs/ssr/canUseDOM.d.ts +0 -4
- package/lib-commonjs/ssr/index.d.ts +0 -2
- package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +0 -5
- package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +0 -1
- package/lib-commonjs/utils/clamp.d.ts +0 -8
- package/lib-commonjs/utils/getNativeElementProps.d.ts +0 -31
- package/lib-commonjs/utils/getRTLSafeKey.d.ts +0 -4
- package/lib-commonjs/utils/getReactCallbackName.d.ts +0 -25
- package/lib-commonjs/utils/getTriggerChild.d.ts +0 -22
- package/lib-commonjs/utils/getTriggerChild.js.map +0 -1
- package/lib-commonjs/utils/index.d.ts +0 -9
- package/lib-commonjs/utils/isFluentTrigger.d.ts +0 -22
- package/lib-commonjs/utils/isFluentTrigger.js.map +0 -1
- package/lib-commonjs/utils/omit.d.ts +0 -14
- package/lib-commonjs/utils/properties.d.ts +0 -160
- package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.d.ts +0 -7
@@ -1,18 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Combine two event callbacks into a single callback function that calls each one in order.
|
3
|
-
*
|
4
|
-
* This is useful to add an event listener to an existing element without overwriting the current listener, if any.
|
5
|
-
*
|
6
|
-
* For example:
|
7
|
-
* ```ts
|
8
|
-
* state.slot.onChange = useMergedCallbacks(state.slot.onChange, ev => {
|
9
|
-
* // Handle onChange
|
10
|
-
* });
|
11
|
-
* ```
|
12
|
-
*
|
13
|
-
* @param callback1 - The first callback to be called
|
14
|
-
* @param callback2 - The second callback to be called
|
15
|
-
*
|
16
|
-
* @returns An event callback that calls the callbacks in order, and is stable between renders
|
17
|
-
*/
|
18
|
-
export declare function useMergedEventCallbacks<Args extends unknown[]>(callback1: ((...args: Args) => void) | undefined, callback2: ((...args: Args) => void) | undefined): (...args: Args) => void;
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
/**
|
3
|
-
* A Ref function which can be treated like a ref object in that it has an attached
|
4
|
-
* current property, which will be updated as the ref is evaluated.
|
5
|
-
*/
|
6
|
-
export declare type RefObjectFunction<T> = React.RefObject<T> & ((value: T) => void);
|
7
|
-
/**
|
8
|
-
* React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that
|
9
|
-
* updates all provided refs
|
10
|
-
* @param refs - Refs to collectively update with one ref value.
|
11
|
-
* @returns A function with an attached "current" prop, so that it can be treated like a RefObject.
|
12
|
-
*/
|
13
|
-
export declare function useMergedRefs<T>(...refs: (React.Ref<T> | undefined)[]): RefObjectFunction<T>;
|
package/lib/hooks/useMount.d.ts
DELETED
package/lib/hooks/useMount.js
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
/**
|
3
|
-
* Hook which asynchronously executes a callback once the component has been mounted.
|
4
|
-
*
|
5
|
-
* @param callback - Function to call before mount.
|
6
|
-
*/
|
7
|
-
|
8
|
-
export const useMount = callback => {
|
9
|
-
const mountRef = React.useRef(callback);
|
10
|
-
mountRef.current = callback;
|
11
|
-
React.useEffect(() => {
|
12
|
-
var _a;
|
13
|
-
|
14
|
-
(_a = mountRef.current) === null || _a === void 0 ? void 0 : _a.call(mountRef);
|
15
|
-
}, []);
|
16
|
-
};
|
17
|
-
//# sourceMappingURL=useMount.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["hooks/useMount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA;;;;AAIG;;AACH,OAAO,MAAM,QAAQ,GAAI,QAAD,IAAyB;AAC/C,QAAM,QAAQ,GAAG,KAAK,CAAC,MAAN,CAAa,QAAb,CAAjB;AACA,EAAA,QAAQ,CAAC,OAAT,GAAmB,QAAnB;AACA,EAAA,KAAK,CAAC,SAAN,CAAgB,MAAK;;;AACnB,KAAA,EAAA,GAAA,QAAQ,CAAC,OAAT,MAAgB,IAAhB,IAAgB,EAAA,KAAA,KAAA,CAAhB,GAAgB,KAAA,CAAhB,GAAgB,EAAA,CAAA,IAAA,CAAhB,QAAgB,CAAhB;AACD,GAFD,EAEG,EAFH;AAGD,CANM","sourcesContent":["import * as React from 'react';\n\n/**\n * Hook which asynchronously executes a callback once the component has been mounted.\n *\n * @param callback - Function to call before mount.\n */\nexport const useMount = (callback: () => void) => {\n const mountRef = React.useRef(callback);\n mountRef.current = callback;\n React.useEffect(() => {\n mountRef.current?.();\n }, []);\n};\n"],"sourceRoot":"../src/"}
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
export declare type UseOnClickOrScrollOutsideOptions = {
|
3
|
-
/**
|
4
|
-
* The element to listen for the click event
|
5
|
-
*/
|
6
|
-
element: Document | undefined;
|
7
|
-
/**
|
8
|
-
* Refs to elements that check if the click is outside
|
9
|
-
*/
|
10
|
-
refs: React.MutableRefObject<HTMLElement | undefined | null>[];
|
11
|
-
/**
|
12
|
-
* By default uses element.contains, but custom contain function can be provided
|
13
|
-
* @param parentRef - provided parent ref
|
14
|
-
* @param child - event target element
|
15
|
-
*/
|
16
|
-
contains?(parent: HTMLElement | null, child: HTMLElement): boolean;
|
17
|
-
/**
|
18
|
-
* Disables event listeners
|
19
|
-
*/
|
20
|
-
disabled?: boolean;
|
21
|
-
/**
|
22
|
-
* Called if the click is outside the element refs
|
23
|
-
*/
|
24
|
-
callback: (ev: MouseEvent | TouchEvent) => void;
|
25
|
-
};
|
26
|
-
/**
|
27
|
-
* Utility to perform checks where a click/touch event was made outside a component
|
28
|
-
*/
|
29
|
-
export declare const useOnClickOutside: (options: UseOnClickOrScrollOutsideOptions) => void;
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const usePrevious: <ValueType = unknown>(value: ValueType) => ValueType | null;
|
@@ -1,8 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Helper to manage a browser timeout.
|
3
|
-
* Ensures that the timeout isn't set multiple times at once,
|
4
|
-
* and is cleaned up when the component is unloaded.
|
5
|
-
*
|
6
|
-
* @returns A pair of [setTimeout, clearTimeout] that are stable between renders.
|
7
|
-
*/
|
8
|
-
export declare function useTimeout(): readonly [(fn: () => void, delay: number) => void, () => void];
|
package/lib/hooks/useUnmount.js
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
/**
|
3
|
-
* Hook which synchronously executes a callback when the component is about to unmount.
|
4
|
-
*
|
5
|
-
* @param callback - Function to call during unmount.
|
6
|
-
*/
|
7
|
-
|
8
|
-
export const useUnmount = callback => {
|
9
|
-
const unmountRef = React.useRef(callback);
|
10
|
-
unmountRef.current = callback;
|
11
|
-
React.useEffect(() => () => {
|
12
|
-
var _a;
|
13
|
-
|
14
|
-
(_a = unmountRef.current) === null || _a === void 0 ? void 0 : _a.call(unmountRef);
|
15
|
-
}, []);
|
16
|
-
};
|
17
|
-
//# sourceMappingURL=useUnmount.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["hooks/useUnmount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA;;;;AAIG;;AACH,OAAO,MAAM,UAAU,GAAI,QAAD,IAAyB;AACjD,QAAM,UAAU,GAAG,KAAK,CAAC,MAAN,CAAa,QAAb,CAAnB;AACA,EAAA,UAAU,CAAC,OAAX,GAAqB,QAArB;AACA,EAAA,KAAK,CAAC,SAAN,CACE,MAAM,MAAK;;;AACT,KAAA,EAAA,GAAA,UAAU,CAAC,OAAX,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAA,IAAA,CAAlB,UAAkB,CAAlB;AACD,GAHH,EAIE,EAJF;AAMD,CATM","sourcesContent":["import * as React from 'react';\n\n/**\n * Hook which synchronously executes a callback when the component is about to unmount.\n *\n * @param callback - Function to call during unmount.\n */\nexport const useUnmount = (callback: () => void) => {\n const unmountRef = React.useRef(callback);\n unmountRef.current = callback;\n React.useEffect(\n () => () => {\n unmountRef.current?.();\n },\n [],\n );\n};\n"],"sourceRoot":"../src/"}
|
package/lib/index.d.ts
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
export { getSlots, resolveShorthand } from './compose/index';
|
2
|
-
export type { AsIntrinsicElement, ComponentProps, ComponentState, ExtractSlotProps, ForwardRefComponent, IsSingleton, PropsWithoutRef, ReplaceNullWithUndefined, ResolveShorthandFunction, ResolveShorthandOptions, Slot, Slots, SlotClassNames, SlotPropsRecord, SlotRenderFunction, SlotShorthandValue, UnionToIntersection, UnknownSlotProps, } from './compose/index';
|
3
|
-
export { resetIdsForTests, useBoolean, useConst, useControllableState, useEventCallback, useFirstMount, useForceUpdate, useId, useIsomorphicLayoutEffect, useMergedEventCallbacks, useMergedRefs, useMount, useOnClickOutside, useOnScrollOutside, usePrevious, useTimeout, useUnmount, } from './hooks/index';
|
4
|
-
export type { RefObjectFunction, UseBooleanCallbacks, UseControllableStateOptions, UseOnClickOrScrollOutsideOptions, } from './hooks/index';
|
5
|
-
export { canUseDOM, defaultSSRContextValue, useIsSSR, useSSRContext, SSRContext, SSRProvider } from './ssr/index';
|
6
|
-
export type { SSRContextValue } from './ssr/index';
|
7
|
-
export { anchorProperties, applyTriggerPropsToChildren, audioProperties, baseElementEvents, baseElementProperties, buttonProperties, clamp, colGroupProperties, colProperties, divProperties, fieldsetProperties, formProperties, getNativeElementProps, getNativeProps, getPartitionedNativeProps, getRTLSafeKey, getTriggerChild, htmlElementProperties, iframeProperties, imageProperties, imgProperties, inputProperties, isFluentTrigger, labelProperties, liProperties, olProperties, omit, optionProperties, selectProperties, shouldPreventDefaultOnKeyDown, tableProperties, tdProperties, textAreaProperties, thProperties, trProperties, videoProperties, } from './utils/index';
|
8
|
-
export type { FluentTriggerComponent } from './utils/index';
|
package/lib/ssr/SSRContext.d.ts
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
/**
|
3
|
-
* To support SSR, the auto incrementing id counter is stored in a context. This allows it to be reset on every request
|
4
|
-
* to ensure the client and server are consistent.
|
5
|
-
*
|
6
|
-
* @internal
|
7
|
-
*/
|
8
|
-
export declare type SSRContextValue = {
|
9
|
-
current: number;
|
10
|
-
};
|
11
|
-
/**
|
12
|
-
* Default context value to use in case there is no SSRProvider. This is fine for client-only apps.
|
13
|
-
*
|
14
|
-
* @internal
|
15
|
-
*/
|
16
|
-
export declare const defaultSSRContextValue: SSRContextValue;
|
17
|
-
export declare const SSRContext: React.Context<SSRContextValue>;
|
18
|
-
/**
|
19
|
-
* @internal
|
20
|
-
*/
|
21
|
-
export declare function useSSRContext(): SSRContextValue;
|
22
|
-
/**
|
23
|
-
* When using SSR with Fluent UI, applications must be wrapped in an SSRProvider. This ensures that auto generated ids
|
24
|
-
* are consistent between the client and server.
|
25
|
-
*
|
26
|
-
* @public
|
27
|
-
*/
|
28
|
-
export declare const SSRProvider: React.FC;
|
29
|
-
/**
|
30
|
-
* Returns whether the component is currently being server side rendered or hydrated on the client. Can be used to delay
|
31
|
-
* browser-specific rendering until after hydration. May cause re-renders on a client when is used within SSRProvider.
|
32
|
-
*/
|
33
|
-
export declare function useIsSSR(): boolean;
|
package/lib/ssr/canUseDOM.d.ts
DELETED
package/lib/ssr/index.d.ts
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
/**
|
3
|
-
* Apply the trigger props to the children, either by calling the render function, or cloning with the new props.
|
4
|
-
*/
|
5
|
-
export declare const applyTriggerPropsToChildren: <TTriggerProps>(children: React.ReactElement<any, string | React.JSXElementConstructor<any>> | ((props: TTriggerProps) => React.ReactElement | null) | null | undefined, triggerProps: TTriggerProps) => React.ReactElement | null;
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["utils/applyTriggerPropsToChildren.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,eAAT,QAAgC,mBAAhC;AAEA;;AAEG;;AACH,OAAO,MAAM,2BAA2B,GAAG,CACzC,QADyC,EAEzC,YAFyC,KAGZ;AAC7B,MAAI,OAAO,QAAP,KAAoB,UAAxB,EAAoC;AAClC,WAAO,QAAQ,CAAC,YAAD,CAAf;AACD,GAFD,MAEO,IAAI,QAAJ,EAAc;AACnB,WAAO,gBAAgB,CAAC,QAAD,EAAW,YAAX,CAAvB;AACD,GAL4B,CAO7B;AACA;AACA;;;AACA,SAAO,QAAQ,IAAI,IAAnB;AACD,CAdM;AAgBP;;;AAGG;;AACH,MAAM,gBAAgB,GAAG,CAAgB,KAAhB,EAAwC,YAAxC,KAA2F;AAClH,MAAI,eAAC,KAAK,CAAC,cAAN,CAAqB,KAArB,CAAD,IAAgC,KAAK,CAAC,IAAN,KAAe,KAAK,CAAC,QAAzD,EAAmE;AACjE,UAAM,IAAI,KAAJ,CACJ,oEACE,sDAFE,CAAN;AAID;;AAED,MAAI,eAAe,CAAC,KAAD,CAAnB,EAA4B;AAC1B,UAAM,UAAU,GAAG,gBAAgB,CAAC,KAAK,CAAC,KAAN,CAAY,QAAb,EAAuB,YAAvB,CAAnC;AACA,wBAAO,KAAK,CAAC,YAAN,CAAmB,KAAnB,EAA0B,SAA1B,EAAqC,UAArC,CAAP;AACD,GAHD,MAGO;AACL,wBAAO,KAAK,CAAC,YAAN,CAAmB,KAAnB,EAA0B,YAA1B,CAAP;AACD;AACF,CAdD","sourcesContent":["import * as React from 'react';\nimport { isFluentTrigger } from './isFluentTrigger';\n\n/**\n * Apply the trigger props to the children, either by calling the render function, or cloning with the new props.\n */\nexport const applyTriggerPropsToChildren = <TTriggerProps>(\n children: React.ReactElement | ((props: TTriggerProps) => React.ReactElement | null) | null | undefined,\n triggerProps: TTriggerProps,\n): React.ReactElement | null => {\n if (typeof children === 'function') {\n return children(triggerProps);\n } else if (children) {\n return cloneTriggerTree(children, triggerProps);\n }\n\n // Components in React should return either JSX elements or \"null\", otherwise React will throw:\n // Nothing was returned from render.\n // This usually means a return statement is missing. Or, to render nothing, return null.\n return children || null;\n};\n\n/**\n * Clones a React element tree, and applies the given props to the first grandchild that is not\n * a FluentTriggerComponent or React Fragment (the same element returned by {@link getTriggerChild}).\n */\nconst cloneTriggerTree = <TTriggerProps>(child: React.ReactNode, triggerProps: TTriggerProps): React.ReactElement => {\n if (!React.isValidElement(child) || child.type === React.Fragment) {\n throw new Error(\n 'A trigger element must be a single element for this component. ' +\n \"Please ensure that you're not using React Fragments.\",\n );\n }\n\n if (isFluentTrigger(child)) {\n const grandchild = cloneTriggerTree(child.props.children, triggerProps);\n return React.cloneElement(child, undefined, grandchild);\n } else {\n return React.cloneElement(child, triggerProps);\n }\n};\n"],"sourceRoot":"../src/"}
|
package/lib/utils/clamp.d.ts
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Clamps `value` to a number between the min and max.
|
3
|
-
*
|
4
|
-
* @param value - the value to be clamped
|
5
|
-
* @param min - the lowest valid value
|
6
|
-
* @param max - the highest valid value
|
7
|
-
*/
|
8
|
-
export declare const clamp: (value: number, min: number, max: number) => number;
|
@@ -1,31 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
/**
|
3
|
-
* Given an element tagname and user props, filters the props to only allowed props for the given
|
4
|
-
* element type.
|
5
|
-
* @param tagName - Tag name (e.g. "div")
|
6
|
-
* @param props - Props object
|
7
|
-
* @param excludedPropNames - List of props to disallow
|
8
|
-
*/
|
9
|
-
export declare function getNativeElementProps<TAttributes extends React.HTMLAttributes<any>>(tagName: string, props: {}, excludedPropNames?: string[]): TAttributes;
|
10
|
-
/**
|
11
|
-
* Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
|
12
|
-
*
|
13
|
-
* This function is only for use with components that have a primary slot other than `root`.
|
14
|
-
* Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.
|
15
|
-
*
|
16
|
-
* @returns An object containing the native props for the `root` and primary slots.
|
17
|
-
*/
|
18
|
-
export declare const getPartitionedNativeProps: <Props extends Pick<React.HTMLAttributes<HTMLElement>, "style" | "className">, ExcludedPropKeys extends Extract<keyof Props, string> = never>({ primarySlotTagName, props, excludedPropNames, }: {
|
19
|
-
/** The primary slot's element type (e.g. 'div') */
|
20
|
-
primarySlotTagName: keyof JSX.IntrinsicElements;
|
21
|
-
/** The component's props object */
|
22
|
-
props: Props;
|
23
|
-
/** List of native props to exclude from the returned value */
|
24
|
-
excludedPropNames?: ExcludedPropKeys[] | undefined;
|
25
|
-
}) => {
|
26
|
-
root: {
|
27
|
-
style: React.CSSProperties | undefined;
|
28
|
-
className: string | undefined;
|
29
|
-
};
|
30
|
-
primary: Omit<Props, ExcludedPropKeys>;
|
31
|
-
};
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
interface ReactSyntheticEvent extends React.SyntheticEvent<unknown> {
|
3
|
-
_reactName?: string;
|
4
|
-
dispatchConfig?: {
|
5
|
-
registrationName: string;
|
6
|
-
phasedRegistrationNames: {
|
7
|
-
bubbled: string;
|
8
|
-
captured: string;
|
9
|
-
};
|
10
|
-
};
|
11
|
-
}
|
12
|
-
declare type NonUndefined<A> = A extends undefined ? never : A;
|
13
|
-
declare type FunctionKeys<T extends object> = {
|
14
|
-
[K in keyof T]-?: NonUndefined<T[K]> extends Function ? K : never;
|
15
|
-
}[keyof T];
|
16
|
-
export declare type ReactCallbackName = FunctionKeys<React.DOMAttributes<unknown>>;
|
17
|
-
/**
|
18
|
-
* React.SyntheticEvent contains name of a callback that should be fired, this function returns it.
|
19
|
-
*
|
20
|
-
* Ideally, it should also distinguish regular and "capture" callbacks, but it's possible only with React 17 as
|
21
|
-
* ".eventPhase" there has proper value, see https://github.com/facebook/react/pull/19244. In React 16 all events
|
22
|
-
* are handled in bubble phase.
|
23
|
-
*/
|
24
|
-
export declare function getReactCallbackName(event: ReactSyntheticEvent): ReactCallbackName | undefined;
|
25
|
-
export {};
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
/**
|
3
|
-
* Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).
|
4
|
-
*
|
5
|
-
* In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,
|
6
|
-
* it returns the first descendant that is _not_ a FluentTriggerComponent or Fragment.
|
7
|
-
* This allows multiple triggers to be stacked, and still apply their props to the actual trigger element.
|
8
|
-
*
|
9
|
-
* For example, the following returns `<div id="child" />`:
|
10
|
-
* ```jsx
|
11
|
-
* getTriggerChild(
|
12
|
-
* <Tooltip>
|
13
|
-
* <MenuTrigger>
|
14
|
-
* <div id="child" />
|
15
|
-
* </MenuTrigger>
|
16
|
-
* </Tooltip>
|
17
|
-
* );
|
18
|
-
* ```
|
19
|
-
*/
|
20
|
-
export declare const getTriggerChild: (children: React.ReactNode) => React.ReactElement & {
|
21
|
-
ref?: React.Ref<unknown>;
|
22
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["utils/getTriggerChild.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,eAAT,QAAgC,mBAAhC;AAEA;;;;;;;;;;;;;;;;;AAiBG;;AACH,OAAO,MAAM,eAAe,GAAI,QAAD,IAAiF;AAC9G,QAAM,KAAK,GAAG,KAAK,CAAC,QAAN,CAAe,IAAf,CAAoB,QAApB,CAAd;AACA,SAAO,eAAe,CAAC,KAAD,CAAf,GAAyB,eAAe,CAAC,KAAK,CAAC,KAAN,CAAY,QAAb,CAAxC,GAAiE,KAAxE;AACD,CAHM","sourcesContent":["import * as React from 'react';\nimport { isFluentTrigger } from './isFluentTrigger';\n\n/**\n * Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).\n *\n * In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,\n * it returns the first descendant that is _not_ a FluentTriggerComponent or Fragment.\n * This allows multiple triggers to be stacked, and still apply their props to the actual trigger element.\n *\n * For example, the following returns `<div id=\"child\" />`:\n * ```jsx\n * getTriggerChild(\n * <Tooltip>\n * <MenuTrigger>\n * <div id=\"child\" />\n * </MenuTrigger>\n * </Tooltip>\n * );\n * ```\n */\nexport const getTriggerChild = (children: React.ReactNode): React.ReactElement & { ref?: React.Ref<unknown> } => {\n const child = React.Children.only(children) as React.ReactElement;\n return isFluentTrigger(child) ? getTriggerChild(child.props.children) : child;\n};\n"],"sourceRoot":"../src/"}
|
package/lib/utils/index.d.ts
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
export * from './applyTriggerPropsToChildren';
|
2
|
-
export * from './clamp';
|
3
|
-
export * from './getNativeElementProps';
|
4
|
-
export * from './getRTLSafeKey';
|
5
|
-
export * from './getTriggerChild';
|
6
|
-
export * from './isFluentTrigger';
|
7
|
-
export * from './omit';
|
8
|
-
export * from './properties';
|
9
|
-
export * from './shouldPreventDefaultOnKeyDown';
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
/**
|
3
|
-
* Allows a component to be tagged as a FluentUI trigger component.
|
4
|
-
*
|
5
|
-
* Triggers are special-case components: they attach event listeners and other props on their child,
|
6
|
-
* and use them to trigger another component to show. Examples include `MenuTrigger` and `Tooltip`.
|
7
|
-
*
|
8
|
-
* A component can be tagged as a trigger as follows:
|
9
|
-
* ```ts
|
10
|
-
* const MyComponent: React.FC<MyComponentProps> & FluentTriggerComponent = ...;
|
11
|
-
*
|
12
|
-
* MyComponent.isFluentTriggerComponent = true; // MUST also set this to true
|
13
|
-
* ```
|
14
|
-
*/
|
15
|
-
export declare type FluentTriggerComponent = {
|
16
|
-
isFluentTriggerComponent?: boolean;
|
17
|
-
};
|
18
|
-
/**
|
19
|
-
* Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).
|
20
|
-
* See the {@link FluentTriggerComponent} type for more info.
|
21
|
-
*/
|
22
|
-
export declare const isFluentTrigger: (element: React.ReactElement) => boolean | undefined;
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["utils/isFluentTrigger.ts"],"names":[],"mappings":"AAmBA;;;AAGG;AACH,OAAO,MAAM,eAAe,GAAI,OAAD,IAAgC;AAC7D,SAAQ,OAAO,CAAC,IAAR,CAAwC,wBAAhD;AACD,CAFM","sourcesContent":["import * as React from 'react';\n\n/**\n * Allows a component to be tagged as a FluentUI trigger component.\n *\n * Triggers are special-case components: they attach event listeners and other props on their child,\n * and use them to trigger another component to show. Examples include `MenuTrigger` and `Tooltip`.\n *\n * A component can be tagged as a trigger as follows:\n * ```ts\n * const MyComponent: React.FC<MyComponentProps> & FluentTriggerComponent = ...;\n *\n * MyComponent.isFluentTriggerComponent = true; // MUST also set this to true\n * ```\n */\nexport type FluentTriggerComponent = {\n isFluentTriggerComponent?: boolean;\n};\n\n/**\n * Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).\n * See the {@link FluentTriggerComponent} type for more info.\n */\nexport const isFluentTrigger = (element: React.ReactElement) => {\n return (element.type as FluentTriggerComponent).isFluentTriggerComponent;\n};\n"],"sourceRoot":"../src/"}
|
package/lib/utils/omit.d.ts
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Tiny helper to do the minimal amount of work in duplicating an object but omitting some
|
3
|
-
* props. This ends up faster than using object ...rest or reduce to filter.
|
4
|
-
*
|
5
|
-
* This behaves very much like filteredAssign, but does not merge many objects together,
|
6
|
-
* uses an exclusion object map, and avoids spreads all for optimal performance.
|
7
|
-
*
|
8
|
-
* See perf test for background:
|
9
|
-
* https://jsperf.com/omit-vs-rest-vs-reduce/1
|
10
|
-
*
|
11
|
-
* @param obj - The object to clone
|
12
|
-
* @param exclusions - The array of keys to exclude
|
13
|
-
*/
|
14
|
-
export declare function omit<TObj extends Record<string, any>, Exclusions extends (keyof TObj)[]>(obj: TObj, exclusions: Exclusions): Omit<TObj, Exclusions[number]>;
|
@@ -1,160 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* An array of events that are allowed on every html element type.
|
3
|
-
*
|
4
|
-
* @public
|
5
|
-
*/
|
6
|
-
export declare const baseElementEvents: Record<string, number>;
|
7
|
-
/**
|
8
|
-
* An array of element attributes which are allowed on every html element type.
|
9
|
-
*
|
10
|
-
* @public
|
11
|
-
*/
|
12
|
-
export declare const baseElementProperties: Record<string, number>;
|
13
|
-
/**
|
14
|
-
* An array of HTML element properties and events.
|
15
|
-
*
|
16
|
-
* @public
|
17
|
-
*/
|
18
|
-
export declare const htmlElementProperties: Record<string, number>;
|
19
|
-
/**
|
20
|
-
* An array of LABEL tag properties and events.
|
21
|
-
*
|
22
|
-
* @public
|
23
|
-
*/
|
24
|
-
export declare const labelProperties: Record<string, number>;
|
25
|
-
/**
|
26
|
-
* An array of AUDIO tag properties and events.
|
27
|
-
|
28
|
-
* @public
|
29
|
-
*/
|
30
|
-
export declare const audioProperties: Record<string, number>;
|
31
|
-
/**
|
32
|
-
* An array of VIDEO tag properties and events.
|
33
|
-
*
|
34
|
-
* @public
|
35
|
-
*/
|
36
|
-
export declare const videoProperties: Record<string, number>;
|
37
|
-
/**
|
38
|
-
* An array of OL tag properties and events.
|
39
|
-
*
|
40
|
-
* @public
|
41
|
-
*/
|
42
|
-
export declare const olProperties: Record<string, number>;
|
43
|
-
/**
|
44
|
-
* An array of LI tag properties and events.
|
45
|
-
*
|
46
|
-
* @public
|
47
|
-
*/
|
48
|
-
export declare const liProperties: Record<string, number>;
|
49
|
-
/**
|
50
|
-
* An array of A tag properties and events.
|
51
|
-
*
|
52
|
-
* @public
|
53
|
-
*/
|
54
|
-
export declare const anchorProperties: Record<string, number>;
|
55
|
-
/**
|
56
|
-
* An array of TIME tag properties and events.
|
57
|
-
*
|
58
|
-
* @public
|
59
|
-
*/
|
60
|
-
export declare const timeProperties: Record<string, number>;
|
61
|
-
/**
|
62
|
-
* An array of BUTTON tag properties and events.
|
63
|
-
*
|
64
|
-
* @public
|
65
|
-
*/
|
66
|
-
export declare const buttonProperties: Record<string, number>;
|
67
|
-
/**
|
68
|
-
* An array of INPUT tag properties and events.
|
69
|
-
*
|
70
|
-
* @public
|
71
|
-
*/
|
72
|
-
export declare const inputProperties: Record<string, number>;
|
73
|
-
/**
|
74
|
-
* An array of TEXTAREA tag properties and events.
|
75
|
-
*
|
76
|
-
* @public
|
77
|
-
*/
|
78
|
-
export declare const textAreaProperties: Record<string, number>;
|
79
|
-
/**
|
80
|
-
* An array of SELECT tag properties and events.
|
81
|
-
*
|
82
|
-
* @public
|
83
|
-
*/
|
84
|
-
export declare const selectProperties: Record<string, number>;
|
85
|
-
export declare const optionProperties: Record<string, number>;
|
86
|
-
/**
|
87
|
-
* An array of TABLE tag properties and events.
|
88
|
-
*
|
89
|
-
* @public
|
90
|
-
*/
|
91
|
-
export declare const tableProperties: Record<string, number>;
|
92
|
-
/**
|
93
|
-
* An array of TR tag properties and events.
|
94
|
-
*
|
95
|
-
* @public
|
96
|
-
*/
|
97
|
-
export declare const trProperties: Record<string, number>;
|
98
|
-
/**
|
99
|
-
* An array of TH tag properties and events.
|
100
|
-
*
|
101
|
-
* @public
|
102
|
-
*/
|
103
|
-
export declare const thProperties: Record<string, number>;
|
104
|
-
/**
|
105
|
-
* An array of TD tag properties and events.
|
106
|
-
*
|
107
|
-
* @public
|
108
|
-
*/
|
109
|
-
export declare const tdProperties: Record<string, number>;
|
110
|
-
export declare const colGroupProperties: Record<string, number>;
|
111
|
-
export declare const colProperties: Record<string, number>;
|
112
|
-
/**
|
113
|
-
* An array of FIELDSET tag properties and events.
|
114
|
-
*
|
115
|
-
* @public
|
116
|
-
*/
|
117
|
-
export declare const fieldsetProperties: Record<string, number>;
|
118
|
-
/**
|
119
|
-
* An array of FORM tag properties and events.
|
120
|
-
*
|
121
|
-
* @public
|
122
|
-
*/
|
123
|
-
export declare const formProperties: Record<string, number>;
|
124
|
-
/**
|
125
|
-
* An array of IFRAME tag properties and events.
|
126
|
-
*
|
127
|
-
* @public
|
128
|
-
*/
|
129
|
-
export declare const iframeProperties: Record<string, number>;
|
130
|
-
/**
|
131
|
-
* An array of IMAGE tag properties and events.
|
132
|
-
*
|
133
|
-
* @public
|
134
|
-
*/
|
135
|
-
export declare const imgProperties: Record<string, number>;
|
136
|
-
/**
|
137
|
-
* @deprecated Use imgProperties for img elements.
|
138
|
-
*/
|
139
|
-
export declare const imageProperties: Record<string, number>;
|
140
|
-
/**
|
141
|
-
* An array of DIV tag properties and events.
|
142
|
-
*
|
143
|
-
* @public
|
144
|
-
*/
|
145
|
-
export declare const divProperties: Record<string, number>;
|
146
|
-
/**
|
147
|
-
* Gets native supported props for an html element provided the allowance set. Use one of the property
|
148
|
-
* sets defined (divProperties, buttonPropertes, etc) to filter out supported properties from a given
|
149
|
-
* props set. Note that all data- and aria- prefixed attributes will be allowed.
|
150
|
-
* NOTE: getNativeProps should always be applied first when adding props to a react component. The
|
151
|
-
* non-native props should be applied second. This will prevent getNativeProps from overriding your custom props.
|
152
|
-
* For example, if props passed to getNativeProps has an onClick function and getNativeProps is added to
|
153
|
-
* the component after an onClick function is added, then the getNativeProps onClick will override it.
|
154
|
-
*
|
155
|
-
* @public
|
156
|
-
* @param props - The unfiltered input props
|
157
|
-
* @param allowedPropsNames - The array or record of allowed prop names.
|
158
|
-
* @returns The filtered props
|
159
|
-
*/
|
160
|
-
export declare function getNativeProps<T extends Record<string, any>>(props: Record<string, any>, allowedPropNames: string[] | Record<string, number>, excludedPropNames?: string[]): T;
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
/**
|
3
|
-
* Checks if the keyboard event should preventDefault() for Enter and Spacebar keys
|
4
|
-
*
|
5
|
-
* Useful for situations where a keydown needs to be transformed to a click event
|
6
|
-
*/
|
7
|
-
export declare function shouldPreventDefaultOnKeyDown(e: KeyboardEvent | React.KeyboardEvent): boolean;
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import type { AsIntrinsicElement, ComponentState, ExtractSlotProps, SlotPropsRecord, UnionToIntersection } from './types';
|
3
|
-
export declare type Slots<S extends SlotPropsRecord> = {
|
4
|
-
[K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As> ? As : ExtractSlotProps<S[K]> extends React.ComponentType<infer P> ? React.ElementType<NonNullable<P>> : React.ElementType<ExtractSlotProps<S[K]>>;
|
5
|
-
};
|
6
|
-
declare type ObjectSlotProps<S extends SlotPropsRecord> = {
|
7
|
-
[K in keyof S]-?: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As> ? UnionToIntersection<JSX.IntrinsicElements[As]> : ExtractSlotProps<S[K]> extends React.ComponentType<infer P> ? P : never;
|
8
|
-
};
|
9
|
-
/**
|
10
|
-
* Given the state and an array of slot names, will break out `slots` and `slotProps`
|
11
|
-
* collections.
|
12
|
-
*
|
13
|
-
* The root is derived from a mix of `components` props and `as` prop.
|
14
|
-
*
|
15
|
-
* Slots will render as null if they are rendered as primitives with undefined children.
|
16
|
-
*
|
17
|
-
* The slotProps will always omit the `as` prop within them, and for slots that are string
|
18
|
-
* primitives, the props will be filtered according to the slot type by the type system.
|
19
|
-
* For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable
|
20
|
-
* anchor props. Note that this is only enforced at build time by Typescript -- there is no
|
21
|
-
* runtime code filtering props in this function.
|
22
|
-
*
|
23
|
-
* @param state - State including slot definitions
|
24
|
-
* @returns An object containing the `slots` map and `slotProps` map.
|
25
|
-
*/
|
26
|
-
export declare function getSlots<R extends SlotPropsRecord>(state: ComponentState<R>): {
|
27
|
-
slots: Slots<R>;
|
28
|
-
slotProps: ObjectSlotProps<R>;
|
29
|
-
};
|
30
|
-
export {};
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import type { ReplaceNullWithUndefined, SlotShorthandValue, UnknownSlotProps } from './types';
|
2
|
-
export declare type ResolveShorthandOptions<Props, Required extends boolean = false> = {
|
3
|
-
required?: Required;
|
4
|
-
defaultProps?: Props;
|
5
|
-
};
|
6
|
-
export declare type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {
|
7
|
-
<P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, true>): ReplaceNullWithUndefined<P>;
|
8
|
-
<P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, boolean>): ReplaceNullWithUndefined<P> | undefined;
|
9
|
-
};
|
10
|
-
/**
|
11
|
-
* Resolves shorthands into slot props, to ensure normalization of the signature
|
12
|
-
* being passed down to getSlots method
|
13
|
-
* @param value - the base shorthand props
|
14
|
-
* @param options - options to resolve shorthand props
|
15
|
-
*/
|
16
|
-
export declare const resolveShorthand: ResolveShorthandFunction;
|