@fluentui/react-utilities 9.0.0-rc.7 → 9.0.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.
Files changed (212) hide show
  1. package/CHANGELOG.json +120 -1
  2. package/CHANGELOG.md +48 -2
  3. package/dist/index.d.ts +31 -278
  4. package/{lib → dist}/tsdoc-metadata.json +0 -0
  5. package/lib/compose/getSlots.js.map +1 -1
  6. package/lib/compose/resolveShorthand.js.map +1 -1
  7. package/lib/compose/types.js.map +1 -1
  8. package/lib/hooks/index.js +0 -4
  9. package/lib/hooks/index.js.map +1 -1
  10. package/lib/hooks/useControllableState.js +3 -2
  11. package/lib/hooks/useControllableState.js.map +1 -1
  12. package/lib/hooks/useEventCallback.js +1 -0
  13. package/lib/hooks/useEventCallback.js.map +1 -1
  14. package/lib/hooks/useFirstMount.js +1 -0
  15. package/lib/hooks/useFirstMount.js.map +1 -1
  16. package/lib/hooks/useForceUpdate.js +1 -0
  17. package/lib/hooks/useForceUpdate.js.map +1 -1
  18. package/lib/hooks/useId.js +0 -2
  19. package/lib/hooks/useId.js.map +1 -1
  20. package/lib/hooks/useIsomorphicLayoutEffect.js +1 -0
  21. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  22. package/lib/hooks/useMergedEventCallbacks.js +1 -0
  23. package/lib/hooks/useMergedEventCallbacks.js.map +1 -1
  24. package/lib/hooks/useMergedRefs.js +1 -0
  25. package/lib/hooks/useMergedRefs.js.map +1 -1
  26. package/lib/hooks/useOnClickOutside.js +2 -1
  27. package/lib/hooks/useOnClickOutside.js.map +1 -1
  28. package/lib/hooks/useOnScrollOutside.js +1 -0
  29. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  30. package/lib/hooks/usePrevious.js +4 -0
  31. package/lib/hooks/usePrevious.js.map +1 -1
  32. package/lib/hooks/useTimeout.js +2 -2
  33. package/lib/hooks/useTimeout.js.map +1 -1
  34. package/lib/index.js +4 -4
  35. package/lib/index.js.map +1 -1
  36. package/lib/ssr/SSRContext.js.map +1 -1
  37. package/lib/ssr/canUseDOM.js.map +1 -1
  38. package/lib/{utils → trigger}/applyTriggerPropsToChildren.js +1 -0
  39. package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -0
  40. package/lib/{utils → trigger}/getTriggerChild.js +2 -0
  41. package/lib/trigger/getTriggerChild.js.map +1 -0
  42. package/lib/trigger/index.js +5 -0
  43. package/lib/trigger/index.js.map +1 -0
  44. package/lib/{utils → trigger}/isFluentTrigger.js +0 -0
  45. package/lib/trigger/isFluentTrigger.js.map +1 -0
  46. package/lib/trigger/types.js +2 -0
  47. package/lib/trigger/types.js.map +1 -0
  48. package/lib/utils/clamp.js +1 -0
  49. package/lib/utils/clamp.js.map +1 -1
  50. package/lib/utils/getNativeElementProps.js +3 -2
  51. package/lib/utils/getNativeElementProps.js.map +1 -1
  52. package/lib/utils/getRTLSafeKey.js +1 -0
  53. package/lib/utils/getRTLSafeKey.js.map +1 -1
  54. package/lib/utils/getReactCallbackName.js.map +1 -1
  55. package/lib/utils/index.js +0 -3
  56. package/lib/utils/index.js.map +1 -1
  57. package/lib/utils/omit.js.map +1 -1
  58. package/lib/utils/properties.js +10 -6
  59. package/lib/utils/properties.js.map +1 -1
  60. package/lib/utils/shouldPreventDefaultOnKeyDown.js +1 -0
  61. package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
  62. package/lib-commonjs/compose/getSlots.js.map +1 -1
  63. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  64. package/lib-commonjs/hooks/index.js +0 -8
  65. package/lib-commonjs/hooks/index.js.map +1 -1
  66. package/lib-commonjs/hooks/useControllableState.js +3 -3
  67. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  68. package/lib-commonjs/hooks/useEventCallback.js +1 -0
  69. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  70. package/lib-commonjs/hooks/useFirstMount.js +1 -0
  71. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  72. package/lib-commonjs/hooks/useForceUpdate.js +1 -0
  73. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  74. package/lib-commonjs/hooks/useId.js +0 -2
  75. package/lib-commonjs/hooks/useId.js.map +1 -1
  76. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +1 -0
  77. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  78. package/lib-commonjs/hooks/useMergedEventCallbacks.js +1 -0
  79. package/lib-commonjs/hooks/useMergedEventCallbacks.js.map +1 -1
  80. package/lib-commonjs/hooks/useMergedRefs.js +1 -0
  81. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  82. package/lib-commonjs/hooks/useOnClickOutside.js +2 -1
  83. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  84. package/lib-commonjs/hooks/useOnScrollOutside.js +1 -0
  85. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  86. package/lib-commonjs/hooks/usePrevious.js +4 -0
  87. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  88. package/lib-commonjs/hooks/useTimeout.js +2 -3
  89. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  90. package/lib-commonjs/index.js +8 -223
  91. package/lib-commonjs/index.js.map +1 -1
  92. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  93. package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
  94. package/lib-commonjs/{utils → trigger}/applyTriggerPropsToChildren.js +1 -0
  95. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -0
  96. package/lib-commonjs/{utils → trigger}/getTriggerChild.js +2 -0
  97. package/lib-commonjs/trigger/getTriggerChild.js.map +1 -0
  98. package/lib-commonjs/trigger/index.js +16 -0
  99. package/lib-commonjs/trigger/index.js.map +1 -0
  100. package/lib-commonjs/{utils → trigger}/isFluentTrigger.js +0 -0
  101. package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -0
  102. package/lib-commonjs/trigger/types.js +6 -0
  103. package/lib-commonjs/trigger/types.js.map +1 -0
  104. package/lib-commonjs/utils/clamp.js +1 -0
  105. package/lib-commonjs/utils/clamp.js.map +1 -1
  106. package/lib-commonjs/utils/getNativeElementProps.js +2 -1
  107. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  108. package/lib-commonjs/utils/getRTLSafeKey.js +1 -0
  109. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  110. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
  111. package/lib-commonjs/utils/index.js +0 -6
  112. package/lib-commonjs/utils/index.js.map +1 -1
  113. package/lib-commonjs/utils/omit.js.map +1 -1
  114. package/lib-commonjs/utils/properties.js +11 -7
  115. package/lib-commonjs/utils/properties.js.map +1 -1
  116. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js +1 -0
  117. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
  118. package/package.json +4 -7
  119. package/lib/compose/getSlots.d.ts +0 -30
  120. package/lib/compose/index.d.ts +0 -3
  121. package/lib/compose/resolveShorthand.d.ts +0 -16
  122. package/lib/compose/types.d.ts +0 -161
  123. package/lib/hooks/index.d.ts +0 -16
  124. package/lib/hooks/useBoolean.d.ts +0 -17
  125. package/lib/hooks/useBoolean.js +0 -28
  126. package/lib/hooks/useBoolean.js.map +0 -1
  127. package/lib/hooks/useConst.d.ts +0 -12
  128. package/lib/hooks/useConst.js +0 -30
  129. package/lib/hooks/useConst.js.map +0 -1
  130. package/lib/hooks/useControllableState.d.ts +0 -31
  131. package/lib/hooks/useEventCallback.d.ts +0 -13
  132. package/lib/hooks/useFirstMount.d.ts +0 -11
  133. package/lib/hooks/useForceUpdate.d.ts +0 -4
  134. package/lib/hooks/useId.d.ts +0 -15
  135. package/lib/hooks/useIsomorphicLayoutEffect.d.ts +0 -11
  136. package/lib/hooks/useMergedEventCallbacks.d.ts +0 -18
  137. package/lib/hooks/useMergedRefs.d.ts +0 -13
  138. package/lib/hooks/useMount.d.ts +0 -6
  139. package/lib/hooks/useMount.js +0 -17
  140. package/lib/hooks/useMount.js.map +0 -1
  141. package/lib/hooks/useOnClickOutside.d.ts +0 -29
  142. package/lib/hooks/useOnScrollOutside.d.ts +0 -5
  143. package/lib/hooks/usePrevious.d.ts +0 -1
  144. package/lib/hooks/useTimeout.d.ts +0 -8
  145. package/lib/hooks/useUnmount.d.ts +0 -6
  146. package/lib/hooks/useUnmount.js +0 -17
  147. package/lib/hooks/useUnmount.js.map +0 -1
  148. package/lib/index.d.ts +0 -8
  149. package/lib/ssr/SSRContext.d.ts +0 -33
  150. package/lib/ssr/canUseDOM.d.ts +0 -4
  151. package/lib/ssr/index.d.ts +0 -2
  152. package/lib/utils/applyTriggerPropsToChildren.d.ts +0 -5
  153. package/lib/utils/applyTriggerPropsToChildren.js.map +0 -1
  154. package/lib/utils/clamp.d.ts +0 -8
  155. package/lib/utils/getNativeElementProps.d.ts +0 -31
  156. package/lib/utils/getRTLSafeKey.d.ts +0 -4
  157. package/lib/utils/getReactCallbackName.d.ts +0 -25
  158. package/lib/utils/getTriggerChild.d.ts +0 -22
  159. package/lib/utils/getTriggerChild.js.map +0 -1
  160. package/lib/utils/index.d.ts +0 -9
  161. package/lib/utils/isFluentTrigger.d.ts +0 -22
  162. package/lib/utils/isFluentTrigger.js.map +0 -1
  163. package/lib/utils/omit.d.ts +0 -14
  164. package/lib/utils/properties.d.ts +0 -154
  165. package/lib/utils/shouldPreventDefaultOnKeyDown.d.ts +0 -7
  166. package/lib-commonjs/compose/getSlots.d.ts +0 -30
  167. package/lib-commonjs/compose/index.d.ts +0 -3
  168. package/lib-commonjs/compose/resolveShorthand.d.ts +0 -16
  169. package/lib-commonjs/compose/types.d.ts +0 -161
  170. package/lib-commonjs/hooks/index.d.ts +0 -16
  171. package/lib-commonjs/hooks/useBoolean.d.ts +0 -17
  172. package/lib-commonjs/hooks/useBoolean.js +0 -39
  173. package/lib-commonjs/hooks/useBoolean.js.map +0 -1
  174. package/lib-commonjs/hooks/useConst.d.ts +0 -12
  175. package/lib-commonjs/hooks/useConst.js +0 -40
  176. package/lib-commonjs/hooks/useConst.js.map +0 -1
  177. package/lib-commonjs/hooks/useControllableState.d.ts +0 -31
  178. package/lib-commonjs/hooks/useEventCallback.d.ts +0 -13
  179. package/lib-commonjs/hooks/useFirstMount.d.ts +0 -11
  180. package/lib-commonjs/hooks/useForceUpdate.d.ts +0 -4
  181. package/lib-commonjs/hooks/useId.d.ts +0 -15
  182. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.d.ts +0 -11
  183. package/lib-commonjs/hooks/useMergedEventCallbacks.d.ts +0 -18
  184. package/lib-commonjs/hooks/useMergedRefs.d.ts +0 -13
  185. package/lib-commonjs/hooks/useMount.d.ts +0 -6
  186. package/lib-commonjs/hooks/useMount.js +0 -27
  187. package/lib-commonjs/hooks/useMount.js.map +0 -1
  188. package/lib-commonjs/hooks/useOnClickOutside.d.ts +0 -29
  189. package/lib-commonjs/hooks/useOnScrollOutside.d.ts +0 -5
  190. package/lib-commonjs/hooks/usePrevious.d.ts +0 -1
  191. package/lib-commonjs/hooks/useTimeout.d.ts +0 -8
  192. package/lib-commonjs/hooks/useUnmount.d.ts +0 -6
  193. package/lib-commonjs/hooks/useUnmount.js +0 -27
  194. package/lib-commonjs/hooks/useUnmount.js.map +0 -1
  195. package/lib-commonjs/index.d.ts +0 -8
  196. package/lib-commonjs/ssr/SSRContext.d.ts +0 -33
  197. package/lib-commonjs/ssr/canUseDOM.d.ts +0 -4
  198. package/lib-commonjs/ssr/index.d.ts +0 -2
  199. package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +0 -5
  200. package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +0 -1
  201. package/lib-commonjs/utils/clamp.d.ts +0 -8
  202. package/lib-commonjs/utils/getNativeElementProps.d.ts +0 -31
  203. package/lib-commonjs/utils/getRTLSafeKey.d.ts +0 -4
  204. package/lib-commonjs/utils/getReactCallbackName.d.ts +0 -25
  205. package/lib-commonjs/utils/getTriggerChild.d.ts +0 -22
  206. package/lib-commonjs/utils/getTriggerChild.js.map +0 -1
  207. package/lib-commonjs/utils/index.d.ts +0 -9
  208. package/lib-commonjs/utils/isFluentTrigger.d.ts +0 -22
  209. package/lib-commonjs/utils/isFluentTrigger.js.map +0 -1
  210. package/lib-commonjs/utils/omit.d.ts +0 -14
  211. package/lib-commonjs/utils/properties.d.ts +0 -154
  212. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.d.ts +0 -7
