@fluentui/react-utilities 0.0.0-nightlyfbae36b19b20211111.1 → 0.0.0-nightlyfc5cfdc52420220215.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 (104) hide show
  1. package/CHANGELOG.json +162 -9
  2. package/CHANGELOG.md +43 -6
  3. package/dist/react-utilities.d.ts +232 -105
  4. package/lib/compose/getSlots.d.ts +11 -10
  5. package/lib/compose/getSlots.js +7 -6
  6. package/lib/compose/getSlots.js.map +1 -1
  7. package/lib/compose/index.d.ts +0 -1
  8. package/lib/compose/index.js +0 -1
  9. package/lib/compose/index.js.map +1 -1
  10. package/lib/compose/resolveShorthand.d.ts +10 -6
  11. package/lib/compose/resolveShorthand.js +5 -5
  12. package/lib/compose/resolveShorthand.js.map +1 -1
  13. package/lib/compose/types.d.ts +86 -35
  14. package/lib/compose/types.js.map +1 -1
  15. package/lib/hooks/index.d.ts +1 -1
  16. package/lib/hooks/index.js +1 -1
  17. package/lib/hooks/index.js.map +1 -1
  18. package/lib/hooks/useControllableState.d.ts +16 -6
  19. package/lib/hooks/useControllableState.js +13 -8
  20. package/lib/hooks/useControllableState.js.map +1 -1
  21. package/lib/hooks/useMergedEventCallbacks.d.ts +18 -0
  22. package/lib/hooks/useMergedEventCallbacks.js +26 -0
  23. package/lib/hooks/useMergedEventCallbacks.js.map +1 -0
  24. package/lib/hooks/useOnClickOutside.js.map +1 -1
  25. package/lib/utils/applyTriggerPropsToChildren.d.ts +1 -1
  26. package/lib/utils/applyTriggerPropsToChildren.js +23 -3
  27. package/lib/utils/applyTriggerPropsToChildren.js.map +1 -1
  28. package/lib/utils/getNativeElementProps.d.ts +22 -0
  29. package/lib/utils/getNativeElementProps.js +22 -0
  30. package/lib/utils/getNativeElementProps.js.map +1 -1
  31. package/lib/utils/getReactCallbackName.d.ts +25 -0
  32. package/lib/utils/getReactCallbackName.js +26 -0
  33. package/lib/utils/getReactCallbackName.js.map +1 -0
  34. package/lib/utils/getTriggerChild.d.ts +22 -0
  35. package/lib/utils/getTriggerChild.js +26 -0
  36. package/lib/utils/getTriggerChild.js.map +1 -0
  37. package/lib/utils/index.d.ts +2 -1
  38. package/lib/utils/index.js +2 -1
  39. package/lib/utils/index.js.map +1 -1
  40. package/lib/utils/isFluentTrigger.d.ts +22 -0
  41. package/lib/utils/isFluentTrigger.js +8 -0
  42. package/lib/utils/isFluentTrigger.js.map +1 -0
  43. package/lib/utils/properties.js +40 -20
  44. package/lib/utils/properties.js.map +1 -1
  45. package/lib-commonjs/compose/getSlots.d.ts +11 -10
  46. package/lib-commonjs/compose/getSlots.js +7 -7
  47. package/lib-commonjs/compose/getSlots.js.map +1 -1
  48. package/lib-commonjs/compose/index.d.ts +0 -1
  49. package/lib-commonjs/compose/index.js +0 -2
  50. package/lib-commonjs/compose/index.js.map +1 -1
  51. package/lib-commonjs/compose/resolveShorthand.d.ts +10 -6
  52. package/lib-commonjs/compose/resolveShorthand.js +5 -5
  53. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  54. package/lib-commonjs/compose/types.d.ts +86 -35
  55. package/lib-commonjs/compose/types.js.map +1 -1
  56. package/lib-commonjs/hooks/index.d.ts +1 -1
  57. package/lib-commonjs/hooks/index.js +2 -2
  58. package/lib-commonjs/hooks/index.js.map +1 -1
  59. package/lib-commonjs/hooks/useControllableState.d.ts +16 -6
  60. package/lib-commonjs/hooks/useControllableState.js +13 -8
  61. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  62. package/lib-commonjs/hooks/useMergedEventCallbacks.d.ts +18 -0
  63. package/lib-commonjs/hooks/useMergedEventCallbacks.js +36 -0
  64. package/lib-commonjs/hooks/useMergedEventCallbacks.js.map +1 -0
  65. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  66. package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +1 -1
  67. package/lib-commonjs/utils/applyTriggerPropsToChildren.js +24 -4
  68. package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +1 -1
  69. package/lib-commonjs/utils/getNativeElementProps.d.ts +22 -0
  70. package/lib-commonjs/utils/getNativeElementProps.js +25 -1
  71. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  72. package/lib-commonjs/utils/getReactCallbackName.d.ts +25 -0
  73. package/lib-commonjs/utils/getReactCallbackName.js +35 -0
  74. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -0
  75. package/lib-commonjs/utils/getTriggerChild.d.ts +22 -0
  76. package/lib-commonjs/utils/getTriggerChild.js +37 -0
  77. package/lib-commonjs/utils/getTriggerChild.js.map +1 -0
  78. package/lib-commonjs/utils/index.d.ts +2 -1
  79. package/lib-commonjs/utils/index.js +4 -2
  80. package/lib-commonjs/utils/index.js.map +1 -1
  81. package/lib-commonjs/utils/isFluentTrigger.d.ts +22 -0
  82. package/lib-commonjs/utils/isFluentTrigger.js +17 -0
  83. package/lib-commonjs/utils/isFluentTrigger.js.map +1 -0
  84. package/lib-commonjs/utils/properties.js +40 -20
  85. package/lib-commonjs/utils/properties.js.map +1 -1
  86. package/package.json +6 -11
  87. package/lib/compose/nullRender.d.ts +0 -4
  88. package/lib/compose/nullRender.js +0 -5
  89. package/lib/compose/nullRender.js.map +0 -1
  90. package/lib/hooks/useControllableValue.d.ts +0 -20
  91. package/lib/hooks/useControllableValue.js +0 -57
  92. package/lib/hooks/useControllableValue.js.map +0 -1
  93. package/lib/utils/onlyChild.d.ts +0 -5
  94. package/lib/utils/onlyChild.js +0 -13
  95. package/lib/utils/onlyChild.js.map +0 -1
  96. package/lib-commonjs/compose/nullRender.d.ts +0 -4
  97. package/lib-commonjs/compose/nullRender.js +0 -14
  98. package/lib-commonjs/compose/nullRender.js.map +0 -1
  99. package/lib-commonjs/hooks/useControllableValue.d.ts +0 -20
  100. package/lib-commonjs/hooks/useControllableValue.js +0 -68
  101. package/lib-commonjs/hooks/useControllableValue.js.map +0 -1
  102. package/lib-commonjs/utils/onlyChild.d.ts +0 -5
  103. package/lib-commonjs/utils/onlyChild.js +0 -23
  104. package/lib-commonjs/utils/onlyChild.js.map +0 -1
