@fluentui/react-utilities 0.0.0-nightlyc0273fdc6920211123.1 → 0.0.0-nightlyc49127232120220201.1

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.
Files changed (64) hide show
  1. package/CHANGELOG.json +97 -6
  2. package/CHANGELOG.md +21 -6
  3. package/dist/react-utilities.d.ts +134 -81
  4. package/lib/compose/getSlots.d.ts +11 -10
  5. package/lib/compose/getSlots.js +6 -4
  6. package/lib/compose/getSlots.js.map +1 -1
  7. package/lib/compose/resolveShorthand.d.ts +5 -5
  8. package/lib/compose/resolveShorthand.js +3 -3
  9. package/lib/compose/types.d.ts +48 -27
  10. package/lib/compose/types.js.map +1 -1
  11. package/lib/hooks/index.d.ts +1 -1
  12. package/lib/hooks/index.js +1 -1
  13. package/lib/hooks/index.js.map +1 -1
  14. package/lib/hooks/useControllableState.d.ts +16 -6
  15. package/lib/hooks/useControllableState.js +13 -8
  16. package/lib/hooks/useControllableState.js.map +1 -1
  17. package/lib/hooks/useOnClickOutside.js.map +1 -1
  18. package/lib/hooks/useTriggerElement.d.ts +18 -0
  19. package/lib/hooks/useTriggerElement.js +90 -0
  20. package/lib/hooks/useTriggerElement.js.map +1 -0
  21. package/lib/utils/applyTriggerPropsToChildren.d.ts +1 -1
  22. package/lib/utils/getNativeElementProps.d.ts +22 -0
  23. package/lib/utils/getNativeElementProps.js +22 -0
  24. package/lib/utils/getNativeElementProps.js.map +1 -1
  25. package/lib/utils/getReactCallbackName.d.ts +25 -0
  26. package/lib/utils/getReactCallbackName.js +26 -0
  27. package/lib/utils/getReactCallbackName.js.map +1 -0
  28. package/lib/utils/onlyChild.d.ts +1 -1
  29. package/lib/utils/properties.js +40 -20
  30. package/lib/utils/properties.js.map +1 -1
  31. package/lib-commonjs/compose/getSlots.d.ts +11 -10
  32. package/lib-commonjs/compose/getSlots.js +6 -4
  33. package/lib-commonjs/compose/getSlots.js.map +1 -1
  34. package/lib-commonjs/compose/resolveShorthand.d.ts +5 -5
  35. package/lib-commonjs/compose/resolveShorthand.js +3 -3
  36. package/lib-commonjs/compose/types.d.ts +48 -27
  37. package/lib-commonjs/compose/types.js.map +1 -1
  38. package/lib-commonjs/hooks/index.d.ts +1 -1
  39. package/lib-commonjs/hooks/index.js +2 -2
  40. package/lib-commonjs/hooks/index.js.map +1 -1
  41. package/lib-commonjs/hooks/useControllableState.d.ts +16 -6
  42. package/lib-commonjs/hooks/useControllableState.js +13 -8
  43. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  44. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  45. package/lib-commonjs/hooks/useTriggerElement.d.ts +18 -0
  46. package/lib-commonjs/hooks/useTriggerElement.js +105 -0
  47. package/lib-commonjs/hooks/useTriggerElement.js.map +1 -0
  48. package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +1 -1
  49. package/lib-commonjs/utils/getNativeElementProps.d.ts +22 -0
  50. package/lib-commonjs/utils/getNativeElementProps.js +25 -1
  51. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  52. package/lib-commonjs/utils/getReactCallbackName.d.ts +25 -0
  53. package/lib-commonjs/utils/getReactCallbackName.js +35 -0
  54. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -0
  55. package/lib-commonjs/utils/onlyChild.d.ts +1 -1
  56. package/lib-commonjs/utils/properties.js +40 -20
  57. package/lib-commonjs/utils/properties.js.map +1 -1
  58. package/package.json +6 -10
  59. package/lib/hooks/useControllableValue.d.ts +0 -20
  60. package/lib/hooks/useControllableValue.js +0 -57
  61. package/lib/hooks/useControllableValue.js.map +0 -1
  62. package/lib-commonjs/hooks/useControllableValue.d.ts +0 -20
  63. package/lib-commonjs/hooks/useControllableValue.js +0 -68
  64. package/lib-commonjs/hooks/useControllableValue.js.map +0 -1