@@ -1,161 +0,0 @@
1
- import * as React from 'react';
2
- export declare type SlotRenderFunction<Props> = (Component: React.ElementType<Props>, props: Omit<Props, 'children' | 'as'>) => React.ReactNode;
3
- /**
4
- * Matches any component's Slots type (such as ButtonSlots).
5
- *
6
- * This should ONLY be used in type templates as in `extends SlotPropsRecord`;
7
- * it shouldn't be used as a component's Slots type.
8
- */
9
- export declare type SlotPropsRecord = Record<string, UnknownSlotProps | SlotShorthandValue | null | undefined>;
10
- /**
11
- * The shorthand value of a slot allows specifying its child
12
- */
13
- export declare type SlotShorthandValue = React.ReactChild | React.ReactNodeArray | React.ReactPortal;
14
- /**
15
- * Matches any slot props type.
16
- *
17
- * This should ONLY be used in type templates as in `extends UnknownSlotProps`;
18
- * it shouldn't be used as the type of a slot.
19
- */
20
- export declare type UnknownSlotProps = Pick<React.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {
21
- as?: keyof JSX.IntrinsicElements;
22
- };
23
- /**
24
- * Helper type for {@link Slot}. Adds shorthand types that are assignable to the slot's `children`.
25
- */
26
- declare type WithSlotShorthandValue<Props extends {
27
- children?: unknown;
28
- }> = Props | Extract<SlotShorthandValue, Props['children']>;
29
- /**
30
- * Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`
31
- * to be a render function that takes those props.
32
- */
33
- declare type WithSlotRenderFunction<Props extends {
34
- children?: unknown;
35
- }> = Props & {
36
- children?: Props['children'] | SlotRenderFunction<Props>;
37
- };
38
- /**
39
- * HTML element types that are not allowed to have children.
40
- *
41
- * Reference: https://developer.mozilla.org/en-US/docs/Glossary/Empty_element
42
- */
43
- declare type EmptyIntrisicElements = 'area' | 'base' | 'br' | 'col' | 'embed' | 'hr' | 'img' | 'input' | 'link' | 'meta' | 'param' | 'source' | 'track' | 'wbr';
44
- /**
45
- * Helper type for {@link Slot}. Modifies `JSX.IntrinsicElements[Type]`:
46
- * * Removes legacy string ref.
47
- * * Disallows children for empty tags like 'img'.
48
- */
49
- declare type IntrisicElementProps<Type extends keyof JSX.IntrinsicElements> = React.PropsWithRef<JSX.IntrinsicElements[Type]> & (Type extends EmptyIntrisicElements ? {
50
- children?: never;
51
- } : {});
52
- /**
53
- * The props type and shorthand value for a slot. Type is either a single intrinsic element like `'div'`,
54
- * or a component like `typeof Button`.
55
- *
56
- * If a slot needs to support multiple intrinsic element types, use the `AlternateAs` param (see examples below).
57
- *
58
- * By default, slots can be set to `null` to prevent them from being rendered. If a slot must always be rendered,
59
- * wrap with `NonNullable` (see examples below).
60
- *
61
- * @example
62
- * ```
63
- * // Intrinsic element examples:
64
- * Slot<'div'> // Slot is always div
65
- * Slot<'button', 'a'> // Defaults to button, but allows as="a" with anchor-specific props
66
- * Slot<'span', 'div' | 'pre'> // Defaults to span, but allows as="div" or as="pre"
67
- * NonNullable<Slot<'div'>> // Slot that will always be rendered (can't be set to null by the user)
68
- *
69
- * // Component examples:
70
- * Slot<typeof Button> // Slot is always a Button, and accepts all of Button's Props
71
- * NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)
72
- * ```
73
- */
74
- export declare type Slot<Type extends keyof JSX.IntrinsicElements | React.ComponentType | UnknownSlotProps, AlternateAs extends keyof JSX.IntrinsicElements = never> = IsSingleton<Extract<Type, string>> extends true ? WithSlotShorthandValue<Type extends keyof JSX.IntrinsicElements ? {
75
- as?: Type;
76
- } & WithSlotRenderFunction<IntrisicElementProps<Type>> : Type extends React.ComponentType<infer Props> ? WithSlotRenderFunction<Props> : Type> | {
77
- [As in AlternateAs]: {
78
- as: As;
79
- } & WithSlotRenderFunction<IntrisicElementProps<As>>;
80
- }[AlternateAs] | null : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';
81
- /**
82
- * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.
83
- *
84
- * ```
85
- * IsSingleton<'a'> // true
86
- * IsSingleton<'a' | 'b' | 'c'> // false
87
- * ```
88
- */
89
- export declare type IsSingleton<T extends string> = {
90
- [K in T]: Exclude<T, K> extends never ? true : false;
91
- }[T];
92
- /**
93
- * Helper type for inferring the type of the as prop from a Props type.
94
- *
95
- * For example:
96
- * ```
97
- * type Example<T> = T extends AsIntrinsicElement<infer As> ? As : never;
98
- * ```
99
- */
100
- export declare type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = {
101
- as?: As;
102
- };
103
- /**
104
- * Converts a union type (`A | B | C`) to an intersection type (`A & B & C`)
105
- */
106
- export declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;
107
- /**
108
- * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by
109
- * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.
110
- *
111
- * The conditional "extends unknown" (always true) exploits a quirk in the way TypeScript handles conditional
112
- * types, to prevent unions from being expanded.
113
- */
114
- export declare type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;
115
- /**
116
- * Removes SlotShorthandValue and null from the slot type, extracting just the slot's Props object.
117
- */
118
- export declare type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;
119
- /**
120
- * Defines the Props type for a component given its slots and the definition of which one is the primary slot,
121
- * defaulting to root if one is not provided.
122
- */
123
- export declare type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> = Omit<Slots, Primary & 'root'> & PropsWithoutRef<ExtractSlotProps<Slots[Primary]>>;
124
- /**
125
- * If type T includes `null`, remove it and add `undefined` instead.
126
- */
127
- export declare type ReplaceNullWithUndefined<T> = T extends null ? Exclude<T, null> | undefined : T;
128
- /**
129
- * Defines the State object of a component given its slots.
130
- */
131
- export declare type ComponentState<Slots extends SlotPropsRecord> = {
132
- components: {
133
- [Key in keyof Slots]-?: React.ComponentType<ExtractSlotProps<Slots[Key]>> | (ExtractSlotProps<Slots[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
134
- };
135
- } & {
136
- [Key in keyof Slots]: ReplaceNullWithUndefined<Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>>;
137
- };
138
- /**
139
- * This is part of a hack to infer the element type from a native element *props* type.
140
- * The only place the original element is found in a native props type (at least that's workable
141
- * for inference) is in the event handlers, so some of the helper types use this event handler
142
- * name to infer the original element type.
143
- *
144
- * Notes:
145
- * - Using an extremely obscure event handler reduces the likelihood that its signature will be
146
- * modified in any component's props.
147
- * - Inferring based on a single prop name instead of a larger type like `DOMAttributes<T>` should be
148
- * less expensive for typescript to evaluate and is less likely to result in type expansion in .d.ts.
149
- */
150
- declare type ObscureEventName = 'onLostPointerCaptureCapture';
151
- /**
152
- * Return type for `React.forwardRef`, including inference of the proper typing for the ref.
153
- */
154
- export declare type ForwardRefComponent<Props> = ObscureEventName extends keyof Props ? Required<Props>[ObscureEventName] extends React.PointerEventHandler<infer Element> ? React.ForwardRefExoticComponent<Props & React.RefAttributes<Element>> : never : never;
155
- /**
156
- * Helper type to correctly define the slot class names object.
157
- */
158
- export declare type SlotClassNames<Slots> = {
159
- [SlotName in keyof Slots]-?: string;
160
- };
161
- export {};
@@ -1,16 +0,0 @@
1
- export * from './useBoolean';
2
- export * from './useConst';
3
- export * from './useControllableState';
4
- export * from './useEventCallback';
5
- export * from './useFirstMount';
6
- export * from './useForceUpdate';
7
- export * from './useId';
8
- export * from './useIsomorphicLayoutEffect';
9
- export * from './useMergedEventCallbacks';
10
- export * from './useMergedRefs';
11
- export * from './useMount';
12
- export * from './useOnClickOutside';
13
- export * from './useOnScrollOutside';
14
- export * from './usePrevious';
15
- export * from './useTimeout';
16
- export * from './useUnmount';
@@ -1,17 +0,0 @@
1
- /** Updater callbacks returned by `useBoolean`. */
2
- export declare type UseBooleanCallbacks = {
3
- /** Set the value to true. Always has the same identity. */
4
- setTrue: () => void;
5
- /** Set the value to false. Always has the same identity. */
6
- setFalse: () => void;
7
- /** Toggle the value. Always has the same identity. */
8
- toggle: () => void;
9
- };
10
- /**
11
- * Hook to store a value and generate callbacks for setting the value to true or false.
12
- * The identity of the callbacks will always stay the same.
13
- *
14
- * @param initialState - Initial value
15
- * @returns Array with the current value and an object containing the updater callbacks.
16
- */
17
- export declare function useBoolean(initialState: boolean): [boolean, UseBooleanCallbacks];
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useBoolean = void 0;
7
-
8
- const React = /*#__PURE__*/require("react");
9
-
10
- const useConst_1 = /*#__PURE__*/require("./useConst");
11
- /**
12
- * Hook to store a value and generate callbacks for setting the value to true or false.
13
- * The identity of the callbacks will always stay the same.
14
- *
15
- * @param initialState - Initial value
16
- * @returns Array with the current value and an object containing the updater callbacks.
17
- */
18
-
19
-
20
- function useBoolean(initialState) {
21
- const [value, setValue] = React.useState(initialState);
22
- const setTrue = useConst_1.useConst(() => () => {
23
- setValue(true);
24
- });
25
- const setFalse = useConst_1.useConst(() => () => {
26
- setValue(false);
27
- });
28
- const toggle = useConst_1.useConst(() => () => {
29
- setValue(currentValue => !currentValue);
30
- });
31
- return [value, {
32
- setTrue,
33
- setFalse,
34
- toggle
35
- }];
36
- }
37
-
38
- exports.useBoolean = useBoolean;
39
- //# sourceMappingURL=useBoolean.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["hooks/useBoolean.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,UAAA,gBAAA,OAAA,CAAA,YAAA,CAAA;AAYA;;;;;;AAMG;;;AACH,SAAgB,UAAhB,CAA2B,YAA3B,EAAgD;AAC9C,QAAM,CAAC,KAAD,EAAQ,QAAR,IAAoB,KAAK,CAAC,QAAN,CAAe,YAAf,CAA1B;AAEA,QAAM,OAAO,GAAG,UAAA,CAAA,QAAA,CAAS,MAAM,MAAK;AAClC,IAAA,QAAQ,CAAC,IAAD,CAAR;AACD,GAFe,CAAhB;AAGA,QAAM,QAAQ,GAAG,UAAA,CAAA,QAAA,CAAS,MAAM,MAAK;AACnC,IAAA,QAAQ,CAAC,KAAD,CAAR;AACD,GAFgB,CAAjB;AAGA,QAAM,MAAM,GAAG,UAAA,CAAA,QAAA,CAAS,MAAM,MAAK;AACjC,IAAA,QAAQ,CAAC,YAAY,IAAI,CAAC,YAAlB,CAAR;AACD,GAFc,CAAf;AAIA,SAAO,CAAC,KAAD,EAAQ;AAAE,IAAA,OAAF;AAAW,IAAA,QAAX;AAAqB,IAAA;AAArB,GAAR,CAAP;AACD;;AAdD,OAAA,CAAA,UAAA,GAAA,UAAA","sourcesContent":["import * as React from 'react';\nimport { useConst } from './useConst';\n\n/** Updater callbacks returned by `useBoolean`. */\nexport type UseBooleanCallbacks = {\n /** Set the value to true. Always has the same identity. */\n setTrue: () => void;\n /** Set the value to false. Always has the same identity. */\n setFalse: () => void;\n /** Toggle the value. Always has the same identity. */\n toggle: () => void;\n};\n\n/**\n * Hook to store a value and generate callbacks for setting the value to true or false.\n * The identity of the callbacks will always stay the same.\n *\n * @param initialState - Initial value\n * @returns Array with the current value and an object containing the updater callbacks.\n */\nexport function useBoolean(initialState: boolean): [boolean, UseBooleanCallbacks] {\n const [value, setValue] = React.useState(initialState);\n\n const setTrue = useConst(() => () => {\n setValue(true);\n });\n const setFalse = useConst(() => () => {\n setValue(false);\n });\n const toggle = useConst(() => () => {\n setValue(currentValue => !currentValue);\n });\n\n return [value, { setTrue, setFalse, toggle }];\n}\n"],"sourceRoot":"../src/"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Hook to initialize and return a constant value. Unlike `React.useMemo`, this is guaranteed to
3
- * always return the same value (and if the initializer is a function, only call it once).
4
- * This is similar to setting a private member in a class constructor.
5
- *
6
- * If the value should ever change based on dependencies, use `React.useMemo` instead.
7
- *
8
- * @param initialValue - Initial value, or function to get the initial value. Similar to `useState`,
9
- * only the value/function passed in the first time this is called is respected.
10
- * @returns The value. The identity of this value will always be the same.
11
- */
12
- export declare function useConst<T>(initialValue: T | (() => T)): T;
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useConst = void 0;
7
-
8
- const React = /*#__PURE__*/require("react");
9
- /**
10
- * Hook to initialize and return a constant value. Unlike `React.useMemo`, this is guaranteed to
11
- * always return the same value (and if the initializer is a function, only call it once).
12
- * This is similar to setting a private member in a class constructor.
13
- *
14
- * If the value should ever change based on dependencies, use `React.useMemo` instead.
15
- *
16
- * @param initialValue - Initial value, or function to get the initial value. Similar to `useState`,
17
- * only the value/function passed in the first time this is called is respected.
18
- * @returns The value. The identity of this value will always be the same.
19
- */
20
-
21
-
22
- function useConst(initialValue) {
23
- // Use useRef to store the value because it's the least expensive built-in hook that works here
24
- // (we could also use `const [value] = React.useState(initialValue)` but that's more expensive
25
- // internally due to reducer handling which we don't need)
26
- const ref = React.useRef();
27
-
28
- if (ref.current === undefined) {
29
- // Box the value in an object so we can tell if it's initialized even if the initializer
30
- // returns/is undefined
31
- ref.current = {
32
- value: typeof initialValue === 'function' ? initialValue() : initialValue
33
- };
34
- }
35
-
36
- return ref.current.value;
37
- }
38
-
39
- exports.useConst = useConst;
40
- //# sourceMappingURL=useConst.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["hooks/useConst.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAEA;;;;;;;;;;AAUG;;;AACH,SAAgB,QAAhB,CAA4B,YAA5B,EAAuD;AACrD;AACA;AACA;AACA,QAAM,GAAG,GAAG,KAAK,CAAC,MAAN,EAAZ;;AACA,MAAI,GAAG,CAAC,OAAJ,KAAgB,SAApB,EAA+B;AAC7B;AACA;AACA,IAAA,GAAG,CAAC,OAAJ,GAAc;AACZ,MAAA,KAAK,EAAE,OAAO,YAAP,KAAwB,UAAxB,GAAsC,YAAyB,EAA/D,GAAoE;AAD/D,KAAd;AAGD;;AACD,SAAO,GAAG,CAAC,OAAJ,CAAY,KAAnB;AACD;;AAbD,OAAA,CAAA,QAAA,GAAA,QAAA","sourcesContent":["import * as React from 'react';\n\n/**\n * Hook to initialize and return a constant value. Unlike `React.useMemo`, this is guaranteed to\n * always return the same value (and if the initializer is a function, only call it once).\n * This is similar to setting a private member in a class constructor.\n *\n * If the value should ever change based on dependencies, use `React.useMemo` instead.\n *\n * @param initialValue - Initial value, or function to get the initial value. Similar to `useState`,\n * only the value/function passed in the first time this is called is respected.\n * @returns The value. The identity of this value will always be the same.\n */\nexport function useConst<T>(initialValue: T | (() => T)): T {\n // Use useRef to store the value because it's the least expensive built-in hook that works here\n // (we could also use `const [value] = React.useState(initialValue)` but that's more expensive\n // internally due to reducer handling which we don't need)\n const ref = React.useRef<{ value: T }>();\n if (ref.current === undefined) {\n // Box the value in an object so we can tell if it's initialized even if the initializer\n // returns/is undefined\n ref.current = {\n value: typeof initialValue === 'function' ? (initialValue as Function)() : initialValue,\n };\n }\n return ref.current.value;\n}\n"],"sourceRoot":"../src/"}
@@ -1,31 +0,0 @@
1
- import * as React from 'react';
2
- export declare type UseControllableStateOptions<State> = {
3
- /**
4
- * User-provided default state or initializer, for uncontrolled usage.
5
- */
6
- defaultState?: State | (() => State);
7
- /**
8
- * User-provided controlled state. `undefined` means internal state will be used.
9
- */
10
- state: State | undefined;
11
- /**
12
- * Used as the initial state if `state` and `defaultState` are both `undefined`.
13
- * If `undefined` is the correct initial state, pass that here.
14
- */
15
- initialState: State;
16
- };
17
- /**
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
30
- */
31
- export declare const useControllableState: <State>(options: UseControllableStateOptions<State>) => [State, React.Dispatch<React.SetStateAction<State>>];
@@ -1,13 +0,0 @@
1
- /**
2
- * https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
3
- *
4
- * Modified `useCallback` that can be used when dependencies change too frequently. Can occur when
5
- * e.g. user props are dependencies which could change on every render
6
- * e.g. volatile values (i.e. useState/useDispatch) are dependencies which could change frequently
7
- *
8
- * This should not be used often, but can be a useful re-render optimization since the callback is a ref and
9
- * will not be invalidated between re-renders
10
- *
11
- * @param fn - The callback function that will be used
12
- */
13
- export declare const useEventCallback: <Args extends unknown[], Return>(fn: (...args: Args) => Return) => (...args: Args) => Return;
@@ -1,11 +0,0 @@
1
- /**
2
- * Checks if components was mounted the first time.
3
- * Since concurrent mode will be released in the future this needs to be verified
4
- * Currently (React 17) will always render the initial mount once
5
- * https://codesandbox.io/s/heuristic-brook-s4w0q?file=/src/App.jsx
6
- * https://codesandbox.io/s/holy-grass-8nieu?file=/src/App.jsx
7
- *
8
- * @example
9
- * const isFirstMount = useFirstMount();
10
- */
11
- export declare function useFirstMount(): boolean;
@@ -1,4 +0,0 @@
1
- /**
2
- * Forces a re-render, similar to `forceUpdate` in class components.
3
- */
4
- export declare function useForceUpdate(): import("react").DispatchWithoutAction;
@@ -1,15 +0,0 @@
1
- /**
2
- * Resets generated IDs, should be used only in tests.
3
- *
4
- * @private
5
- */
6
- export declare function resetIdsForTests(): void;
7
- /**
8
- * Hook to generate a unique ID.
9
- *
10
- * @param prefix - Optional prefix for the ID. Defaults to 'fui-'.
11
- * @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,
12
- * without conditioning the hook call
13
- * @returns The ID
14
- */
15
- export declare function useId(prefix?: string, providedId?: string): string;
@@ -1,11 +0,0 @@
1
- import * as React from 'react';
2
- /**
3
- * React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally
4
- * useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to
5
- * ensure we don't get a render flash for certain operations, but we may also need affected components to render on
6
- * the server.
7
- *
8
- * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
9
- * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
10
- */
11
- export declare const useIsomorphicLayoutEffect: typeof React.useEffect;
@@ -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>;
@@ -1,6 +0,0 @@
1
- /**
2
- * Hook which asynchronously executes a callback once the component has been mounted.
3
- *
4
- * @param callback - Function to call before mount.
5
- */
6
- export declare const useMount: (callback: () => void) => void;
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useMount = void 0;
7
-
8
- const React = /*#__PURE__*/require("react");
9
- /**
10
- * Hook which asynchronously executes a callback once the component has been mounted.
11
- *
12
- * @param callback - Function to call before mount.
13
- */
14
-
15
-
16
- const useMount = callback => {
17
- const mountRef = React.useRef(callback);
18
- mountRef.current = callback;
19
- React.useEffect(() => {
20
- var _a;
21
-
22
- (_a = mountRef.current) === null || _a === void 0 ? void 0 : _a.call(mountRef);
23
- }, []);
24
- };
25
-
26
- exports.useMount = useMount;
27
- //# sourceMappingURL=useMount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["hooks/useMount.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAEA;;;;AAIG;;;AACI,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;;AAAM,OAAA,CAAA,QAAA,GAAQ,QAAR","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,5 +0,0 @@
1
- import type { UseOnClickOrScrollOutsideOptions } from './useOnClickOutside';
2
- /**
3
- * Utility to perform checks where a click/touch event was made outside a component
4
- */
5
- export declare const useOnScrollOutside: (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];
@@ -1,6 +0,0 @@
1
- /**
2
- * Hook which synchronously executes a callback when the component is about to unmount.
3
- *
4
- * @param callback - Function to call during unmount.
5
- */
6
- export declare const useUnmount: (callback: () => void) => void;
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useUnmount = void 0;
7
-
8
- const React = /*#__PURE__*/require("react");
9
- /**
10
- * Hook which synchronously executes a callback when the component is about to unmount.
11
- *
12
- * @param callback - Function to call during unmount.
13
- */
14
-
15
-
16
- const useUnmount = callback => {
17
- const unmountRef = React.useRef(callback);
18
- unmountRef.current = callback;
19
- React.useEffect(() => () => {
20
- var _a;
21
-
22
- (_a = unmountRef.current) === null || _a === void 0 ? void 0 : _a.call(unmountRef);
23
- }, []);
24
- };
25
-
26
- exports.useUnmount = useUnmount;
27
- //# sourceMappingURL=useUnmount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["hooks/useUnmount.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAEA;;;;AAIG;;;AACI,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;;AAAM,OAAA,CAAA,UAAA,GAAU,UAAV","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/"}
@@ -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';
@@ -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;
@@ -1,4 +0,0 @@
1
- /**
2
- * Verifies if an application can use DOM.
3
- */
4
- export declare function canUseDOM(): boolean;
@@ -1,2 +0,0 @@
1
- export * from './canUseDOM';
2
- export * from './SSRContext';
@@ -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,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,mBAAA,CAAA;AAEA;;AAEG;;;AACI,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;;AAAM,OAAA,CAAA,2BAAA,GAA2B,2BAA3B;AAgBb;;;AAGG;;AACH,MAAM,gBAAgB,GAAG,CAAgB,KAAhB,EAAwC,YAAxC,KAA2F;AAClH,MAAI,CAAC,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,iBAAA,CAAA,eAAA,CAAgB,KAAhB,CAAJ,EAA4B;AAC1B,UAAM,UAAU,GAAG,gBAAgB,CAAC,KAAK,CAAC,KAAN,CAAY,QAAb,EAAuB,YAAvB,CAAnC;AACA,WAAO,KAAK,CAAC,YAAN,CAAmB,KAAnB,EAA0B,SAA1B,EAAqC,UAArC,CAAP;AACD,GAHD,MAGO;AACL,WAAO,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/"}