@@ -11,7 +11,7 @@ export declare const anchorProperties: Record<string, number>;
11
11
  /**
12
12
  * Apply the trigger props to the children, either by calling the render function, or cloning with the new props.
13
13
  */
14
- export declare const applyTriggerPropsToChildren: <TTriggerProps>(children: React_2.ReactElement<any, string | ((props: any) => React_2.ReactElement<any, string | any | (new (props: any) => React_2.Component<any, any, any>)> | null) | (new (props: any) => React_2.Component<any, any, any>)> | ((props: TTriggerProps) => React_2.ReactNode) | null | undefined, triggerProps: TTriggerProps) => React_2.ReactNode;
14
+ export declare const applyTriggerPropsToChildren: <TTriggerProps>(children: React_2.ReactElement<any, string | React_2.JSXElementConstructor<any>> | ((props: TTriggerProps) => React_2.ReactElement | null) | null | undefined, triggerProps: TTriggerProps) => React_2.ReactElement | null;
15
15
 
16
16
  /**
17
17
  * Helper type for inferring the type of the as prop from a Props type.
@@ -58,8 +58,6 @@ export declare const buttonProperties: Record<string, number>;
58
58
  */
59
59
  export declare function canUseDOM(): boolean;
60
60
 
61
- export declare type ChangeCallback<TElement extends HTMLElement, TValue, TEvent extends React_2.SyntheticEvent<TElement> | undefined> = (ev: TEvent, newValue: TValue | undefined) => void;
62
-
63
61
  /**
64
62
  * Clamps `value` to a number between the min and max.
65
63
  *
@@ -73,26 +71,22 @@ export declare const colGroupProperties: Record<string, number>;
73
71
 
74
72
  export declare const colProperties: Record<string, number>;
75
73
 
76
- export declare type ComponentProps<Shorthands extends ObjectShorthandPropsRecord, Primary extends keyof Shorthands = 'root'> = Omit<{
77
- [Key in keyof Shorthands]?: ShorthandProps<NonNullable<Shorthands[Key]>>;
78
- }, Primary> & PropsWithoutRef<Shorthands[Primary]>;
79
-
80
- export declare type ComponentState<Shorthands extends ObjectShorthandPropsRecord> = {
81
- components?: {
82
- [Key in keyof Shorthands]-?: React_2.ComponentType<NonNullable<Shorthands[Key]> extends ObjectShorthandProps<infer P> ? P : NonNullable<Shorthands[Key]>> | (NonNullable<Shorthands[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
83
- };
84
- } & Shorthands;
74
+ /**
75
+ * Defines the Props type for a component given its slots and the definition of which one is the primary slot,
76
+ * defaulting to root if one is not provided.
77
+ */
78
+ export declare type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> = Omit<Slots, Primary & 'root'> & PropsWithoutRef<ExtractSlotProps<Slots[Primary]>>;
85
79
 