@@ -1,46 +1,60 @@
1
1
  import * as React from 'react';
2
- export declare type ShorthandRenderFunction<Props> = (Component: React.ElementType<Props>, props: Omit<Props, 'children' | 'as'>) => React.ReactNode;
3
- export declare type ObjectShorthandPropsRecord = Record<string, DefaultObjectShorthandProps | undefined>;
4
- export declare type ShorthandProps<Props extends DefaultObjectShorthandProps> = React.ReactChild | React.ReactNodeArray | React.ReactPortal | number | null | undefined | Props;
2
+ export declare type SlotRenderFunction<Props> = (Component: React.ElementType<Props>, props: Omit<Props, 'children' | 'as'>) => React.ReactNode;
3
+ export declare type SlotPropsRecord = Record<string, UnknownSlotProps | undefined>;
4
+ export declare type ShorthandProps<Props extends UnknownSlotProps> = React.ReactChild | React.ReactNodeArray | React.ReactPortal | number | null | undefined | Props;
5
5
  /**
6
- * Matches any shorthand props type.
6
+ * Matches any slot props type.
7
7
  *
8
- * This should ONLY be used in type templates as in `extends DefaultObjectShorthandProps`;
8
+ * This should ONLY be used in type templates as in `extends DefaultObjectSlotProps`;
9
9
  * it shouldn't be used as the type of a slot.
10
10
  */