86
80
  /**
87
- * Matches any shorthand props type.
88
- *
89
- * This should ONLY be used in type templates as in `extends DefaultObjectShorthandProps`;
90
- * it shouldn't be used as the type of a slot.
81
+ * Defines the State object of a component given its slots.
91
82
  */
92
- export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{
93
- children?: React_2.ReactNode;
94
- as?: keyof JSX.IntrinsicElements;
95
- }>;
83
+ export declare type ComponentState<Slots extends SlotPropsRecord> = {
84
+ components: {
85
+ [Key in keyof Slots]-?: React_2.ComponentType<ExtractSlotProps<Slots[Key]>> | (ExtractSlotProps<Slots[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
86
+ };
87
+ } & {
88
+ [Key in keyof Slots]: ReplaceNullWithUndefined<Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>>;
89
+ };
96
90
 
97
91
  /**
98
92
  * Default context value to use in case there is no SSRProvider. This is fine for client-only apps.
@@ -101,11 +95,6 @@ export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{
101
95
  */
102
96
  export declare const defaultSSRContextValue: SSRContextValue;
103
97
 
104
- /**
105
- * Default value can be a value or an initializer
106
- */
107
- declare type DefaultValue<TValue> = TValue | (() => TValue);
108
-
109
98
  /**
110
99
  * An array of DIV tag properties and events.
111
100
  *
@@ -113,6 +102,35 @@ declare type DefaultValue<TValue> = TValue | (() => TValue);
113
102
  */
114
103
  export declare const divProperties: Record<string, number>;
115
104
 
105
+ /**
106
+ * HTML element types that are not allowed to have children.
107
+ *
108
+ * Reference: https://developer.mozilla.org/en-US/docs/Glossary/Empty_element
109
+ */
110
+ declare type EmptyIntrisicElements = 'area' | 'base' | 'br' | 'col' | 'embed' | 'hr' | 'img' | 'input' | 'link' | 'meta' | 'param' | 'source' | 'track' | 'wbr';
111
+
112
+ /**
113
+ * Removes SlotShorthandValue and null from the slot type, extracting just the slot's Props object.
114
+ */
115
+ export declare type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;
116
+
117
+ /**
118
+ * Allows a component to be tagged as a FluentUI trigger component.
119
+ *
120
+ * Triggers are special-case components: they attach event listeners and other props on their child,
121
+ * and use them to trigger another component to show. Examples include `MenuTrigger` and `Tooltip`.
122
+ *
123
+ * A component can be tagged as a trigger as follows:
124
+ * ```ts
125
+ * const MyComponent: React.FC<MyComponentProps> & FluentTriggerComponent = ...;
126
+ *
127
+ * MyComponent.isFluentTriggerComponent = true; // MUST also set this to true
128
+ * ```
129
+ */
130
+ export declare type FluentTriggerComponent = {
131
+ isFluentTriggerComponent?: boolean;
132
+ };
133
+
116
134
  /**
117
135
  * An array of FORM tag properties and events.
118
136
  *
@@ -150,6 +168,29 @@ export declare function getNativeElementProps<TAttributes extends React_2.HTMLAt
150
168
  */
151
169
  export declare function getNativeProps<T extends Record<string, any>>(props: Record<string, any>, allowedPropNames: string[] | Record<string, number>, excludedPropNames?: string[]): T;
152
170
 
171
+ /**
172
+ * Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
173
+ *
174
+ * This function is only for use with components that have a primary slot other than `root`.
175
+ * Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.
176
+ *
177
+ * @returns An object containing the native props for the `root` and primary slots.
178
+ */
179
+ export declare const getPartitionedNativeProps: <Props extends Pick<React_2.HTMLAttributes<HTMLElement>, "style" | "className">, ExcludedPropKeys extends Extract<keyof Props, string> = never>({ primarySlotTagName, props, excludedPropNames, }: {
180
+ /** The primary slot's element type (e.g. 'div') */
181
+ primarySlotTagName: keyof JSX.IntrinsicElements;
182
+ /** The component's props object */
183
+ props: Props;
184
+ /** List of native props to exclude from the returned value */
185
+ excludedPropNames?: ExcludedPropKeys[] | undefined;
186
+ }) => {
187
+ root: {
188
+ style: React_2.CSSProperties | undefined;
189
+ className: string | undefined;
190
+ };
191
+ primary: Omit<Props, ExcludedPropKeys>;
192
+ };
193
+
153
194
  /**
154
195
  * Finds and swaps a provided key for it's right to left format.
155
196
  */
@@ -164,16 +205,39 @@ export declare const getRTLSafeKey: (key: string, dir: 'ltr' | 'rtl') => string;
164
205
  * Slots will render as null if they are rendered as primitives with undefined children.
165
206
  *
166
207
  * The slotProps will always omit the `as` prop within them, and for slots that are string
167
- * primitives, the props will be filtered according the the slot type. For example, if the
168
- * slot is rendered `as: 'a'`, the props will be filtered for acceptable anchor props.
208
+ * primitives, the props will be filtered according to the slot type by the type system.
209
+ * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable
210
+ * anchor props. Note that this is only enforced at build time by Typescript -- there is no
211
+ * runtime code filtering props in this function.
169
212
  *
170
213
  * @param state - State including slot definitions
171
- * @param slotNames - Name of which props are slots
172
214
  * @returns An object containing the `slots` map and `slotProps` map.
173
215
  */
174
- export declare function getSlots<R extends ObjectShorthandPropsRecord>(state: ComponentState<R>, slotNames?: (keyof R)[]): {
216
+ export declare function getSlots<R extends SlotPropsRecord>(state: ComponentState<R>): {
175
217
  slots: Slots<R>;
176
- slotProps: SlotProps<R>;
218
+ slotProps: ObjectSlotProps<R>;
219
+ };
220
+
221
+ /**
222
+ * Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).
223
+ *
224
+ * In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,
225
+ * it returns the first descendant that is _not_ a FluentTriggerComponent or Fragment.
226
+ * This allows multiple triggers to be stacked, and still apply their props to the actual trigger element.
227
+ *
228
+ * For example, the following returns `<div id="child" />`:
229
+ * ```jsx
230
+ * getTriggerChild(
231
+ * <Tooltip>
232
+ * <MenuTrigger>
233
+ * <div id="child" />
234
+ * </MenuTrigger>
235
+ * </Tooltip>
236
+ * );
237
+ * ```
238
+ */
239
+ export declare const getTriggerChild: (children: React_2.ReactNode) => React_2.ReactElement & {
240
+ ref?: React_2.Ref<unknown>;
177
241
  };
178
242
 
179
243
  /**
@@ -210,25 +274,19 @@ export declare const imgProperties: Record<string, number>;
210
274
  export declare const inputProperties: Record<string, number>;
211
275
 
212
276
  /**
213
- * Define the slot arguments for a slot that supports one or more intrinsic element types, such as 'div'.
214
- * For slots that support custom components, use {@link ObjectShorthandProps} instead.
215
- *
216
- * The first param is the slot's default type if no `as` prop is specified.
217
- * The second param is an optional union of alternative types that can be specified for the `as` prop.
218
- *
219
- * ```
220
- * IntrinsicShorthandProps<'div'> // Slot is always div
221
- * IntrinsicShorthandProps<'button', 'a'> // Defaults to button, but allows as="a" with anchor-specific props
222
- * IntrinsicShorthandProps<'label', 'span' | 'div'>; // Defaults to label, but allows as="span" or as="div"
223
- * ```
277
+ * Helper type for {@link Slot}. Modifies `JSX.IntrinsicElements[Type]`:
278
+ * * Removes legacy string ref.
279
+ * * Disallows children for empty tags like 'img'.
224
280
  */
225
- 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' : ({
226
- as?: DefaultAs;
227
- } & ObjectShorthandProps<React_2.PropsWithRef<JSX.IntrinsicElements[DefaultAs]>>) | {
228
- [As in AlternateAs]: {
229
- as: As;
230
- } & ObjectShorthandProps<React_2.PropsWithRef<JSX.IntrinsicElements[As]>>;
231
- }[AlternateAs];
281
+ declare type IntrisicElementProps<Type extends keyof JSX.IntrinsicElements> = React_2.PropsWithRef<JSX.IntrinsicElements[Type]> & (Type extends EmptyIntrisicElements ? {
282
+ children?: never;
283
+ } : {});
284
+
285
+ /**
286
+ * Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).
287
+ * See the {@link FluentTriggerComponent} type for more info.
288
+ */
289
+ export declare const isFluentTrigger: (element: React_2.ReactElement) => boolean | undefined;
232
290
 
233
291
  /**
234
292
  * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.
@@ -256,24 +314,10 @@ export declare const labelProperties: Record<string, number>;
256
314
  */
257
315
  export declare const liProperties: Record<string, number>;
258
316
 
259
- /**
260
- * Simple constant function for returning null, used to render empty templates in JSX.
261
- */
262
- export declare const nullRender: () => null;
263
-
264
- /**
265
- * Defines the slot props for a slot that supports a Component type.
266
- *
267
- * For intrinsic elements like 'div', use {@link IntrinsicShorthandProps} instead.
268
- */
269
- export declare type ObjectShorthandProps<Props extends {
270
- children?: React_2.ReactNode;
271
- } = {}> = Props & {
272
- children?: Props['children'] | ShorthandRenderFunction<Props>;
317
+ declare type ObjectSlotProps<S extends SlotPropsRecord> = {
318
+ [K in keyof S]-?: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As> ? UnionToIntersection<JSX.IntrinsicElements[As]> : ExtractSlotProps<S[K]> extends React_2.ComponentType<infer P> ? P : never;
273
319
  };
274
320
 
275
- export declare type ObjectShorthandPropsRecord = Record<string, DefaultObjectShorthandProps | undefined>;
276
-
277
321
  /**
278
322
  * This is part of a hack to infer the element type from a native element *props* type.
279
323
  * The only place the original element is found in a native props type (at least that's workable
@@ -310,16 +354,11 @@ export declare const olProperties: Record<string, number>;
310
354
  */
311
355
  export declare function omit<TObj extends Record<string, any>, Exclusions extends (keyof TObj)[]>(obj: TObj, exclusions: Exclusions): Omit<TObj, Exclusions[number]>;
312
356
 
313
- /**
314
- * Similar to React.Children.only, but drills into fragments rather than treating them as a single child
315
- */
316
- export declare const onlyChild: <P>(child: string | number | boolean | {} | React_2.ReactNodeArray | React_2.ReactPortal | React_2.ReactElement<P, string | ((props: any) => React_2.ReactElement<any, string | any | (new (props: any) => React_2.Component<any, any, any>)> | null) | (new (props: any) => React_2.Component<any, any, any>)> | null | undefined) => React_2.ReactElement<P, string | ((props: any) => React_2.ReactElement<any, string | any | (new (props: any) => React_2.Component<any, any, any>)> | null) | (new (props: any) => React_2.Component<any, any, any>)>;
317
-
318
357
  export declare const optionProperties: Record<string, number>;
319
358
 
320
359
  /**
321
360
  * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by
322
- * IntrinsicShorthandProps). This allows IntrinsicShorthandProps to be used with React.forwardRef.
361
+ * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.
323
362
  *
324
363
  * The conditional "extends unknown" (always true) exploits a quirk in the way TypeScript handles conditional
325
364
  * types, to prevent unions from being expanded.
@@ -332,6 +371,11 @@ export declare type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unkn
332
371
  */
333
372
  export declare type RefObjectFunction<T> = React_2.RefObject<T> & ((value: T) => void);
334
373
 
374
+ /**
375
+ * If type T includes `null`, remove it and add `undefined` instead.
376
+ */
377
+ export declare type ReplaceNullWithUndefined<T> = T extends null ? Exclude<T, null> | undefined : T;
378
+
335
379
  /**
336
380
  * Resets generated IDs, should be used only in tests.
337
381
  *
@@ -340,14 +384,19 @@ export declare type RefObjectFunction<T> = React_2.RefObject<T> & ((value: T) =>
340
384
  export declare function resetIdsForTests(): void;
341
385
 
342
386
  /**
343
- * Resolves ShorthandProps into ObjectShorthandProps, to ensure normalization of the signature
387
+ * Resolves shorthands into slot props, to ensure normalization of the signature
344
388
  * being passed down to getSlots method
345
- * @param value - the base ShorthandProps
346
- * @param options - options to resolve ShorthandProps
389
+ * @param value - the base shorthand props
390
+ * @param options - options to resolve shorthand props
347
391
  */
348
- export declare function resolveShorthand<Props extends DefaultObjectShorthandProps, Required extends boolean = false>(value: ShorthandProps<Props>, options?: ResolveShorthandOptions<Props, Required>): Required extends false ? Props | undefined : Props;
392
+ export declare const resolveShorthand: ResolveShorthandFunction;
393
+
394
+ export declare type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {
395
+ <P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, true>): ReplaceNullWithUndefined<P>;
396
+ <P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, boolean>): ReplaceNullWithUndefined<P> | undefined;
397
+ };
349
398
 
350
- export declare type ResolveShorthandOptions<Props extends Record<string, any>, Required extends boolean = false> = {
399
+ export declare type ResolveShorthandOptions<Props, Required extends boolean = false> = {
351
400
  required?: Required;
352
401
  defaultProps?: Props;
353
402
  };
@@ -359,10 +408,6 @@ export declare type ResolveShorthandOptions<Props extends Record<string, any>, R
359
408
  */
360
409
  export declare const selectProperties: Record<string, number>;
361
410
 
362
- export declare type ShorthandProps<Props extends DefaultObjectShorthandProps> = React_2.ReactChild | React_2.ReactNodeArray | React_2.ReactPortal | number | null | undefined | Props;
363
-
364
- export declare type ShorthandRenderFunction<Props> = (Component: React_2.ElementType<Props>, props: Omit<Props, 'children' | 'as'>) => React_2.ReactNode;
365
-
366
411
  /**
367
412
  * Checks if the keyboard event should preventDefault() for Enter and Spacebar keys
368
413
  *
@@ -370,14 +415,55 @@ export declare type ShorthandRenderFunction<Props> = (Component: React_2.Element
370
415
  */
371
416
  export declare function shouldPreventDefaultOnKeyDown(e: KeyboardEvent | React_2.KeyboardEvent): boolean;
372
417
 
373
- declare type SlotProps<S extends ObjectShorthandPropsRecord> = {
374
- [K in keyof S]-?: NonNullable<S[K]> extends AsIntrinsicElement<infer As> ? UnionToIntersection<JSX.IntrinsicElements[As]> : NonNullable<S[K]> extends ObjectShorthandProps<infer P> ? P : never;
375
- };
418
+ /**
419
+ * The props type and shorthand value for a slot. Type is either a single intrinsic element like `'div'`,
420
+ * or a component like `typeof Button`.
421
+ *
422
+ * If a slot needs to support multiple intrinsic element types, use the `AlternateAs` param (see examples below).
423
+ *
424
+ * By default, slots can be set to `null` to prevent them from being rendered. If a slot must always be rendered,
425
+ * wrap with `NonNullable` (see examples below).
426
+ *
427
+ * @example
428
+ * ```
429
+ * // Intrinsic element examples:
430
+ * Slot<'div'> // Slot is always div
431
+ * Slot<'button', 'a'> // Defaults to button, but allows as="a" with anchor-specific props
432
+ * Slot<'span', 'div' | 'pre'> // Defaults to span, but allows as="div" or as="pre"
433
+ * NonNullable<Slot<'div'>> // Slot that will always be rendered (can't be set to null by the user)
434
+ *
435
+ * // Component examples:
436
+ * Slot<typeof Button> // Slot is always a Button, and accepts all of Button's Props
437
+ * NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)
438
+ * ```
439
+ */
440
+ export declare type Slot<Type extends keyof JSX.IntrinsicElements | React_2.ComponentType | UnknownSlotProps, AlternateAs extends keyof JSX.IntrinsicElements = never> = IsSingleton<Extract<Type, string>> extends true ? WithSlotShorthandValue<Type extends keyof JSX.IntrinsicElements ? {
441
+ as?: Type;
442
+ } & WithSlotRenderFunction<IntrisicElementProps<Type>> : Type extends React_2.ComponentType<infer Props> ? WithSlotRenderFunction<Props> : Type> | {
443
+ [As in AlternateAs]: {
444
+ as: As;
445
+ } & WithSlotRenderFunction<IntrisicElementProps<As>>;
446
+ }[AlternateAs] | null : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';
376
447
 
377
- export declare type Slots<S extends ObjectShorthandPropsRecord> = {
378
- [K in keyof S]-?: NonNullable<S[K]> extends AsIntrinsicElement<infer As> ? As : S[K] extends ObjectShorthandProps<infer P> ? React_2.ElementType<NonNullable<P>> : React_2.ElementType<NonNullable<S[K]>>;
448
+ /**
449
+ * Matches any component's Slots type (such as ButtonSlots).
450
+ *
451
+ * This should ONLY be used in type templates as in `extends SlotPropsRecord`;
452
+ * it shouldn't be used as a component's Slots type.
453
+ */
454
+ export declare type SlotPropsRecord = Record<string, UnknownSlotProps | SlotShorthandValue | null | undefined>;
455
+
456
+ export declare type SlotRenderFunction<Props> = (Component: React_2.ElementType<Props>, props: Omit<Props, 'children' | 'as'>) => React_2.ReactNode;
457
+
458
+ export declare type Slots<S extends SlotPropsRecord> = {
459
+ [K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As> ? As : ExtractSlotProps<S[K]> extends React_2.ComponentType<infer P> ? React_2.ElementType<NonNullable<P>> : React_2.ElementType<ExtractSlotProps<S[K]>>;
379
460
  };
380
461
 
462
+ /**
463
+ * The shorthand value of a slot allows specifying its child
464
+ */
465
+ export declare type SlotShorthandValue = React_2.ReactChild | React_2.ReactNodeArray | React_2.ReactPortal;
466
+
381
467
  export declare const SSRContext: React_2.Context<SSRContextValue>;
382
468
 
383
469
  /**
@@ -438,6 +524,16 @@ export declare const trProperties: Record<string, number>;
438
524
  */
439
525
  export declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;
440
526
 
527
+ /**
528
+ * Matches any slot props type.
529
+ *
530
+ * This should ONLY be used in type templates as in `extends UnknownSlotProps`;
531
+ * it shouldn't be used as the type of a slot.
532
+ */
533
+ export declare type UnknownSlotProps = Pick<React_2.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {
534
+ as?: keyof JSX.IntrinsicElements;
535
+ };
536
+
441
537
  /**
442
538
  * Hook to store a value and generate callbacks for setting the value to true or false.
443
539
  * The identity of the callbacks will always stay the same.
@@ -471,42 +567,37 @@ export declare type UseBooleanCallbacks = {
471
567
  export declare function useConst<T>(initialValue: T | (() => T)): T;
472
568
 
473
569
  /**
474
- * A useState 'like' hook that allows optional user control
475
- * Useful for components which allow uncontrolled and controlled behaviour for users
476
- * @returns - https://reactjs.org/docs/hooks-state.html
570
+ * A `useState`-like hook to manage a value that could be either controlled or uncontrolled,
571
+ * such as a checked state or text input string.
572
+ *
573
+ * Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a
574
+ * controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.
575
+ *
576
+ * @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array
577
+ * of the current value and an updater (dispatch) function. The updater function is referentially
578
+ * stable (won't change during the component's lifecycle). It can take either a new value, or a
579
+ * function which is passed the previous value and returns the new value. Unlike `setState`, calls
580
+ * to the updater function will only be respected if the component is uncontrolled.
581
+ * @see https://reactjs.org/docs/uncontrolled-components.html
477
582
  */
478
583
  export declare const useControllableState: <State>(options: UseControllableStateOptions<State>) => [State, React_2.Dispatch<React_2.SetStateAction<State>>];
479
584
 
480
585
  export declare type UseControllableStateOptions<State> = {
481
586
  /**
482
- * User provided default state or factory initializer
587
+ * User-provided default state or initializer, for uncontrolled usage.
483
588
  */
484
589
  defaultState?: State | (() => State);
485
590
  /**
486
- * User provided controllable state, undefined state means internal state will be used
591
+ * User-provided controlled state. `undefined` means internal state will be used.
487
592
  */
488
593
  state: State | undefined;
489
594
  /**
490
- * Used to initialize state if all user provided states are undefined
595
+ * Used as the initial state if `state` and `defaultState` are both `undefined`.
596
+ * If `undefined` is the correct initial state, pass that here.
491
597
  */
492
598
  initialState: State;
493
599
  };
494
600
 
495
- /**
496
- * Hook to manage a value that could be either controlled or uncontrolled, such as a checked state or
497
- * text box string.
498
- * @param controlledValue - The controlled value passed in the props. This value will always be used if provided,
499
- * and the internal state will be updated to reflect it.
500
- * @param defaultUncontrolledValue - Initial value for the internal state in the uncontrolled case.
501
- * @returns An array of the current value and an updater callback. Like `React.useState`, the updater
502
- * callback always has the same identity, and it can take either a new value, or a function which
503
- * is passed the previous value and returns the new value.
504
- * @see https://reactjs.org/docs/uncontrolled-components.html
505
- */
506
- export declare function useControllableValue<TValue, TElement extends HTMLElement>(controlledValue: TValue, defaultUncontrolledValue: DefaultValue<TValue>): Readonly<[TValue, (update: React_2.SetStateAction<TValue>) => void]>;
507
-
508
- export declare function useControllableValue<TValue, TElement extends HTMLElement, TEvent extends React_2.SyntheticEvent<TElement> | undefined>(controlledValue: TValue, defaultUncontrolledValue: DefaultValue<TValue>, onChange: ChangeCallback<TElement, TValue, TEvent>): Readonly<[TValue, (update: React_2.SetStateAction<TValue>, ev?: React_2.FormEvent<TElement>) => void]>;
509
-
510
601
  /**
511
602
  * https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
512
603
  *
@@ -565,6 +656,25 @@ export declare const useIsomorphicLayoutEffect: typeof React_2.useEffect;
565
656
  */
566
657
  export declare function useIsSSR(): boolean;
567
658
 
659
+ /**
660
+ * Combine two event callbacks into a single callback function that calls each one in order.
661
+ *
662
+ * This is useful to add an event listener to an existing element without overwriting the current listener, if any.
663
+ *
664
+ * For example:
665
+ * ```ts
666
+ * state.slot.onChange = useMergedCallbacks(state.slot.onChange, ev => {
667
+ * // Handle onChange
668
+ * });
669
+ * ```
670
+ *
671
+ * @param callback1 - The first callback to be called
672
+ * @param callback2 - The second callback to be called
673
+ *
674
+ * @returns An event callback that calls the callbacks in order, and is stable between renders
675
+ */
676
+ export declare function useMergedEventCallbacks<Args extends unknown[]>(callback1: ((...args: Args) => void) | undefined, callback2: ((...args: Args) => void) | undefined): (...args: Args) => void;
677
+
568
678
  /**
569
679
  * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that
570
680
  * updates all provided refs
@@ -645,4 +755,21 @@ export declare const useUnmount: (callback: () => void) => void;
645
755
  */
646
756
  export declare const videoProperties: Record<string, number>;
647
757
 
758
+ /**
759
+ * Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`
760
+ * to be a render function that takes those props.
761
+ */
762
+ declare type WithSlotRenderFunction<Props extends {
763
+ children?: unknown;
764
+ }> = Props & {
765
+ children?: Props['children'] | SlotRenderFunction<Props>;
766
+ };
767
+
768
+ /**
769
+ * Helper type for {@link Slot}. Adds shorthand types that are assignable to the slot's `children`.
770
+ */
771
+ declare type WithSlotShorthandValue<Props extends {
772
+ children?: unknown;
773
+ }> = Props | Extract<SlotShorthandValue, Props['children']>;
774
+
648
775
  export { }
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
- import { AsIntrinsicElement, ComponentState, ObjectShorthandPropsRecord, ObjectShorthandProps, UnionToIntersection } from './types';
3
- export declare type Slots<S extends ObjectShorthandPropsRecord> = {
4
- [K in keyof S]-?: NonNullable<S[K]> extends AsIntrinsicElement<infer As> ? As : S[K] extends ObjectShorthandProps<infer P> ? React.ElementType<NonNullable<P>> : React.ElementType<NonNullable<S[K]>>;
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
5
  };
6
- declare type SlotProps<S extends ObjectShorthandPropsRecord> = {
7
- [K in keyof S]-?: NonNullable<S[K]> extends AsIntrinsicElement<infer As> ? UnionToIntersection<JSX.IntrinsicElements[As]> : NonNullable<S[K]> extends ObjectShorthandProps<infer P> ? P : never;
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
8
  };
9
9
  /**
10
10
  * Given the state and an array of slot names, will break out `slots` and `slotProps`
@@ -15,15 +15,16 @@ declare type SlotProps<S extends ObjectShorthandPropsRecord> = {
15
15
  * Slots will render as null if they are rendered as primitives with undefined children.
16
16
  *
17
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 the the slot type. For example, if the
19
- * slot is rendered `as: 'a'`, the props will be filtered for acceptable anchor props.
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.
20
22
  *
21
23
  * @param state - State including slot definitions
22
- * @param slotNames - Name of which props are slots
23
24
  * @returns An object containing the `slots` map and `slotProps` map.
24
25
  */
25
- export declare function getSlots<R extends ObjectShorthandPropsRecord>(state: ComponentState<R>, slotNames?: (keyof R)[]): {
26
+ export declare function getSlots<R extends SlotPropsRecord>(state: ComponentState<R>): {
26
27
  slots: Slots<R>;
27
- slotProps: SlotProps<R>;
28
+ slotProps: ObjectSlotProps<R>;
28
29
  };
29
30
  export {};
@@ -1,5 +1,4 @@
1
1
  import * as React from 'react';
2
- import { nullRender } from './nullRender';
3
2
  import { omit } from '../utils/omit';
4
3
  /**
5
4
  * Given the state and an array of slot names, will break out `slots` and `slotProps`
@@ -10,17 +9,19 @@ import { omit } from '../utils/omit';
10
9
  * Slots will render as null if they are rendered as primitives with undefined children.
11
10
  *
12
11
  * The slotProps will always omit the `as` prop within them, and for slots that are string
13
- * primitives, the props will be filtered according the the slot type. For example, if the
14
- * slot is rendered `as: 'a'`, the props will be filtered for acceptable anchor props.
12
+ * primitives, the props will be filtered according to the slot type by the type system.
13
+ * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable
14
+ * anchor props. Note that this is only enforced at build time by Typescript -- there is no
15
+ * runtime code filtering props in this function.
15
16
  *
16
17
  * @param state - State including slot definitions
17
- * @param slotNames - Name of which props are slots
18
18
  * @returns An object containing the `slots` map and `slotProps` map.
19
19
  */
20
20
 
21
- export function getSlots(state, slotNames = ['root']) {
21
+ export function getSlots(state) {
22
22
  const slots = {};
23
23
  const slotProps = {};
24
+ const slotNames = Object.keys(state.components);
24
25
 
25
26
  for (const slotName of slotNames) {
26
27
  const [slot, props] = getSlot(state, slotName);
@@ -38,7 +39,7 @@ function getSlot(state, slotName) {
38
39
  var _a, _b, _c;
39
40
 
40
41
  if (state[slotName] === undefined) {
41
- return [nullRender, undefined];
42
+ return [null, undefined];
42
43
  }
43
44
 
44
45
  const {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/compose/getSlots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAUA,SAAS,UA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B,CAAP,GAAoC,KAAK,CAAC,QAAD,CAA5E;AAEA,SAAO,CAAC,IAAD,EAAO,SAAP,CAAP;AACD","sourceRoot":""}
@@ -1,4 +1,3 @@
1
1
  export * from './getSlots';
2
- export * from './nullRender';
3
2
  export * from './resolveShorthand';
4
3
  export * from './types';
@@ -1,5 +1,4 @@
1
1
  export * from './getSlots';
2
- export * from './nullRender';
3
2
  export * from './resolveShorthand';
4
3
  export * from './types';
5
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/compose/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/compose/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC"}
@@ -1,12 +1,16 @@
1
- import type { DefaultObjectShorthandProps, ShorthandProps } from './types';
2
- export declare type ResolveShorthandOptions<Props extends Record<string, any>, Required extends boolean = false> = {
1
+ import type { ReplaceNullWithUndefined, SlotShorthandValue, UnknownSlotProps } from './types';
2
+ export declare type ResolveShorthandOptions<Props, Required extends boolean = false> = {
3
3
  required?: Required;
4
4
  defaultProps?: Props;
5
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
+ };
6
10
  /**
7
- * Resolves ShorthandProps into ObjectShorthandProps, to ensure normalization of the signature
11
+ * Resolves shorthands into slot props, to ensure normalization of the signature
8
12
  * being passed down to getSlots method
9
- * @param value - the base ShorthandProps
10
- * @param options - options to resolve ShorthandProps
13
+ * @param value - the base shorthand props
14
+ * @param options - options to resolve shorthand props
11
15
  */
12
- export declare function resolveShorthand<Props extends DefaultObjectShorthandProps, Required extends boolean = false>(value: ShorthandProps<Props>, options?: ResolveShorthandOptions<Props, Required>): Required extends false ? Props | undefined : Props;
16
+ export declare const resolveShorthand: ResolveShorthandFunction;