11
- export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{
12
- children?: React.ReactNode;
11
+ export declare type UnknownSlotProps = SlotProps<Pick<React.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {
13
12
  as?: keyof JSX.IntrinsicElements;
14
13
  }>;
15
14
  /**
16
- * Defines the slot props for a slot that supports a Component type.
17
- *
18
- * For intrinsic elements like 'div', use {@link IntrinsicShorthandProps} instead.
15
+ * Takes the props we want to support for a slot and adds the ability for `children` to be a render function that takes
16
+ * those props.
19
17
  */
20
- export declare type ObjectShorthandProps<Props extends {
18
+ export declare type SlotProps<Props extends {
21
19
  children?: React.ReactNode;
22
20
  } = {}> = Props & {
23
- children?: Props['children'] | ShorthandRenderFunction<Props>;
21
+ children?: Props['children'] | SlotRenderFunction<Props>;
24
22
  };
23
+ /**
24
+ * Defines the slot props for a slot that supports a Component type.
25
+ *
26
+ * For intrinsic/native elements like 'div', use {@link IntrinsicSlotProps} instead.
27
+ *
28
+ * The generic param is the type of a control, i.e. a React component. For example:
29
+ *
30
+ * @example
31
+ * ```
32
+ * type Props = {...}
33
+ * const Button: React.FC<Props> = () => {...}
34
+ * // $ExpectType ...
35
+ * type SlotProps = ComponentSlotProps<typeof Button>
36
+ * ```
37
+ */
38
+ export declare type ComponentSlotProps<Component extends React.ComponentType> = Component extends React.ComponentType<infer Props> ? SlotProps<Props> : never;
25
39
  /**
26
40
  * Define the slot arguments for a slot that supports one or more intrinsic element types, such as 'div'.
27
- * For slots that support custom components, use {@link ObjectShorthandProps} instead.
41
+ * For slots that support custom components, use {@link ComponentSlotProps} instead.
28
42
  *
29
43
  * The first param is the slot's default type if no `as` prop is specified.
30
44
  * The second param is an optional union of alternative types that can be specified for the `as` prop.
31
45
  *
32
46
  * ```
33
- * IntrinsicShorthandProps<'div'> // Slot is always div
34
- * IntrinsicShorthandProps<'button', 'a'> // Defaults to button, but allows as="a" with anchor-specific props
35
- * IntrinsicShorthandProps<'label', 'span' | 'div'>; // Defaults to label, but allows as="span" or as="div"
47
+ * IntrinsicSlotProps<'div'> // Slot is always div
48
+ * IntrinsicSlotProps<'button', 'a'> // Defaults to button, but allows as="a" with anchor-specific props
49
+ * IntrinsicSlotProps<'label', 'span' | 'div'>; // Defaults to label, but allows as="span" or as="div"
36
50
  * ```
37
51
  */
38
- export declare type IntrinsicShorthandProps<DefaultAs extends keyof JSX.IntrinsicElements, AlternateAs extends keyof JSX.IntrinsicElements = never> = IsSingleton<DefaultAs> extends false ? 'Error: first parameter to IntrinsicShorthandProps must be a single element type, not a union of types' : ({
52
+ export declare type IntrinsicSlotProps<DefaultAs extends keyof JSX.IntrinsicElements, AlternateAs extends keyof JSX.IntrinsicElements = never> = IsSingleton<DefaultAs> extends false ? 'Error: first parameter to IntrinsicSlotProps must be a single element type, not a union of types' : ({
39
53
  as?: DefaultAs;
40
- } & ObjectShorthandProps<React.PropsWithRef<JSX.IntrinsicElements[DefaultAs]>>) | {
54
+ } & SlotProps<React.PropsWithRef<JSX.IntrinsicElements[DefaultAs]>>) | {
41
55
  [As in AlternateAs]: {
42
56
  as: As;
43
- } & ObjectShorthandProps<React.PropsWithRef<JSX.IntrinsicElements[As]>>;
57
+ } & SlotProps<React.PropsWithRef<JSX.IntrinsicElements[As]>>;
44
58
  }[AlternateAs];
45
59
  /**
46
60
  * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.
@@ -70,20 +84,27 @@ export declare type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> =
70
84
  export declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;
71
85
  /**
72
86
  * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by
73
- * IntrinsicShorthandProps). This allows IntrinsicShorthandProps to be used with React.forwardRef.
87
+ * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.
74
88
  *
75
89
  * The conditional "extends unknown" (always true) exploits a quirk in the way TypeScript handles conditional
76
90
  * types, to prevent unions from being expanded.
77
91
  */
78
92
  export declare type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;
79
- export declare type ComponentProps<Shorthands extends ObjectShorthandPropsRecord, Primary extends keyof Shorthands = 'root'> = Omit<{
80
- [Key in keyof Shorthands]?: ShorthandProps<NonNullable<Shorthands[Key]>>;
81
- }, Primary> & PropsWithoutRef<Shorthands[Primary]>;
82
- export declare type ComponentState<Shorthands extends ObjectShorthandPropsRecord> = {
83
- components?: {
84
- [Key in keyof Shorthands]-?: React.ComponentType<NonNullable<Shorthands[Key]> extends ObjectShorthandProps<infer P> ? P : NonNullable<Shorthands[Key]>> | (NonNullable<Shorthands[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
93
+ /**
94
+ * Defines the Props type for a component given its slots and the definition of which one is the primary slot,
95
+ * defaulting to root if one is not provided.
96
+ */
97
+ export declare type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> = Omit<{
98
+ [Key in keyof Slots]?: ShorthandProps<NonNullable<Slots[Key]>>;
99
+ }, Primary & 'root'> & PropsWithoutRef<Slots[Primary]>;
100
+ /**
101
+ * Defines the State object of a component given its slots.
102
+ */
103
+ export declare type ComponentState<Slots extends SlotPropsRecord> = {
104
+ components: {
105
+ [Key in keyof Slots]-?: React.ComponentType<NonNullable<Slots[Key]> extends SlotProps<infer P> ? P : NonNullable<Slots[Key]>> | (NonNullable<Slots[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
85
106
  };
86
- } & Shorthands;
107
+ } & Slots;
87
108
  /**
88
109
  * This is part of a hack to infer the element type from a native element *props* type.
89
110
  * The only place the original element is found in a native props type (at least that's workable
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/compose/types.ts"],"names":[],"mappings":"WA2IA;AACA;AACA;AACA;AACA","sourceRoot":""}
1
+ {"version":3,"sources":["../../src/compose/types.ts"],"names":[],"mappings":"WAyKA;AACA;AACA;AACA;AACA","sourceRoot":""}
@@ -1,7 +1,6 @@
1
1
  export * from './useControllableState';
2
2
  export * from './useBoolean';
3
3
  export * from './useConst';
4
- export * from './useControllableValue';
5
4
  export * from './useEventCallback';
6
5
  export * from './useFirstMount';
7
6
  export * from './useId';
@@ -12,5 +11,6 @@ export * from './useOnClickOutside';
12
11
  export * from './useOnScrollOutside';
13
12
  export * from './usePrevious';
14
13
  export * from './useTimeout';
14
+ export * from './useTriggerElement';
15
15
  export * from './useUnmount';
16
16
  export * from './useForceUpdate';
@@ -1,7 +1,6 @@
1
1
  export * from './useControllableState';
2
2
  export * from './useBoolean';
3
3
  export * from './useConst';
4
- export * from './useControllableValue';
5
4
  export * from './useEventCallback';
6
5
  export * from './useFirstMount';
7
6
  export * from './useId';
@@ -12,6 +11,7 @@ export * from './useOnClickOutside';
12
11
  export * from './useOnScrollOutside';
13
12
  export * from './usePrevious';
14
13
  export * from './useTimeout';
14
+ export * from './useTriggerElement';
15
15
  export * from './useUnmount';
16
16
  export * from './useForceUpdate';
17
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC"}
@@ -1,21 +1,31 @@
1
1
  import * as React from 'react';
2
2
  export declare type UseControllableStateOptions<State> = {
3
3
  /**
4
- * User provided default state or factory initializer
4
+ * User-provided default state or initializer, for uncontrolled usage.
5
5
  */
6
6
  defaultState?: State | (() => State);
7
7
  /**
8
- * User provided controllable state, undefined state means internal state will be used
8
+ * User-provided controlled state. `undefined` means internal state will be used.
9
9
  */
10
10
  state: State | undefined;
11
11
  /**
12
- * Used to initialize state if all user provided states are undefined
12
+ * Used as the initial state if `state` and `defaultState` are both `undefined`.
13
+ * If `undefined` is the correct initial state, pass that here.
13
14
  */
14
15
  initialState: State;
15
16
  };
16
17
  /**
17
- * A useState 'like' hook that allows optional user control
18
- * Useful for components which allow uncontrolled and controlled behaviour for users
19
- * @returns - https://reactjs.org/docs/hooks-state.html
18
+ * A `useState`-like hook to manage a value that could be either controlled or uncontrolled,
19
+ * such as a checked state or text input string.
20
+ *
21
+ * Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a
22
+ * controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.
23
+ *
24
+ * @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array
25
+ * of the current value and an updater (dispatch) function. The updater function is referentially
26
+ * stable (won't change during the component's lifecycle). It can take either a new value, or a
27
+ * function which is passed the previous value and returns the new value. Unlike `setState`, calls
28
+ * to the updater function will only be respected if the component is uncontrolled.
29
+ * @see https://reactjs.org/docs/uncontrolled-components.html
20
30
  */
21
31
  export declare const useControllableState: <State>(options: UseControllableStateOptions<State>) => [State, React.Dispatch<React.SetStateAction<State>>];
@@ -1,23 +1,28 @@
1
1
  import * as React from 'react';
2
2
  import { useConst } from './useConst';
3
3
 
4
- function isUndefined(state) {
5
- return typeof state === 'undefined';
6
- }
7
-
8
4
  function isFactoryDispatch(newState) {
9
5
  return typeof newState === 'function';
10
6
  }
11
7
  /**
12
- * A useState 'like' hook that allows optional user control
13
- * Useful for components which allow uncontrolled and controlled behaviour for users
14
- * @returns - https://reactjs.org/docs/hooks-state.html
8
+ * A `useState`-like hook to manage a value that could be either controlled or uncontrolled,
9
+ * such as a checked state or text input string.
10
+ *
11
+ * Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a
12
+ * controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.
13
+ *
14
+ * @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array
15
+ * of the current value and an updater (dispatch) function. The updater function is referentially
16
+ * stable (won't change during the component's lifecycle). It can take either a new value, or a
17
+ * function which is passed the previous value and returns the new value. Unlike `setState`, calls
18
+ * to the updater function will only be respected if the component is uncontrolled.
19
+ * @see https://reactjs.org/docs/uncontrolled-components.html
15
20
  */
16
21
 
17
22
 
18
23
  export const useControllableState = options => {
19
24
  const isControlled = useIsControlled(options.state);
20
- const initialState = isUndefined(options.defaultState) ? options.initialState : options.defaultState;
25
+ const initialState = typeof options.defaultState === 'undefined' ? options.initialState : options.defaultState;
21
26
  const [internalState, setInternalState] = React.useState(initialState);
22
27
  const state = isControlled ? options.state : internalState;
23
28
  const stateRef = React.useRef(state);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useControllableState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,YAAzB;;AAiBA,SAAS,WAAT,CAAqB,KAArB,EAAmC;AACjC,SAAO,OAAO,KAAP,KAAiB,WAAxB;AACD;;AAED,SAAS,iBAAT,CAAkC,QAAlC,EAAuE;AACrE,SAAO,OAAO,QAAP,KAAoB,UAA3B;AACD;AAED;;;;AAIG;;;AACH,OAAO,MAAM,oBAAoB,GAC/B,OADkC,IAEsB;AACxD,QAAM,YAAY,GAAG,eAAe,CAAC,OAAO,CAAC,KAAT,CAApC;AACA,QAAM,YAAY,GAAG,WAAW,CAAC,OAAO,CAAC,YAAT,CAAX,GAAoC,OAAO,CAAC,YAA5C,GAA2D,OAAO,CAAC,YAAxF;AACA,QAAM,CAAC,aAAD,EAAgB,gBAAhB,IAAoC,KAAK,CAAC,QAAN,CAAsB,YAAtB,CAA1C;AAEA,QAAM,KAAK,GAAG,YAAY,GAAI,OAAO,CAAC,KAAZ,GAA8B,aAAxD;AAEA,QAAM,QAAQ,GAAG,KAAK,CAAC,MAAN,CAAa,KAAb,CAAjB;AACA,EAAA,KAAK,CAAC,SAAN,CAAgB,MAAK;AACnB,IAAA,QAAQ,CAA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Props> = {
3
+ /** An actual trigger element or render props function. */
4
+ children: React.ReactElement | ((props: TriggerProps) => React.ReactNode) | null | undefined;
5
+ /** A ref to trigger element. */
6
+ ref: React.Ref<unknown> | undefined;
7
+ /** Props that are passed to a parent component and should be forwarded down. */
8
+ outerProps: React.HTMLProps<unknown>;
9
+ /** Custom props including callbacks. */
10
+ overrideProps: TriggerProps;
11
+ };
12
+ /**
13
+ * A hook that handles "trigger" pattern.
14
+ *
15
+ * Clones a passed element or calls render props. Merges props including refs and callbacks, callbacks are kept stable
16
+ * by reference.
17
+ */
18
+ export declare function useTriggerElement<TriggerProps extends React.HTMLProps<unknown>>(options: UseTriggerElementOptions<TriggerProps>): React.ReactNode;
@@ -0,0 +1,90 @@
1
+ import * as React from 'react';
2
+ import { applyTriggerPropsToChildren } from '../utils/applyTriggerPropsToChildren';
3
+ import { getReactCallbackName } from '../utils/getReactCallbackName';
4
+ import { onlyChild } from '../utils/onlyChild';
5
+ import { useEventCallback } from './useEventCallback';
6
+ import { useMergedRefs } from './useMergedRefs';
7
+ const CAPTURE_CALLBACK_REGEX = /on[A-Z].+Capture$/;
8
+ const CALLBACK_REGEX = /on[A-Z].+/;
9
+ /**
10
+ * A hook that handles "trigger" pattern.
11
+ *
12
+ * Clones a passed element or calls render props. Merges props including refs and callbacks, callbacks are kept stable
13
+ * by reference.
14
+ */
15
+
16
+ export function useTriggerElement(options) {
17
+ const {
18
+ children,
19
+ ref,
20
+ outerProps,
21
+ overrideProps
22
+ } = options;
23
+ let childProps = {};
24
+ let childRef = null; // child can be a render func, `applyTriggerPropsToChildren`does the same check again
25
+ // TODO figure out a way to only do this check once
26
+
27
+ if ( /*#__PURE__*/React.isValidElement(children)) {
28
+ const child = onlyChild(children);
29
+ childProps = child.props;
30
+ childRef = child.ref;
31
+ } // Two separate callbacks are needed to handle properly bubble and capture callbacks
32
+ // "getReactCallbackName()" could return proper callback name, but it's possible only with React 17
33
+
34
+
35
+ const handleBubbleEvent = useEventCallback(ev => {
36
+ var _a, _b, _c;
37
+
38
+ const callbackName = getReactCallbackName(ev);
39
+
40
+ if (callbackName) {
41
+ // Typecast is required as "ev" is "React.SyntheticEvent" while callbacks have stricter typings and accept
42
+ // "FocusEvent", "ClipboardEvent" and etc.
43
+
44
+ /* eslint-disable @typescript-eslint/no-explicit-any */
45
+ (_a = childProps[callbackName]) === null || _a === void 0 ? void 0 : _a.call(childProps, ev);
46
+ (_b = overrideProps[callbackName]) === null || _b === void 0 ? void 0 : _b.call(overrideProps, ev);
47
+ (_c = outerProps[callbackName]) === null || _c === void 0 ? void 0 : _c.call(outerProps, ev);
48
+ /* eslint-enable @typescript-eslint/no-explicit-any */
49
+ }
50
+ });
51
+ const handleCaptureEvent = useEventCallback(ev => {
52
+ var _a, _b, _c;
53
+
54
+ const callbackName = getReactCallbackName(ev) + 'Capture';
55
+
56
+ if (callbackName) {
57
+ // Typecast is required as "ev" is "React.SyntheticEvent" while callbacks have stricter typings and accept
58
+ // "FocusEvent", "ClipboardEvent" and etc.
59
+
60
+ /* eslint-disable @typescript-eslint/no-explicit-any */
61
+ (_a = childProps[callbackName]) === null || _a === void 0 ? void 0 : _a.call(childProps, ev);
62
+ (_b = overrideProps[callbackName]) === null || _b === void 0 ? void 0 : _b.call(overrideProps, ev);
63
+ (_c = outerProps[callbackName]) === null || _c === void 0 ? void 0 : _c.call(outerProps, ev);
64
+ /* eslint-enable @typescript-eslint/no-explicit-any */
65
+ }
66
+ });
67
+ const mergedPropEntries = Object.entries({ ...outerProps,
68
+ ...overrideProps,
69
+ ...childProps,
70
+ // Undocumented, but React supports ref cloning through props
71
+ ref: useMergedRefs(childRef, ref)
72
+ }); // TODO: fix me after https://github.com/microsoft/fluentui/issues/21229
73
+ // Causes TS error:
74
+ // "Property 'fromEntries' does not exist on type 'ObjectConstructor'"
75
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
+
77
+ const triggerProps = Object.fromEntries(mergedPropEntries.map(([propName, propValue]) => {
78
+ if (propName.match(CAPTURE_CALLBACK_REGEX)) {
79
+ return [propName, handleCaptureEvent];
80
+ }
81
+
82
+ if (propName.match(CALLBACK_REGEX)) {
83
+ return [propName, handleBubbleEvent];
84
+ }
85
+
86
+ return [propName, propValue];
87
+ }));
88
+ return applyTriggerPropsToChildren(children, triggerProps);
89
+ }
90
+ //# sourceMappingURL=useTriggerElement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/useTriggerElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA,SAAS,2BAAT,QAA4C,sCAA5C;AACA,SAAS,oBAAT,QAAqC,+BAArC;AACA,SAAS,SAAT,QAA0B,oBAA1B;AACA,SAAS,gBAAT,QAAiC,oBAAjC;AACA,SAAS,aAAT,QAA8B,iBAA9B;AAiBA,MAAM,sBAAsB,GAAG,mBAA/B;AACA,MAAM,cAAc,GAAG,WAAvB;AAEA;;;;;AAKG;;AACH,OAAM,SAAU,iBAAV,CACJ,OADI,EAC2C;AAE/C,QAAM;AAAE,IAAA,QAAF;AAAY,IAAA,GAAZ;AAAiB,IAAA,UAAjB;AAA6B,IAAA;AAA7B,MAA+C,OAArD;AAEA,MAAI,UAAU,GAA6B,EAA3C;AACA,MAAI,QAAQ,GAAG,IAAf,CAL+C,CAO/C;AACA;;AACA,oBAAI,KAAK,CAAC,cAAN,CAAqB,QAArB,CAAJ,EAAoC;AAClC,UAAM,KAAK,GAAG,SAAS,CAAC,QAAD,CAAvB;AAEA,IAAA,UAAU,GAAG,KAAK,CAAC,KAAnB;AACA,IAAA,QAAQ,GAAK,KAAkD,CAAC,GAAhE;AACD,GAd8C,CAgB/C;AACA;;;AAEA,QAAM,iBAAiB,GAAG,gBAAgB,CAAE,EAAD,IAAsC;;;AAC/E,UAAM,YAAY,GAAG,oBAAoB,CAAC,EAAD,CAAzC;;AAEA,QAAI,YAAJ,EAAkB;AAChB;AACA;;AACA;AACA,OAAA,EAAA,GAAA,UAAU,CAAC,YAA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QAAM,iBAAiB,GAAG,MAAM,CAAC,OAAP,CAAe,EACvC,GAAG,UADoC;AAEvC,OAAG,aAFoC;AAGvC,OAAG,UAHoC;AAIvC;AACA,IAAA,GAAG,EAAE,aAAa,CAAC,QAAD,EAAW,GAAX;AALqB,GAAf,CAA1B,CA9C+C,CAsD/C;AACA;AACA;AACA;;AACA,QAAM,YAAY,GAAI,MAAc,CAAC,WAAf,CACpB,iBAAiB,CAAC,GAAlB,CAAsB,CAAC,CAAC,QAAD,EAAW,SAAX,CAAD,KAA0B;AAC9C,QAAI,QAAQ,CAAC,KAAT,CAAe,sBAAf,CAAJ,EAA4C;AAC1C,aAAO,CAAC,QAAD,EAAW,kBAAX,CAAP;AACD;;AAED,QAAI,QAAQ,CAAC,KAAT,CAAe,cAAf,CAAJ,EAAoC;AAClC,aAAO,CAAC,QAAD,EAAW,iBAAX,CAAP;AACD;;AAED,WAAO,CAAC,QAAD,EAAW,SAAX,CAAP;AACD,GAVD,CADoB,CAAtB;AAcA,SAAO,2BAA2B,CAAC,QAAD,EAAW,YAAX,CAAlC;AACD","sourceRoot":""}
@@ -2,4 +2,4 @@ import * as React from 'react';
2
2
  /**
3
3
  * Apply the trigger props to the children, either by calling the render function, or cloning with the new props.
4
4
  */
5
- export declare const applyTriggerPropsToChildren: <TTriggerProps>(children: React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | ((props: TTriggerProps) => React.ReactNode) | null | undefined, triggerProps: TTriggerProps) => React.ReactNode;
5
+ export declare const applyTriggerPropsToChildren: <TTriggerProps>(children: React.ReactElement<any, string | React.JSXElementConstructor<any>> | ((props: TTriggerProps) => React.ReactNode) | null | undefined, triggerProps: TTriggerProps) => React.ReactNode;
@@ -7,3 +7,25 @@ import * as React from 'react';
7
7
  * @param excludedPropNames - List of props to disallow
8
8
  */
9
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: ({ 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: Pick<React.HTMLAttributes<HTMLElement>, 'style' | 'className'>;
23
+ /** List of native props to exclude from the returned value */
24
+ excludedPropNames?: string[] | undefined;
25
+ }) => {
26
+ root: {
27
+ style: React.CSSProperties | undefined;
28
+ className: string | undefined;
29
+ };
30
+ primary: React.HTMLAttributes<any>;
31
+ };
@@ -35,4 +35,26 @@ export function getNativeElementProps(tagName, props, excludedPropNames) {
35
35
  allowedPropNames.as = 1;
36
36
  return getNativeProps(props, allowedPropNames, excludedPropNames);
37
37
  }
38
+ /**
39
+ * Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
40
+ *
41
+ * This function is only for use with components that have a primary slot other than `root`.
42
+ * Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.
43
+ *
44
+ * @returns An object containing the native props for the `root` and primary slots.
45
+ */
46
+
47
+ export const getPartitionedNativeProps = ({
48
+ primarySlotTagName,
49
+ props,
50
+ excludedPropNames
51
+ }) => {
52
+ return {
53
+ root: {
54
+ style: props.style,
55
+ className: props.className
56
+ },
57
+ primary: getNativeElementProps(primarySlotTagName, props, [...(excludedPropNames || []), 'style', 'className'])
58
+ };
59
+ };
38
60
  //# sourceMappingURL=getNativeElementProps.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/getNativeElementProps.ts"],"names":[],"mappings":"AACA,SACE,eADF,EAEE,eAFF,EAGE,eAHF,EAIE,YAJF,EAKE,YAL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D,CAA5B,IAA0C,qBAAnE;AACA,EAAA,gBAAgB,CAAC,EAAjB,GAAsB,CAAtB;AAEA,SAAO,cAAc,CAAC,KAAD,EAAQ,gBAAR,EAA0B,iBAA1B,CAArB;AACD;AAED;;;;;;;AAOG;;AACH,OAAO,MAAM,yBAAyB,GAAG,CAAC;AACxC,EAAA,kBADwC;AAExC,EAAA,KAFwC;AAGxC,EAAA;AAHwC,CAAD,KAapC;AACH,SAAO;AACL,IAAA,IAAI,EAAE;AAAE,MAAA,KAAK,EAAE,KAAK,CAAC,KAAf;AAAsB,MAAA,SAAS,EAAE,KAAK,CAAC;AAAvC,KADD;AAEL,IAAA,OAAO,EAAE,qBAAqB,CAAC,kBAAD,EAAqB,KAArB,EAA4B,CAAC,IAAI,iBAAiB,IAAI,EAAzB,CAAD,EAA+B,OAA/B,EAAwC,WAAxC,CAA5B;AAFzB,GAAP;AAID,CAlBM","sourceRoot":""}
@@ -0,0 +1,25 @@
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 {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * React.SyntheticEvent contains name of a callback that should be fired, this function returns it.
3
+ *
4
+ * Ideally, it should also distinguish regular and "capture" callbacks, but it's possible only with React 17 as
5
+ * ".eventPhase" there has proper value, see https://github.com/facebook/react/pull/19244. In React 16 all events
6
+ * are handled in bubble phase.
7
+ */
8
+ export function getReactCallbackName(event) {
9
+ if (event._reactName) {
10
+ return event._reactName;
11
+ }
12
+
13
+ if (event.dispatchConfig) {
14
+ if (event.dispatchConfig.registrationName) {
15
+ return event.dispatchConfig.registrationName;
16
+ }
17
+
18
+ return event.dispatchConfig.phasedRegistrationNames.bubbled;
19
+ }
20
+
21
+ if (process.env.NODE_ENV !== 'production') {
22
+ // eslint-disable-next-line no-console
23
+ console.error(['Passed React.SyntheticEvent does not contain ".dispatchConfig" or "._reactName".', 'This should not happen, please report it to https://github.com/microsoft/fluentui']);
24
+ }
25
+ }
26
+ //# sourceMappingURL=getReactCallbackName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/getReactCallbackName.ts"],"names":[],"mappings":"AAwBA;;;;;;AAMG;AACH,OAAM,SAAU,oBAAV,CAA+B,KAA/B,EAAyD;AAC7D,MAAI,KAAK,CAAC,UAAV,EAAsB;AACpB,WAAO,KAAK,CAAC,UAAb;AACD;;AAED,MAAI,KAAK,CAAC,cAAV,EAA0B;AACxB,QAAI,KAAK,CAAC,cAAN,CAAqB,gBAAzB,EAA2C;AACzC,aAAO,KAAK,CAAC,cAAN,CAAqB,gBAA5B;AACD;;AAED,WAAO,KAAK,CAAC,cAAN,CAAqB,uBAArB,CAA6C,OAApD;AACD;;AAED,MAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;AACzC;AACA,IAAA,OAAO,CAAC,KAAR,CAAc,CACZ,kFADY,EAEZ,mFAFY,CAAd;AAID;AACF","sourceRoot":""}
@@ -2,4 +2,4 @@ import * as React from 'react';
2
2
  /**
3
3
  * Similar to React.Children.only, but drills into fragments rather than treating them as a single child
4
4
  */
5
- export declare const onlyChild: <P>(child: string | number | boolean | {} | React.ReactNodeArray | React.ReactPortal | React.ReactElement<P, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null | undefined) => React.ReactElement<P, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>;
5
+ export declare const onlyChild: <P>(child: boolean | React.ReactText | React.ReactFragment | React.ReactPortal | React.ReactElement<P, string | React.JSXElementConstructor<any>> | null | undefined) => React.ReactElement<P, string | React.JSXElementConstructor<any>>;