@fluentui/react-utilities 9.22.0 → 9.23.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 (127) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/dist/index.d.ts +59 -8
  3. package/lib/compose/assertSlots.js.map +1 -1
  4. package/lib/compose/constants.js.map +1 -1
  5. package/lib/compose/deprecated/getSlots.js.map +1 -1
  6. package/lib/compose/deprecated/getSlotsNext.js.map +1 -1
  7. package/lib/compose/deprecated/resolveShorthand.js.map +1 -1
  8. package/lib/compose/getIntrinsicElementProps.js.map +1 -1
  9. package/lib/compose/getSlotClassNameProp.js.map +1 -1
  10. package/lib/compose/index.js.map +1 -1
  11. package/lib/compose/isResolvedShorthand.js.map +1 -1
  12. package/lib/compose/isSlot.js.map +1 -1
  13. package/lib/compose/slot.js.map +1 -1
  14. package/lib/compose/types.js.map +1 -1
  15. package/lib/events/index.js.map +1 -1
  16. package/lib/events/mouseTouchHelpers.js.map +1 -1
  17. package/lib/hooks/index.js.map +1 -1
  18. package/lib/hooks/useAnimationFrame.js.map +1 -1
  19. package/lib/hooks/useBrowserTimer.js.map +1 -1
  20. package/lib/hooks/useControllableState.js.map +1 -1
  21. package/lib/hooks/useEventCallback.js.map +1 -1
  22. package/lib/hooks/useFirstMount.js.map +1 -1
  23. package/lib/hooks/useForceUpdate.js.map +1 -1
  24. package/lib/hooks/useId.js.map +1 -1
  25. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  26. package/lib/hooks/useMergedRefs.js.map +1 -1
  27. package/lib/hooks/useOnClickOutside.js.map +1 -1
  28. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  29. package/lib/hooks/usePrevious.js.map +1 -1
  30. package/lib/hooks/useScrollbarWidth.js.map +1 -1
  31. package/lib/hooks/useTimeout.js.map +1 -1
  32. package/lib/index.js.map +1 -1
  33. package/lib/selection/index.js.map +1 -1
  34. package/lib/selection/types.js.map +1 -1
  35. package/lib/selection/useSelection.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/ssr/index.js.map +1 -1
  39. package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
  40. package/lib/trigger/getTriggerChild.js.map +1 -1
  41. package/lib/trigger/index.js.map +1 -1
  42. package/lib/trigger/isFluentTrigger.js.map +1 -1
  43. package/lib/trigger/types.js.map +1 -1
  44. package/lib/utils/clamp.js.map +1 -1
  45. package/lib/utils/createSetFromIterable.js.map +1 -1
  46. package/lib/utils/generated-types.js +11 -0
  47. package/lib/utils/generated-types.js.map +1 -0
  48. package/lib/utils/getNativeElementProps.js.map +1 -1
  49. package/lib/utils/getRTLSafeKey.js.map +1 -1
  50. package/lib/utils/getReactCallbackName.js.map +1 -1
  51. package/lib/utils/index.js.map +1 -1
  52. package/lib/utils/isHTMLElement.js.map +1 -1
  53. package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
  54. package/lib/utils/mergeCallbacks.js.map +1 -1
  55. package/lib/utils/omit.js.map +1 -1
  56. package/lib/utils/priorityQueue.js.map +1 -1
  57. package/lib/utils/properties.js.map +1 -1
  58. package/lib/utils/types.js.map +1 -1
  59. package/lib/virtualParent/elementContains.js.map +1 -1
  60. package/lib/virtualParent/getParent.js.map +1 -1
  61. package/lib/virtualParent/index.js.map +1 -1
  62. package/lib/virtualParent/isVirtualElement.js.map +1 -1
  63. package/lib/virtualParent/setVirtualParent.js.map +1 -1
  64. package/lib/virtualParent/types.js.map +1 -1
  65. package/lib-commonjs/compose/assertSlots.js.map +1 -1
  66. package/lib-commonjs/compose/constants.js.map +1 -1
  67. package/lib-commonjs/compose/deprecated/getSlots.js.map +1 -1
  68. package/lib-commonjs/compose/deprecated/getSlotsNext.js.map +1 -1
  69. package/lib-commonjs/compose/deprecated/resolveShorthand.js.map +1 -1
  70. package/lib-commonjs/compose/getIntrinsicElementProps.js.map +1 -1
  71. package/lib-commonjs/compose/getSlotClassNameProp.js.map +1 -1
  72. package/lib-commonjs/compose/index.js.map +1 -1
  73. package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
  74. package/lib-commonjs/compose/isSlot.js.map +1 -1
  75. package/lib-commonjs/compose/slot.js.map +1 -1
  76. package/lib-commonjs/compose/types.js.map +1 -1
  77. package/lib-commonjs/events/index.js.map +1 -1
  78. package/lib-commonjs/events/mouseTouchHelpers.js.map +1 -1
  79. package/lib-commonjs/hooks/index.js.map +1 -1
  80. package/lib-commonjs/hooks/useAnimationFrame.js.map +1 -1
  81. package/lib-commonjs/hooks/useBrowserTimer.js.map +1 -1
  82. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  83. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  84. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  85. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  86. package/lib-commonjs/hooks/useId.js.map +1 -1
  87. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  88. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  89. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  90. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  91. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  92. package/lib-commonjs/hooks/useScrollbarWidth.js.map +1 -1
  93. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  94. package/lib-commonjs/index.js.map +1 -1
  95. package/lib-commonjs/selection/index.js.map +1 -1
  96. package/lib-commonjs/selection/types.js.map +1 -1
  97. package/lib-commonjs/selection/useSelection.js.map +1 -1
  98. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  99. package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
  100. package/lib-commonjs/ssr/index.js.map +1 -1
  101. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
  102. package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
  103. package/lib-commonjs/trigger/index.js.map +1 -1
  104. package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
  105. package/lib-commonjs/trigger/types.js.map +1 -1
  106. package/lib-commonjs/utils/clamp.js.map +1 -1
  107. package/lib-commonjs/utils/createSetFromIterable.js.map +1 -1
  108. package/lib-commonjs/utils/generated-types.js +12 -0
  109. package/lib-commonjs/utils/generated-types.js.map +1 -0
  110. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  111. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  112. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
  113. package/lib-commonjs/utils/index.js.map +1 -1
  114. package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
  115. package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
  116. package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
  117. package/lib-commonjs/utils/omit.js.map +1 -1
  118. package/lib-commonjs/utils/priorityQueue.js.map +1 -1
  119. package/lib-commonjs/utils/properties.js.map +1 -1
  120. package/lib-commonjs/utils/types.js.map +1 -1
  121. package/lib-commonjs/virtualParent/elementContains.js.map +1 -1
  122. package/lib-commonjs/virtualParent/getParent.js.map +1 -1
  123. package/lib-commonjs/virtualParent/index.js.map +1 -1
  124. package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -1
  125. package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -1
  126. package/lib-commonjs/virtualParent/types.js.map +1 -1
  127. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,12 +1,21 @@
1
1
  # Change Log - @fluentui/react-utilities
2
2
 
3
- This log was last generated on Thu, 26 Jun 2025 14:07:53 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 28 Jul 2025 18:44:11 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.23.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.23.0)
8
+
9
+ Mon, 28 Jul 2025 18:44:11 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.22.0..@fluentui/react-utilities_v9.23.0)
11
+
12
+ ### Minor changes
13
+
14
+ - feat: add custom JSX.* types that are compatible with various react major versions ([PR #34733](https://github.com/microsoft/fluentui/pull/34733) by martinhochel@microsoft.com)
15
+
7
16
  ## [9.22.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.22.0)
8
17
 
9
- Thu, 26 Jun 2025 14:07:53 GMT
18
+ Thu, 26 Jun 2025 14:11:55 GMT
10
19
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.21.1..@fluentui/react-utilities_v9.22.0)
11
20
 
12
21
  ### Minor changes
package/dist/index.d.ts CHANGED
@@ -24,7 +24,7 @@ export declare function applyTriggerPropsToChildren<TriggerChildProps>(children:
24
24
  * type Example<T> = T extends AsIntrinsicElement<infer As> ? As : never;
25
25
  * ```
26
26
  */
27
- declare type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = {
27
+ declare type AsIntrinsicElement<As extends JSXIntrinsicElementKeys> = {
28
28
  as?: As;
29
29
  };
30
30
 
@@ -285,7 +285,7 @@ declare type GetParentOptions = {
285
285
  */
286
286
  export declare const getPartitionedNativeProps: <Props extends Pick<React_2.HTMLAttributes<HTMLElement>, "style" | "className">, ExcludedPropKeys extends Extract<keyof Props, string> = never>({ primarySlotTagName, props, excludedPropNames, }: {
287
287
  /** The primary slot's element type (e.g. 'div') */
288
- primarySlotTagName: keyof JSX.IntrinsicElements;
288
+ primarySlotTagName: JSXIntrinsicElementKeys;
289
289
  /** The component's props object */
290
290
  props: Props;
291
291
  /** List of native props to exclude from the returned value */
@@ -402,11 +402,11 @@ export declare const IdPrefixProvider: React_2.Provider<string | undefined>;
402
402
  export declare type InferredElementRefType<Props> = ObscureEventName extends keyof Props ? Required<Props>[ObscureEventName] extends React_2.PointerEventHandler<infer Element> ? Element : never : never;
403
403
 
404
404
  /**
405
- * Helper type for {@link Slot}. Modifies `JSX.IntrinsicElements[Type]`:
405
+ * Helper type for {@link Slot}. Modifies `JSXIntrinsicElements<Type>`:
406
406
  * * Removes legacy string ref.
407
407
  * * Disallows children for empty tags like 'img'.
408
408
  */
409
- declare type IntrinsicElementProps<Type extends keyof JSX.IntrinsicElements> = Type extends EmptyIntrinsicElements ? PropsWithoutChildren<React_2.PropsWithRef<JSX.IntrinsicElements[Type]>> : React_2.PropsWithRef<JSX.IntrinsicElements[Type]>;
409
+ declare type IntrinsicElementProps<Type extends JSXIntrinsicElementKeys> = Type extends EmptyIntrinsicElements ? PropsWithoutChildren<React_2.PropsWithRef<JSXIntrinsicElement<Type>>> : React_2.PropsWithRef<JSXIntrinsicElement<Type>>;
410
410
 
411
411
  /**
412
412
  * @internal
@@ -503,6 +503,57 @@ export declare function isSlot<Props extends {}>(element: unknown): element is S
503
503
  */
504
504
  export declare function isTouchEvent(event: TouchOrMouseEvent): event is TouchEvent | React_2.TouchEvent;
505
505
 
506
+ /**
507
+ * Our own alias for `JSX.Element` type that is compatible with both React 17 and React 18+.
508
+ * Use this type when annotating JSX markup in all our code in order to avoid issues between different React versions.
509
+ *
510
+ * Example usage:
511
+ *
512
+ * BAD:
513
+ * ```tsx
514
+ * const renderFoo = (state: FooState) = <div {...props}>Hello World</div>;
515
+ * // infers
516
+ * // R17: declare const renderFoo: (state: FooState) => JSX.Element;
517
+ * // R18+: declare const renderFoo: (state: FooState) => React.JSX.Element;
518
+ * ```
519
+ *
520
+ * GOOD:
521
+ * ```tsx
522
+ * import type { JSXElement } from '@fluentui/react-utilities';
523
+ * const renderFoo = (state: FooState): JSXElement = <div {...props}>Hello World</div>;
524
+ * ```
525
+ */
526
+ export declare type JSXElement = React_2.ReactElement<any, any>;
527
+
528
+ /**
529
+ * Our own alias for `JSX.IntrinsicElements` type that is compatible with both React 17 and React 18+.
530
+ * Use this type to get the intrinsic elements from React types in order to avoid issues between different React versions.
531
+ */
532
+ export declare type JSXIntrinsicElement<Element extends JSXIntrinsicElementKeys> = React_2.ComponentProps<Element>;
533
+
534
+ /**
535
+ * Union of all intrinsic element keys in React.
536
+ * Based on the React version, it will either be the latest set of intrinsic elements or the legacy set.
537
+ */
538
+ export declare type JSXIntrinsicElementKeys = ReactVersionDependent<JSXIntrinsicElementKeysLatest, JSXIntrinsicElementKeysCompat>;
539
+
540
+ /**
541
+ * ============================================
542
+ * 💡 DO NOT EDIT THIS FILE.
543
+ * - This file is automatically generated and should not be edited manually.
544
+ * - To regenerate run `yarn nx run react-utilities:build`.
545
+ * ============================================
546
+ */
547
+ /**
548
+ * Unwrapped type for 'keyof JSX.IntrinsicElement'. (Backwards compatible with older versions of '\@types/react')
549
+ */
550
+ declare type JSXIntrinsicElementKeysCompat = 'a' | 'abbr' | 'address' | 'animate' | 'animateMotion' | 'animateTransform' | 'area' | 'article' | 'aside' | 'audio' | 'b' | 'base' | 'bdi' | 'bdo' | 'big' | 'blockquote' | 'body' | 'br' | 'button' | 'canvas' | 'caption' | 'circle' | 'cite' | 'clipPath' | 'code' | 'col' | 'colgroup' | 'data' | 'datalist' | 'dd' | 'defs' | 'del' | 'desc' | 'details' | 'dfn' | 'dialog' | 'div' | 'dl' | 'dt' | 'ellipse' | 'em' | 'embed' | 'feBlend' | 'feColorMatrix' | 'feComponentTransfer' | 'feComposite' | 'feConvolveMatrix' | 'feDiffuseLighting' | 'feDisplacementMap' | 'feDistantLight' | 'feDropShadow' | 'feFlood' | 'feFuncA' | 'feFuncB' | 'feFuncG' | 'feFuncR' | 'feGaussianBlur' | 'feImage' | 'feMerge' | 'feMergeNode' | 'feMorphology' | 'feOffset' | 'fePointLight' | 'feSpecularLighting' | 'feSpotLight' | 'feTile' | 'feTurbulence' | 'fieldset' | 'figcaption' | 'figure' | 'filter' | 'footer' | 'foreignObject' | 'form' | 'g' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'head' | 'header' | 'hgroup' | 'hr' | 'html' | 'i' | 'iframe' | 'image' | 'img' | 'input' | 'ins' | 'kbd' | 'keygen' | 'label' | 'legend' | 'li' | 'line' | 'linearGradient' | 'link' | 'main' | 'map' | 'mark' | 'marker' | 'mask' | 'menu' | 'menuitem' | 'meta' | 'metadata' | 'meter' | 'nav' | 'noindex' | 'noscript' | 'object' | 'ol' | 'optgroup' | 'option' | 'output' | 'p' | 'param' | 'path' | 'pattern' | 'picture' | 'polygon' | 'polyline' | 'pre' | 'progress' | 'q' | 'radialGradient' | 'rect' | 'rp' | 'rt' | 'ruby' | 's' | 'samp' | 'script' | 'section' | 'select' | 'slot' | 'small' | 'source' | 'span' | 'stop' | 'strong' | 'style' | 'sub' | 'summary' | 'sup' | 'svg' | 'switch' | 'symbol' | 'table' | 'tbody' | 'td' | 'template' | 'text' | 'textPath' | 'textarea' | 'tfoot' | 'th' | 'thead' | 'time' | 'title' | 'tr' | 'track' | 'tspan' | 'u' | 'ul' | 'use' | 'var' | 'video' | 'view' | 'wbr' | 'webview';
551
+
552
+ /**
553
+ * Unwrapped type for 'keyof JSX.IntrinsicElement'
554
+ */
555
+ declare type JSXIntrinsicElementKeysLatest = 'set' | 'mpath' | 'center' | 'search' | JSXIntrinsicElementKeysCompat;
556
+
506
557
  /**
507
558
  * @internal
508
559
  * Combine two event callbacks into a single callback function that calls each one in order.
@@ -788,7 +839,7 @@ export declare function setVirtualParent(child: Node, parent?: Node): void;
788
839
  * NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)
789
840
  * ```
790
841
  */
791
- export declare type Slot<Type extends keyof JSX.IntrinsicElements | ComponentType<any> | UnknownSlotProps, AlternateAs extends keyof JSX.IntrinsicElements = never> = IsSingleton<Extract<Type, string>> extends true ? WithSlotShorthandValue<Type extends keyof JSX.IntrinsicElements ? {
842
+ export declare type Slot<Type extends JSXIntrinsicElementKeys | ComponentType<any> | UnknownSlotProps, AlternateAs extends JSXIntrinsicElementKeys = never> = IsSingleton<Extract<Type, string>> extends true ? WithSlotShorthandValue<Type extends JSXIntrinsicElementKeys ? {
792
843
  as?: Type;
793
844
  } & WithSlotRenderFunction<IntrinsicElementProps<Type>> : Type extends ComponentType<infer Props> ? Props extends UnknownSlotProps ? Props : WithSlotRenderFunction<Props> : Type> | (AlternateAs extends unknown ? {
794
845
  as: AlternateAs;
@@ -847,7 +898,7 @@ export declare type SlotComponentType<Props> = WithoutSlotRenderFunction<Props>
847
898
  /**
848
899
  * @internal
849
900
  */
850
- [SLOT_ELEMENT_TYPE_SYMBOL]: ComponentType<Props> | (Props extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
901
+ [SLOT_ELEMENT_TYPE_SYMBOL]: ComponentType<Props> | (Props extends AsIntrinsicElement<infer As> ? As : JSXIntrinsicElementKeys);
851
902
  /**
852
903
  * @internal
853
904
  * The original className prop for the slot, before being modified by the useStyles hook.
@@ -856,7 +907,7 @@ export declare type SlotComponentType<Props> = WithoutSlotRenderFunction<Props>
856
907
  };
857
908
 
858
909
  export declare type SlotOptions<Props extends UnknownSlotProps> = {
859
- elementType: React_2.ComponentType<Props> | (Props extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
910
+ elementType: React_2.ComponentType<Props> | (Props extends AsIntrinsicElement<infer As> ? As : JSXIntrinsicElementKeys);
860
911
  defaultProps?: Partial<Props>;
861
912
  };
862
913
 
@@ -916,7 +967,7 @@ export declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U :
916
967
  * it shouldn't be used as the type of a slot.
917
968
  */
918
969
  export declare type UnknownSlotProps = Pick<React_2.HTMLAttributes<HTMLElement>, 'className' | 'style'> & {
919
- as?: keyof JSX.IntrinsicElements;
970
+ as?: JSXIntrinsicElementKeys;
920
971
  children?: ReactNode;
921
972
  };
922
973
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compose/assertSlots.ts"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { isSlot } from './isSlot';\nimport { ComponentState, ExtractSlotProps, SlotComponentType, SlotPropsRecord } from './types';\nimport * as slot from './slot';\n\ntype SlotComponents<Slots extends SlotPropsRecord> = {\n [K in keyof Slots]: SlotComponentType<ExtractSlotProps<Slots[K]>> | (null extends Slots[K] ? undefined : never);\n};\n\n/**\n * @internal\n * Assertion method to ensure state slots properties are properly declared.\n * A properly declared slot must be declared by using the `slot` method.\n *\n * @example\n * ```tsx\n * export const renderInput_unstable = (state: InputState) => {\n assertSlots<InputSlots>(state);\n return (\n <state.root>\n {state.contentBefore && <state.contentBefore />}\n <state.input />\n {state.contentAfter && <state.contentAfter />}\n </state.root>\n );\n };\n * ```\n */\nexport function assertSlots<Slots extends SlotPropsRecord>(state: unknown): asserts state is SlotComponents<Slots> {\n /**\n * This verification is not necessary in production\n * as we're verifying static properties that will not change between environments\n */\n if (process.env.NODE_ENV !== 'production') {\n const typedState = state as ComponentState<Slots>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n for (const slotName of Object.keys(typedState.components)) {\n const slotElement = typedState[slotName];\n if (slotElement === undefined) {\n continue;\n }\n // this means a slot is being declared without using, slot.always or slot.optional or even resolveShorthand on the state hook,\n // but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type\n // FIXME: this slot will still fail to support child render function scenario\n if (!isSlot(slotElement)) {\n typedState[slotName as keyof ComponentState<Slots>] = slot.always(slotElement, {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n elementType: typedState.components[slotName] as React.ComponentType<{}>,\n }) as ComponentState<Slots>[keyof ComponentState<Slots>];\n // eslint-disable-next-line no-console\n console.warn(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [${assertSlots.name}]:\n \"state.${slotName}\" is not a slot!\n Be sure to create slots properly by using \"slot.always\" or \"slot.optional\".\n `);\n } else {\n // This means a slot is being declared by using resolveShorthand on the state hook,\n // but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type\n const { [SLOT_ELEMENT_TYPE_SYMBOL]: elementType } = slotElement;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n if (elementType !== typedState.components[slotName]) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slotElement[SLOT_ELEMENT_TYPE_SYMBOL] = typedState.components[slotName] as React.ComponentType<{}>;\n // eslint-disable-next-line no-console\n console.warn(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [${assertSlots.name}]:\n \"state.${slotName}\" element type differs from \"state.components.${slotName}\",\n ${elementType} !== ${\n typedState.components[slotName] /* eslint-disable-line @typescript-eslint/no-deprecated */\n }.\n Be sure to create slots properly by using \"slot.always\" or \"slot.optional\" with the correct elementType.\n `);\n }\n }\n }\n }\n}\n"],"names":["React","SLOT_ELEMENT_TYPE_SYMBOL","isSlot","slot","assertSlots","state","process","env","NODE_ENV","typedState","slotName","Object","keys","components","slotElement","undefined","always","elementType","console","warn","name"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,QAAQ,cAAc;AACvD,SAASC,MAAM,QAAQ,WAAW;AAElC,YAAYC,UAAU,SAAS;AAM/B;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,YAA2CC,KAAc;IACvE;;;GAGC,GACD,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,MAAMC,aAAaJ;QACnB,4DAA4D;QAC5D,KAAK,MAAMK,YAAYC,OAAOC,IAAI,CAACH,WAAWI,UAAU,EAAG;YACzD,MAAMC,cAAcL,UAAU,CAACC,SAAS;YACxC,IAAII,gBAAgBC,WAAW;gBAC7B;YACF;YACA,8HAA8H;YAC9H,4JAA4J;YAC5J,6EAA6E;YAC7E,IAAI,CAACb,OAAOY,cAAc;gBACxBL,UAAU,CAACC,SAAwC,GAAGP,KAAKa,MAAM,CAACF,aAAa;oBAC7E,4DAA4D;oBAC5DG,aAAaR,WAAWI,UAAU,CAACH,SAAS;gBAC9C;gBACA,sCAAsC;gBACtCQ,QAAQC,IAAI,CAAuB,CAAC,2BACP,EAAEf,YAAYgB,IAAI,CAAC;OACvC,EAAEV,SAAS;2EAEpB,CAAC;YACH,OAAO;gBACL,mFAAmF;gBACnF,4JAA4J;gBAC5J,MAAM,EAAE,CAACT,yBAAyB,EAAEgB,WAAW,EAAE,GAAGH;gBACpD,4DAA4D;gBAC5D,IAAIG,gBAAgBR,WAAWI,UAAU,CAACH,SAAS,EAAE;oBACnD,4DAA4D;oBAC5DI,WAAW,CAACb,yBAAyB,GAAGQ,WAAWI,UAAU,CAACH,SAAS;oBACvE,sCAAsC;oBACtCQ,QAAQC,IAAI,CAAuB,CAAC,2BACP,EAAEf,YAAYgB,IAAI,CAAC;OACvC,EAAEV,SAAS,8CAA8C,EAAEA,SAAS;AAC3E,EAAEO,YAAY,KAAK,EACnBR,WAAWI,UAAU,CAACH,SAAS,CAChC;wGAED,CAAC;gBACH;YACF;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../src/compose/assertSlots.ts"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { isSlot } from './isSlot';\nimport { ComponentState, ExtractSlotProps, SlotComponentType, SlotPropsRecord } from './types';\nimport * as slot from './slot';\n\ntype SlotComponents<Slots extends SlotPropsRecord> = {\n [K in keyof Slots]: SlotComponentType<ExtractSlotProps<Slots[K]>> | (null extends Slots[K] ? undefined : never);\n};\n\n/**\n * @internal\n * Assertion method to ensure state slots properties are properly declared.\n * A properly declared slot must be declared by using the `slot` method.\n *\n * @example\n * ```tsx\n * export const renderInput_unstable = (state: InputState) => {\n assertSlots<InputSlots>(state);\n return (\n <state.root>\n {state.contentBefore && <state.contentBefore />}\n <state.input />\n {state.contentAfter && <state.contentAfter />}\n </state.root>\n );\n };\n * ```\n */\nexport function assertSlots<Slots extends SlotPropsRecord>(state: unknown): asserts state is SlotComponents<Slots> {\n /**\n * This verification is not necessary in production\n * as we're verifying static properties that will not change between environments\n */\n if (process.env.NODE_ENV !== 'production') {\n const typedState = state as ComponentState<Slots>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n for (const slotName of Object.keys(typedState.components)) {\n const slotElement = typedState[slotName];\n if (slotElement === undefined) {\n continue;\n }\n // this means a slot is being declared without using, slot.always or slot.optional or even resolveShorthand on the state hook,\n // but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type\n // FIXME: this slot will still fail to support child render function scenario\n if (!isSlot(slotElement)) {\n typedState[slotName as keyof ComponentState<Slots>] = slot.always(slotElement, {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n elementType: typedState.components[slotName] as React.ComponentType<{}>,\n }) as ComponentState<Slots>[keyof ComponentState<Slots>];\n // eslint-disable-next-line no-console\n console.warn(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [${assertSlots.name}]:\n \"state.${slotName}\" is not a slot!\n Be sure to create slots properly by using \"slot.always\" or \"slot.optional\".\n `);\n } else {\n // This means a slot is being declared by using resolveShorthand on the state hook,\n // but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type\n const { [SLOT_ELEMENT_TYPE_SYMBOL]: elementType } = slotElement;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n if (elementType !== typedState.components[slotName]) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slotElement[SLOT_ELEMENT_TYPE_SYMBOL] = typedState.components[slotName] as React.ComponentType<{}>;\n // eslint-disable-next-line no-console\n console.warn(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [${assertSlots.name}]:\n \"state.${slotName}\" element type differs from \"state.components.${slotName}\",\n ${elementType} !== ${\n typedState.components[slotName] /* eslint-disable-line @typescript-eslint/no-deprecated */\n }.\n Be sure to create slots properly by using \"slot.always\" or \"slot.optional\" with the correct elementType.\n `);\n }\n }\n }\n }\n}\n"],"names":["React","SLOT_ELEMENT_TYPE_SYMBOL","isSlot","slot","assertSlots","state","process","env","NODE_ENV","typedState","slotName","Object","keys","components","slotElement","undefined","always","elementType","console","warn","name"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,QAAQ,cAAc;AACvD,SAASC,MAAM,QAAQ,WAAW;AAElC,YAAYC,UAAU,SAAS;AAM/B;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,YAA2CC,KAAc;IACvE;;;GAGC,GACD,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,MAAMC,aAAaJ;QACnB,4DAA4D;QAC5D,KAAK,MAAMK,YAAYC,OAAOC,IAAI,CAACH,WAAWI,UAAU,EAAG;YACzD,MAAMC,cAAcL,UAAU,CAACC,SAAS;YACxC,IAAII,gBAAgBC,WAAW;gBAC7B;YACF;YACA,8HAA8H;YAC9H,4JAA4J;YAC5J,6EAA6E;YAC7E,IAAI,CAACb,OAAOY,cAAc;gBACxBL,UAAU,CAACC,SAAwC,GAAGP,KAAKa,MAAM,CAACF,aAAa;oBAC7E,4DAA4D;oBAC5DG,aAAaR,WAAWI,UAAU,CAACH,SAAS;gBAC9C;gBACA,sCAAsC;gBACtCQ,QAAQC,IAAI,CAAuB,CAAC,2BACP,EAAEf,YAAYgB,IAAI,CAAC;OACvC,EAAEV,SAAS;2EAEpB,CAAC;YACH,OAAO;gBACL,mFAAmF;gBACnF,4JAA4J;gBAC5J,MAAM,EAAE,CAACT,yBAAyB,EAAEgB,WAAW,EAAE,GAAGH;gBACpD,4DAA4D;gBAC5D,IAAIG,gBAAgBR,WAAWI,UAAU,CAACH,SAAS,EAAE;oBACnD,4DAA4D;oBAC5DI,WAAW,CAACb,yBAAyB,GAAGQ,WAAWI,UAAU,CAACH,SAAS;oBACvE,sCAAsC;oBACtCQ,QAAQC,IAAI,CAAuB,CAAC,2BACP,EAAEf,YAAYgB,IAAI,CAAC;OACvC,EAAEV,SAAS,8CAA8C,EAAEA,SAAS;AAC3E,EAAEO,YAAY,KAAK,EACnBR,WAAWI,UAAU,CAACH,SAAS,CAChC;wGAED,CAAC;gBACH;YACF;QACF;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compose/constants.ts"],"sourcesContent":["/**\n * @internal\n * Internal reference for the render function\n */\nexport const SLOT_RENDER_FUNCTION_SYMBOL = Symbol.for('fui.slotRenderFunction');\n/**\n * @internal\n * Internal reference for the render function\n */\nexport const SLOT_ELEMENT_TYPE_SYMBOL = Symbol.for('fui.slotElementType');\n/**\n * @internal\n * Internal cache of the original className prop for the slot, before being modified by the useStyles hook.\n */\nexport const SLOT_CLASS_NAME_PROP_SYMBOL = Symbol.for('fui.slotClassNameProp');\n"],"names":["SLOT_RENDER_FUNCTION_SYMBOL","Symbol","for","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_CLASS_NAME_PROP_SYMBOL"],"rangeMappings":";;;;;;;;;;;","mappings":"AAAA;;;CAGC,GACD,OAAO,MAAMA,8BAA8BC,OAAOC,GAAG,CAAC,0BAA0B;AAChF;;;CAGC,GACD,OAAO,MAAMC,2BAA2BF,OAAOC,GAAG,CAAC,uBAAuB;AAC1E;;;CAGC,GACD,OAAO,MAAME,8BAA8BH,OAAOC,GAAG,CAAC,yBAAyB"}
1
+ {"version":3,"sources":["../src/compose/constants.ts"],"sourcesContent":["/**\n * @internal\n * Internal reference for the render function\n */\nexport const SLOT_RENDER_FUNCTION_SYMBOL = Symbol.for('fui.slotRenderFunction');\n/**\n * @internal\n * Internal reference for the render function\n */\nexport const SLOT_ELEMENT_TYPE_SYMBOL = Symbol.for('fui.slotElementType');\n/**\n * @internal\n * Internal cache of the original className prop for the slot, before being modified by the useStyles hook.\n */\nexport const SLOT_CLASS_NAME_PROP_SYMBOL = Symbol.for('fui.slotClassNameProp');\n"],"names":["SLOT_RENDER_FUNCTION_SYMBOL","Symbol","for","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_CLASS_NAME_PROP_SYMBOL"],"mappings":"AAAA;;;CAGC,GACD,OAAO,MAAMA,8BAA8BC,OAAOC,GAAG,CAAC,0BAA0B;AAChF;;;CAGC,GACD,OAAO,MAAMC,2BAA2BF,OAAOC,GAAG,CAAC,uBAAuB;AAC1E;;;CAGC,GACD,OAAO,MAAME,8BAA8BH,OAAOC,GAAG,CAAC,yBAAyB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compose/deprecated/getSlots.ts"],"sourcesContent":["import * as React from 'react';\nimport { omit } from '../../utils/omit';\nimport type { ComponentState, SlotPropsRecord, SlotRenderFunction, UnknownSlotProps } from '../types';\nimport { isSlot } from '../isSlot';\nimport { SLOT_RENDER_FUNCTION_SYMBOL } from '../constants';\n\n/**\n * @deprecated - use slot.always or slot.optional combined with assertSlots instead\n */\nexport type Slots<S extends SlotPropsRecord> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof S]: React.ElementType<any>;\n};\n\n/**\n * @deprecated - use slot.always or slot.optional combined with assertSlots instead\n */\nexport type ObjectSlotProps<S extends SlotPropsRecord> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof S]-?: any;\n};\n\n/**\n * Given the state and an array of slot names, will break out `slots` and `slotProps`\n * collections.\n *\n * The root is derived from a mix of `components` props and `as` prop.\n *\n * Slots will render as null if they are rendered as primitives with undefined children.\n *\n * The slotProps will always omit the `as` prop within them, and for slots that are string\n * primitives, the props will be filtered according to the slot type by the type system.\n * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable\n * anchor props. Note that this is only enforced at build time by Typescript -- there is no\n * runtime code filtering props in this function.\n *\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n *\n * @param state - State including slot definitions\n * @returns An object containing the `slots` map and `slotProps` map.\n */\nexport function getSlots<R extends SlotPropsRecord>(\n state: unknown,\n): {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slots: Slots<R>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slotProps: ObjectSlotProps<R>;\n} {\n const typeState = state as ComponentState<R>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const slotNames: (keyof R)[] = Object.keys(typeState.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(typeState, slotName);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return { slots, slotProps: slotProps as unknown as ObjectSlotProps<R> };\n}\n\nfunction getSlot<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n const props = state[slotName];\n\n if (props === undefined) {\n return [null, undefined as R[K]];\n }\n\n type NonUndefined<T> = T extends undefined ? never : T;\n // TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)\n const { as: asProp, children, ...rest } = props as NonUndefined<typeof props>;\n\n const renderFunction = isSlot(props) ? props[SLOT_RENDER_FUNCTION_SYMBOL] : undefined;\n\n const slot = (\n state.components?.[slotName] === undefined || // eslint-disable-line @typescript-eslint/no-deprecated\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n typeof state.components[slotName] === 'string'\n ? // eslint-disable-next-line @typescript-eslint/no-deprecated\n asProp || state.components?.[slotName] || 'div'\n : // eslint-disable-next-line @typescript-eslint/no-deprecated\n state.components[slotName]\n ) as React.ElementType<R[K]>;\n\n if (renderFunction || typeof children === 'function') {\n const render = (renderFunction || children) as SlotRenderFunction<R[K]>;\n return [\n React.Fragment as React.ElementType<R[K]>,\n {\n children: render(slot, rest as Omit<R[K], 'as'>),\n } as unknown as R[K],\n ];\n }\n\n const shouldOmitAsProp = typeof slot === 'string' && asProp;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const slotProps = (shouldOmitAsProp ? omit(props, ['as']) : (props as UnknownSlotProps)) as R[K];\n return [slot, slotProps];\n}\n"],"names":["React","omit","isSlot","SLOT_RENDER_FUNCTION_SYMBOL","getSlots","state","typeState","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","undefined","as","asProp","children","rest","renderFunction","render","Fragment","shouldOmitAsProp"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,IAAI,QAAQ,mBAAmB;AAExC,SAASC,MAAM,QAAQ,YAAY;AACnC,SAASC,2BAA2B,QAAQ,eAAe;AAkB3D;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,SACdC,KAAc;IAOd,MAAMC,YAAYD;IAClB,4DAA4D;IAC5D,MAAME,QAAQ,CAAC;IACf,MAAMC,YAAY,CAAC;IAEnB,4DAA4D;IAC5D,MAAMC,YAAyBC,OAAOC,IAAI,CAACL,UAAUM,UAAU;IAC/D,KAAK,MAAMC,YAAYJ,UAAW;QAChC,MAAM,CAACK,MAAMC,MAAM,GAAGC,QAAQV,WAAWO;QACzC,4DAA4D;QAC5DN,KAAK,CAACM,SAAS,GAAGC;QAClBN,SAAS,CAACK,SAAS,GAAGE;IACxB;IACA,4DAA4D;IAC5D,OAAO;QAAER;QAAOC,WAAWA;IAA2C;AACxE;AAEA,SAASQ,QACPX,KAAwB,EACxBQ,QAAW;QAeTR,mBAIcA;IAjBhB,MAAMU,QAAQV,KAAK,CAACQ,SAAS;IAE7B,IAAIE,UAAUE,WAAW;QACvB,OAAO;YAAC;YAAMA;SAAkB;IAClC;IAGA,yFAAyF;IACzF,MAAM,EAAEC,IAAIC,MAAM,EAAEC,QAAQ,EAAE,GAAGC,MAAM,GAAGN;IAE1C,MAAMO,iBAAiBpB,OAAOa,SAASA,KAAK,CAACZ,4BAA4B,GAAGc;IAE5E,MAAMH,OACJT,EAAAA,oBAAAA,MAAMO,UAAU,cAAhBP,wCAAAA,iBAAkB,CAACQ,SAAS,MAAKI,aAAa,uDAAuD;IACrG,4DAA4D;IAC5D,OAAOZ,MAAMO,UAAU,CAACC,SAAS,KAAK,WAElCM,YAAUd,qBAAAA,MAAMO,UAAU,cAAhBP,yCAAAA,kBAAkB,CAACQ,SAAS,KAAI,QAE1CR,MAAMO,UAAU,CAACC,SAAS;IAGhC,IAAIS,kBAAkB,OAAOF,aAAa,YAAY;QACpD,MAAMG,SAAUD,kBAAkBF;QAClC,OAAO;YACLpB,MAAMwB,QAAQ;YACd;gBACEJ,UAAUG,OAAOT,MAAMO;YACzB;SACD;IACH;IAEA,MAAMI,mBAAmB,OAAOX,SAAS,YAAYK;IACrD,4DAA4D;IAC5D,MAAMX,YAAaiB,mBAAmBxB,KAAKc,OAAO;QAAC;KAAK,IAAKA;IAC7D,OAAO;QAACD;QAAMN;KAAU;AAC1B"}
1
+ {"version":3,"sources":["../src/compose/deprecated/getSlots.ts"],"sourcesContent":["import * as React from 'react';\nimport { omit } from '../../utils/omit';\nimport type { ComponentState, SlotPropsRecord, SlotRenderFunction, UnknownSlotProps } from '../types';\nimport { isSlot } from '../isSlot';\nimport { SLOT_RENDER_FUNCTION_SYMBOL } from '../constants';\n\n/**\n * @deprecated - use slot.always or slot.optional combined with assertSlots instead\n */\nexport type Slots<S extends SlotPropsRecord> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof S]: React.ElementType<any>;\n};\n\n/**\n * @deprecated - use slot.always or slot.optional combined with assertSlots instead\n */\nexport type ObjectSlotProps<S extends SlotPropsRecord> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof S]-?: any;\n};\n\n/**\n * Given the state and an array of slot names, will break out `slots` and `slotProps`\n * collections.\n *\n * The root is derived from a mix of `components` props and `as` prop.\n *\n * Slots will render as null if they are rendered as primitives with undefined children.\n *\n * The slotProps will always omit the `as` prop within them, and for slots that are string\n * primitives, the props will be filtered according to the slot type by the type system.\n * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable\n * anchor props. Note that this is only enforced at build time by Typescript -- there is no\n * runtime code filtering props in this function.\n *\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n *\n * @param state - State including slot definitions\n * @returns An object containing the `slots` map and `slotProps` map.\n */\nexport function getSlots<R extends SlotPropsRecord>(\n state: unknown,\n): {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slots: Slots<R>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slotProps: ObjectSlotProps<R>;\n} {\n const typeState = state as ComponentState<R>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const slotNames: (keyof R)[] = Object.keys(typeState.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(typeState, slotName);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return { slots, slotProps: slotProps as unknown as ObjectSlotProps<R> };\n}\n\nfunction getSlot<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n const props = state[slotName];\n\n if (props === undefined) {\n return [null, undefined as R[K]];\n }\n\n type NonUndefined<T> = T extends undefined ? never : T;\n // TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)\n const { as: asProp, children, ...rest } = props as NonUndefined<typeof props>;\n\n const renderFunction = isSlot(props) ? props[SLOT_RENDER_FUNCTION_SYMBOL] : undefined;\n\n const slot = (\n state.components?.[slotName] === undefined || // eslint-disable-line @typescript-eslint/no-deprecated\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n typeof state.components[slotName] === 'string'\n ? // eslint-disable-next-line @typescript-eslint/no-deprecated\n asProp || state.components?.[slotName] || 'div'\n : // eslint-disable-next-line @typescript-eslint/no-deprecated\n state.components[slotName]\n ) as React.ElementType<R[K]>;\n\n if (renderFunction || typeof children === 'function') {\n const render = (renderFunction || children) as SlotRenderFunction<R[K]>;\n return [\n React.Fragment as React.ElementType<R[K]>,\n {\n children: render(slot, rest as Omit<R[K], 'as'>),\n } as unknown as R[K],\n ];\n }\n\n const shouldOmitAsProp = typeof slot === 'string' && asProp;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const slotProps = (shouldOmitAsProp ? omit(props, ['as']) : (props as UnknownSlotProps)) as R[K];\n return [slot, slotProps];\n}\n"],"names":["React","omit","isSlot","SLOT_RENDER_FUNCTION_SYMBOL","getSlots","state","typeState","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","undefined","as","asProp","children","rest","renderFunction","render","Fragment","shouldOmitAsProp"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,IAAI,QAAQ,mBAAmB;AAExC,SAASC,MAAM,QAAQ,YAAY;AACnC,SAASC,2BAA2B,QAAQ,eAAe;AAkB3D;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,SACdC,KAAc;IAOd,MAAMC,YAAYD;IAClB,4DAA4D;IAC5D,MAAME,QAAQ,CAAC;IACf,MAAMC,YAAY,CAAC;IAEnB,4DAA4D;IAC5D,MAAMC,YAAyBC,OAAOC,IAAI,CAACL,UAAUM,UAAU;IAC/D,KAAK,MAAMC,YAAYJ,UAAW;QAChC,MAAM,CAACK,MAAMC,MAAM,GAAGC,QAAQV,WAAWO;QACzC,4DAA4D;QAC5DN,KAAK,CAACM,SAAS,GAAGC;QAClBN,SAAS,CAACK,SAAS,GAAGE;IACxB;IACA,4DAA4D;IAC5D,OAAO;QAAER;QAAOC,WAAWA;IAA2C;AACxE;AAEA,SAASQ,QACPX,KAAwB,EACxBQ,QAAW;QAeTR,mBAIcA;IAjBhB,MAAMU,QAAQV,KAAK,CAACQ,SAAS;IAE7B,IAAIE,UAAUE,WAAW;QACvB,OAAO;YAAC;YAAMA;SAAkB;IAClC;IAGA,yFAAyF;IACzF,MAAM,EAAEC,IAAIC,MAAM,EAAEC,QAAQ,EAAE,GAAGC,MAAM,GAAGN;IAE1C,MAAMO,iBAAiBpB,OAAOa,SAASA,KAAK,CAACZ,4BAA4B,GAAGc;IAE5E,MAAMH,OACJT,EAAAA,oBAAAA,MAAMO,UAAU,cAAhBP,wCAAAA,iBAAkB,CAACQ,SAAS,MAAKI,aAAa,uDAAuD;IACrG,4DAA4D;IAC5D,OAAOZ,MAAMO,UAAU,CAACC,SAAS,KAAK,WAElCM,YAAUd,qBAAAA,MAAMO,UAAU,cAAhBP,yCAAAA,kBAAkB,CAACQ,SAAS,KAAI,QAE1CR,MAAMO,UAAU,CAACC,SAAS;IAGhC,IAAIS,kBAAkB,OAAOF,aAAa,YAAY;QACpD,MAAMG,SAAUD,kBAAkBF;QAClC,OAAO;YACLpB,MAAMwB,QAAQ;YACd;gBACEJ,UAAUG,OAAOT,MAAMO;YACzB;SACD;IACH;IAEA,MAAMI,mBAAmB,OAAOX,SAAS,YAAYK;IACrD,4DAA4D;IAC5D,MAAMX,YAAaiB,mBAAmBxB,KAAKc,OAAO;QAAC;KAAK,IAAKA;IAC7D,OAAO;QAACD;QAAMN;KAAU;AAC1B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compose/deprecated/getSlotsNext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentState, SlotPropsRecord, UnknownSlotProps } from '../types';\nimport { ObjectSlotProps, Slots } from './getSlots';\n\n/**\n * Similar to `getSlots`, main difference is that it's compatible with new custom jsx pragma\n *\n * @internal\n * This is an internal temporary method, this method will cease to exist eventually!\n *\n * * ❗️❗️ **DO NOT USE IT EXTERNALLY** ❗️❗️\n *\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\nexport function getSlotsNext<R extends SlotPropsRecord>(\n state: unknown,\n): {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slots: Slots<R>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slotProps: ObjectSlotProps<R>;\n} {\n const typedState = state as ComponentState<R>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const slotNames: (keyof R)[] = Object.keys(typedState.components);\n for (const slotName of slotNames) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const [slot, props] = getSlotNext(typedState, slotName);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return { slots, slotProps: slotProps as unknown as ObjectSlotProps<R> };\n}\n\n/**\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\nfunction getSlotNext<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n const props = state[slotName];\n\n if (props === undefined) {\n return [null, undefined as R[K]];\n }\n\n type NonUndefined<T> = T extends undefined ? never : T;\n // TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)\n const { as: asProp, ...propsWithoutAs } = props as NonUndefined<typeof props>;\n\n const slot = (\n state.components?.[slotName] === undefined || // eslint-disable-line @typescript-eslint/no-deprecated\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n typeof state.components[slotName] === 'string'\n ? // eslint-disable-next-line @typescript-eslint/no-deprecated\n asProp || state.components?.[slotName] || 'div'\n : // eslint-disable-next-line @typescript-eslint/no-deprecated\n state.components[slotName]\n ) as React.ElementType<R[K]>;\n\n const shouldOmitAsProp = typeof slot === 'string' && asProp;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const slotProps: UnknownSlotProps = shouldOmitAsProp ? propsWithoutAs : props;\n\n return [slot, slotProps as R[K]];\n}\n"],"names":["React","getSlotsNext","state","typedState","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlotNext","undefined","as","asProp","propsWithoutAs","shouldOmitAsProp"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAI/B;;;;;;;;;CASC,GACD,OAAO,SAASC,aACdC,KAAc;IAOd,MAAMC,aAAaD;IACnB,4DAA4D;IAC5D,MAAME,QAAQ,CAAC;IACf,MAAMC,YAAY,CAAC;IAEnB,4DAA4D;IAC5D,MAAMC,YAAyBC,OAAOC,IAAI,CAACL,WAAWM,UAAU;IAChE,KAAK,MAAMC,YAAYJ,UAAW;QAChC,4DAA4D;QAC5D,MAAM,CAACK,MAAMC,MAAM,GAAGC,YAAYV,YAAYO;QAC9C,4DAA4D;QAC5DN,KAAK,CAACM,SAAS,GAAGC;QAClBN,SAAS,CAACK,SAAS,GAAGE;IACxB;IACA,4DAA4D;IAC5D,OAAO;QAAER;QAAOC,WAAWA;IAA2C;AACxE;AAEA;;CAEC,GACD,SAASQ,YACPX,KAAwB,EACxBQ,QAAW;QAaTR,mBAIcA;IAfhB,MAAMU,QAAQV,KAAK,CAACQ,SAAS;IAE7B,IAAIE,UAAUE,WAAW;QACvB,OAAO;YAAC;YAAMA;SAAkB;IAClC;IAGA,yFAAyF;IACzF,MAAM,EAAEC,IAAIC,MAAM,EAAE,GAAGC,gBAAgB,GAAGL;IAE1C,MAAMD,OACJT,EAAAA,oBAAAA,MAAMO,UAAU,cAAhBP,wCAAAA,iBAAkB,CAACQ,SAAS,MAAKI,aAAa,uDAAuD;IACrG,4DAA4D;IAC5D,OAAOZ,MAAMO,UAAU,CAACC,SAAS,KAAK,WAElCM,YAAUd,qBAAAA,MAAMO,UAAU,cAAhBP,yCAAAA,kBAAkB,CAACQ,SAAS,KAAI,QAE1CR,MAAMO,UAAU,CAACC,SAAS;IAGhC,MAAMQ,mBAAmB,OAAOP,SAAS,YAAYK;IACrD,4DAA4D;IAC5D,MAAMX,YAA8Ba,mBAAmBD,iBAAiBL;IAExE,OAAO;QAACD;QAAMN;KAAkB;AAClC"}
1
+ {"version":3,"sources":["../src/compose/deprecated/getSlotsNext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentState, SlotPropsRecord, UnknownSlotProps } from '../types';\nimport { ObjectSlotProps, Slots } from './getSlots';\n\n/**\n * Similar to `getSlots`, main difference is that it's compatible with new custom jsx pragma\n *\n * @internal\n * This is an internal temporary method, this method will cease to exist eventually!\n *\n * * ❗️❗️ **DO NOT USE IT EXTERNALLY** ❗️❗️\n *\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\nexport function getSlotsNext<R extends SlotPropsRecord>(\n state: unknown,\n): {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slots: Slots<R>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slotProps: ObjectSlotProps<R>;\n} {\n const typedState = state as ComponentState<R>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const slotNames: (keyof R)[] = Object.keys(typedState.components);\n for (const slotName of slotNames) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const [slot, props] = getSlotNext(typedState, slotName);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return { slots, slotProps: slotProps as unknown as ObjectSlotProps<R> };\n}\n\n/**\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\nfunction getSlotNext<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n const props = state[slotName];\n\n if (props === undefined) {\n return [null, undefined as R[K]];\n }\n\n type NonUndefined<T> = T extends undefined ? never : T;\n // TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)\n const { as: asProp, ...propsWithoutAs } = props as NonUndefined<typeof props>;\n\n const slot = (\n state.components?.[slotName] === undefined || // eslint-disable-line @typescript-eslint/no-deprecated\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n typeof state.components[slotName] === 'string'\n ? // eslint-disable-next-line @typescript-eslint/no-deprecated\n asProp || state.components?.[slotName] || 'div'\n : // eslint-disable-next-line @typescript-eslint/no-deprecated\n state.components[slotName]\n ) as React.ElementType<R[K]>;\n\n const shouldOmitAsProp = typeof slot === 'string' && asProp;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const slotProps: UnknownSlotProps = shouldOmitAsProp ? propsWithoutAs : props;\n\n return [slot, slotProps as R[K]];\n}\n"],"names":["React","getSlotsNext","state","typedState","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlotNext","undefined","as","asProp","propsWithoutAs","shouldOmitAsProp"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAI/B;;;;;;;;;CASC,GACD,OAAO,SAASC,aACdC,KAAc;IAOd,MAAMC,aAAaD;IACnB,4DAA4D;IAC5D,MAAME,QAAQ,CAAC;IACf,MAAMC,YAAY,CAAC;IAEnB,4DAA4D;IAC5D,MAAMC,YAAyBC,OAAOC,IAAI,CAACL,WAAWM,UAAU;IAChE,KAAK,MAAMC,YAAYJ,UAAW;QAChC,4DAA4D;QAC5D,MAAM,CAACK,MAAMC,MAAM,GAAGC,YAAYV,YAAYO;QAC9C,4DAA4D;QAC5DN,KAAK,CAACM,SAAS,GAAGC;QAClBN,SAAS,CAACK,SAAS,GAAGE;IACxB;IACA,4DAA4D;IAC5D,OAAO;QAAER;QAAOC,WAAWA;IAA2C;AACxE;AAEA;;CAEC,GACD,SAASQ,YACPX,KAAwB,EACxBQ,QAAW;QAaTR,mBAIcA;IAfhB,MAAMU,QAAQV,KAAK,CAACQ,SAAS;IAE7B,IAAIE,UAAUE,WAAW;QACvB,OAAO;YAAC;YAAMA;SAAkB;IAClC;IAGA,yFAAyF;IACzF,MAAM,EAAEC,IAAIC,MAAM,EAAE,GAAGC,gBAAgB,GAAGL;IAE1C,MAAMD,OACJT,EAAAA,oBAAAA,MAAMO,UAAU,cAAhBP,wCAAAA,iBAAkB,CAACQ,SAAS,MAAKI,aAAa,uDAAuD;IACrG,4DAA4D;IAC5D,OAAOZ,MAAMO,UAAU,CAACC,SAAS,KAAK,WAElCM,YAAUd,qBAAAA,MAAMO,UAAU,cAAhBP,yCAAAA,kBAAkB,CAACQ,SAAS,KAAI,QAE1CR,MAAMO,UAAU,CAACC,SAAS;IAGhC,MAAMQ,mBAAmB,OAAOP,SAAS,YAAYK;IACrD,4DAA4D;IAC5D,MAAMX,YAA8Ba,mBAAmBD,iBAAiBL;IAExE,OAAO;QAACD;QAAMN;KAAkB;AAClC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compose/deprecated/resolveShorthand.ts"],"sourcesContent":["import * as slot from '../slot';\nimport type { UnknownSlotProps, SlotShorthandValue, WithoutSlotRenderFunction } from '../types';\n\n/**\n * @deprecated - use slot.always or slot.optional combined with assertSlots instead\n */\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = Required extends true\n ? { required: true; defaultProps?: Props }\n : { required?: Required; defaultProps?: Props };\n\n/**\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n <P extends Props>(\n value: P | SlotShorthandValue | undefined,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n options: ResolveShorthandOptions<P, true>,\n ): WithoutSlotRenderFunction<P>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <P extends Props>(value: P | SlotShorthandValue | null | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | WithoutSlotRenderFunction<P>\n | undefined;\n};\n\n/**\n *\n * Resolves shorthands into slot props, to ensure normalization of the signature\n * being passed down to getSlots method\n * @param value - the base shorthand props\n * @param options - options to resolve shorthand props\n *\n * @deprecated use slot.always, slot.optional, slot.resolveShorthand combined with assertSlots instead\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport const resolveShorthand: ResolveShorthandFunction<UnknownSlotProps> = (value, options) =>\n slot.optional<UnknownSlotProps>(value, {\n ...options,\n renderByDefault: options?.required,\n // elementType as undefined is the way to identify between a slot and a resolveShorthand call\n // in the case elementType is undefined assertSlots will fail, ensuring it'll only work with slot method.\n elementType: undefined!,\n }) as WithoutSlotRenderFunction<UnknownSlotProps>;\n"],"names":["slot","resolveShorthand","value","options","optional","renderByDefault","required","elementType","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,UAAU,UAAU;AAyBhC;;;;;;;;CAQC,GACD,4DAA4D;AAC5D,OAAO,MAAMC,mBAA+D,CAACC,OAAOC,UAClFH,KAAKI,QAAQ,CAAmBF,OAAO;QACrC,GAAGC,OAAO;QACVE,eAAe,EAAEF,oBAAAA,8BAAAA,QAASG,QAAQ;QAClC,6FAA6F;QAC7F,yGAAyG;QACzGC,aAAaC;IACf,GAAkD"}
1
+ {"version":3,"sources":["../src/compose/deprecated/resolveShorthand.ts"],"sourcesContent":["import * as slot from '../slot';\nimport type { UnknownSlotProps, SlotShorthandValue, WithoutSlotRenderFunction } from '../types';\n\n/**\n * @deprecated - use slot.always or slot.optional combined with assertSlots instead\n */\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = Required extends true\n ? { required: true; defaultProps?: Props }\n : { required?: Required; defaultProps?: Props };\n\n/**\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n <P extends Props>(\n value: P | SlotShorthandValue | undefined,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n options: ResolveShorthandOptions<P, true>,\n ): WithoutSlotRenderFunction<P>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <P extends Props>(value: P | SlotShorthandValue | null | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | WithoutSlotRenderFunction<P>\n | undefined;\n};\n\n/**\n *\n * Resolves shorthands into slot props, to ensure normalization of the signature\n * being passed down to getSlots method\n * @param value - the base shorthand props\n * @param options - options to resolve shorthand props\n *\n * @deprecated use slot.always, slot.optional, slot.resolveShorthand combined with assertSlots instead\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport const resolveShorthand: ResolveShorthandFunction<UnknownSlotProps> = (value, options) =>\n slot.optional<UnknownSlotProps>(value, {\n ...options,\n renderByDefault: options?.required,\n // elementType as undefined is the way to identify between a slot and a resolveShorthand call\n // in the case elementType is undefined assertSlots will fail, ensuring it'll only work with slot method.\n elementType: undefined!,\n }) as WithoutSlotRenderFunction<UnknownSlotProps>;\n"],"names":["slot","resolveShorthand","value","options","optional","renderByDefault","required","elementType","undefined"],"mappings":"AAAA,YAAYA,UAAU,UAAU;AAyBhC;;;;;;;;CAQC,GACD,4DAA4D;AAC5D,OAAO,MAAMC,mBAA+D,CAACC,OAAOC,UAClFH,KAAKI,QAAQ,CAAmBF,OAAO;QACrC,GAAGC,OAAO;QACVE,eAAe,EAAEF,oBAAAA,8BAAAA,QAASG,QAAQ;QAClC,6FAA6F;QAC7F,yGAAyG;QACzGC,aAAaC;IACf,GAAkD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compose/getIntrinsicElementProps.ts"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps } from '../utils/getNativeElementProps';\nimport type { InferredElementRefType, UnknownSlotProps } from './types';\nimport type { DistributiveOmit } from '../utils/types';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype HTMLAttributes = React.HTMLAttributes<any>;\n\n/**\n * Given an element tagname and user props, filters the props to only allowed props for the given\n * element type.\n *\n * Equivalent to {@link getNativeElementProps}, but more type-safe.\n *\n * @param tagName - The slot's default element type (e.g. 'div')\n * @param props - The component's props object\n * @param excludedPropNames - List of native props to exclude from the returned value\n */\nexport const getIntrinsicElementProps = <\n Props extends UnknownSlotProps,\n ExcludedPropKeys extends Extract<keyof Props, string> = never,\n>(\n tagName: NonNullable<Props['as']>,\n // eslint-disable-next-line @typescript-eslint/no-restricted-types -- in order to not introduce Type Restriction CHANGe which is kinda \"breaking change from Types POV\", we don't enforce our custom `RefAttributes` in this API, to be compatible with scenarios where non v9 interfaces might be used. This may/will change with React 19\n props: Props & React.RefAttributes<InferredElementRefType<Props>>,\n excludedPropNames?: ExcludedPropKeys[],\n) => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return getNativeElementProps<\n DistributiveOmit<Props, Exclude<keyof Props, keyof HTMLAttributes | keyof UnknownSlotProps> | ExcludedPropKeys>\n >(props.as ?? tagName, props, excludedPropNames);\n};\n"],"names":["React","getNativeElementProps","getIntrinsicElementProps","tagName","props","excludedPropNames","as"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,qBAAqB,QAAQ,iCAAiC;AAOvE;;;;;;;;;CASC,GACD,OAAO,MAAMC,2BAA2B,CAItCC,SACA,2UAA2U;AAC3UC,OACAC;QAKED;IAHF,4DAA4D;IAC5D,OAAOH,sBAELG,CAAAA,YAAAA,MAAME,EAAE,cAARF,uBAAAA,YAAYD,SAASC,OAAOC;AAChC,EAAE"}
1
+ {"version":3,"sources":["../src/compose/getIntrinsicElementProps.ts"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps } from '../utils/getNativeElementProps';\nimport type { InferredElementRefType, UnknownSlotProps } from './types';\nimport type { DistributiveOmit } from '../utils/types';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype HTMLAttributes = React.HTMLAttributes<any>;\n\n/**\n * Given an element tagname and user props, filters the props to only allowed props for the given\n * element type.\n *\n * Equivalent to {@link getNativeElementProps}, but more type-safe.\n *\n * @param tagName - The slot's default element type (e.g. 'div')\n * @param props - The component's props object\n * @param excludedPropNames - List of native props to exclude from the returned value\n */\nexport const getIntrinsicElementProps = <\n Props extends UnknownSlotProps,\n ExcludedPropKeys extends Extract<keyof Props, string> = never,\n>(\n tagName: NonNullable<Props['as']>,\n // eslint-disable-next-line @typescript-eslint/no-restricted-types -- in order to not introduce Type Restriction CHANGe which is kinda \"breaking change from Types POV\", we don't enforce our custom `RefAttributes` in this API, to be compatible with scenarios where non v9 interfaces might be used. This may/will change with React 19\n props: Props & React.RefAttributes<InferredElementRefType<Props>>,\n excludedPropNames?: ExcludedPropKeys[],\n) => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return getNativeElementProps<\n DistributiveOmit<Props, Exclude<keyof Props, keyof HTMLAttributes | keyof UnknownSlotProps> | ExcludedPropKeys>\n >(props.as ?? tagName, props, excludedPropNames);\n};\n"],"names":["React","getNativeElementProps","getIntrinsicElementProps","tagName","props","excludedPropNames","as"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,qBAAqB,QAAQ,iCAAiC;AAOvE;;;;;;;;;CASC,GACD,OAAO,MAAMC,2BAA2B,CAItCC,SACA,2UAA2U;AAC3UC,OACAC;QAKED;IAHF,4DAA4D;IAC5D,OAAOH,sBAELG,CAAAA,YAAAA,MAAME,EAAE,cAARF,uBAAAA,YAAYD,SAASC,OAAOC;AAChC,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compose/getSlotClassNameProp.ts"],"sourcesContent":["import { SLOT_CLASS_NAME_PROP_SYMBOL } from '../compose/constants';\nimport type { UnknownSlotProps } from '../compose/types';\n\n/**\n * Get the className prop set on the slot by the user, without including the default classes added by the component.\n * Custom style hooks should merge this className _after_ any additional classes added by the hook, to ensure that\n * classes added by the user take precedence over the custom style hook.\n *\n * Example usage in a custom style hook:\n * ```ts\n * state.root.className = mergeClasses(\n * state.root.className,\n * customStyles.root,\n * getSlotClassNameProp_unstable(state.root));\n * ```\n *\n * @returns The className prop set on the slot by the user, or undefined if not set.\n */\nexport const getSlotClassNameProp = (slot: UnknownSlotProps) => {\n if (SLOT_CLASS_NAME_PROP_SYMBOL in slot && typeof slot[SLOT_CLASS_NAME_PROP_SYMBOL] === 'string') {\n return slot[SLOT_CLASS_NAME_PROP_SYMBOL];\n }\n return undefined;\n};\n"],"names":["SLOT_CLASS_NAME_PROP_SYMBOL","getSlotClassNameProp","slot","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,2BAA2B,QAAQ,uBAAuB;AAGnE;;;;;;;;;;;;;;CAcC,GACD,OAAO,MAAMC,uBAAuB,CAACC;IACnC,IAAIF,+BAA+BE,QAAQ,OAAOA,IAAI,CAACF,4BAA4B,KAAK,UAAU;QAChG,OAAOE,IAAI,CAACF,4BAA4B;IAC1C;IACA,OAAOG;AACT,EAAE"}
1
+ {"version":3,"sources":["../src/compose/getSlotClassNameProp.ts"],"sourcesContent":["import { SLOT_CLASS_NAME_PROP_SYMBOL } from '../compose/constants';\nimport type { UnknownSlotProps } from '../compose/types';\n\n/**\n * Get the className prop set on the slot by the user, without including the default classes added by the component.\n * Custom style hooks should merge this className _after_ any additional classes added by the hook, to ensure that\n * classes added by the user take precedence over the custom style hook.\n *\n * Example usage in a custom style hook:\n * ```ts\n * state.root.className = mergeClasses(\n * state.root.className,\n * customStyles.root,\n * getSlotClassNameProp_unstable(state.root));\n * ```\n *\n * @returns The className prop set on the slot by the user, or undefined if not set.\n */\nexport const getSlotClassNameProp = (slot: UnknownSlotProps) => {\n if (SLOT_CLASS_NAME_PROP_SYMBOL in slot && typeof slot[SLOT_CLASS_NAME_PROP_SYMBOL] === 'string') {\n return slot[SLOT_CLASS_NAME_PROP_SYMBOL];\n }\n return undefined;\n};\n"],"names":["SLOT_CLASS_NAME_PROP_SYMBOL","getSlotClassNameProp","slot","undefined"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,uBAAuB;AAGnE;;;;;;;;;;;;;;CAcC,GACD,OAAO,MAAMC,uBAAuB,CAACC;IACnC,IAAIF,+BAA+BE,QAAQ,OAAOA,IAAI,CAACF,4BAA4B,KAAK,UAAU;QAChG,OAAOE,IAAI,CAACF,4BAA4B;IAC1C;IACA,OAAOG;AACT,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compose/index.ts"],"sourcesContent":["import * as slot from './slot';\n\nexport type {\n AsIntrinsicElement,\n ComponentProps,\n ComponentState,\n EventData,\n EventHandler,\n ExtractSlotProps,\n ForwardRefComponent,\n RefAttributes,\n InferredElementRefType,\n IsSingleton,\n Slot,\n SlotClassNames,\n SlotComponentType,\n SlotPropsRecord,\n SlotRenderFunction,\n SlotShorthandValue,\n UnknownSlotProps,\n} from './types';\n\nexport { isResolvedShorthand } from './isResolvedShorthand';\nexport { SLOT_CLASS_NAME_PROP_SYMBOL, SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\nexport { isSlot } from './isSlot';\nexport { assertSlots } from './assertSlots';\nexport { getIntrinsicElementProps } from './getIntrinsicElementProps';\nexport { getSlotClassNameProp as getSlotClassNameProp_unstable } from './getSlotClassNameProp';\n\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport type { ObjectSlotProps, Slots } from './deprecated/getSlots';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { getSlots } from './deprecated/getSlots';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport type { ResolveShorthandFunction, ResolveShorthandOptions } from './deprecated/resolveShorthand';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { resolveShorthand } from './deprecated/resolveShorthand';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { getSlotsNext } from './deprecated/getSlotsNext';\n\nexport { slot };\nexport type { SlotOptions } from './slot';\nexport type { PropsWithoutChildren, PropsWithoutRef } from '../utils/types';\n"],"names":["slot","isResolvedShorthand","SLOT_CLASS_NAME_PROP_SYMBOL","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","isSlot","assertSlots","getIntrinsicElementProps","getSlotClassNameProp","getSlotClassNameProp_unstable","getSlots","resolveShorthand","getSlotsNext"],"rangeMappings":";;;;;;;;;;;;;","mappings":"AAAA,YAAYA,UAAU,SAAS;AAsB/B,SAASC,mBAAmB,QAAQ,wBAAwB;AAC5D,SAASC,2BAA2B,EAAEC,wBAAwB,EAAEC,2BAA2B,QAAQ,cAAc;AACjH,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,wBAAwB,QAAQ,6BAA6B;AACtE,SAASC,wBAAwBC,6BAA6B,QAAQ,yBAAyB;AAI/F,4DAA4D;AAC5D,SAASC,QAAQ,QAAQ,wBAAwB;AAGjD,4DAA4D;AAC5D,SAASC,gBAAgB,QAAQ,gCAAgC;AACjE,4DAA4D;AAC5D,SAASC,YAAY,QAAQ,4BAA4B;AAEzD,SAASZ,IAAI,GAAG"}
1
+ {"version":3,"sources":["../src/compose/index.ts"],"sourcesContent":["import * as slot from './slot';\n\nexport type {\n AsIntrinsicElement,\n ComponentProps,\n ComponentState,\n EventData,\n EventHandler,\n ExtractSlotProps,\n ForwardRefComponent,\n RefAttributes,\n InferredElementRefType,\n IsSingleton,\n Slot,\n SlotClassNames,\n SlotComponentType,\n SlotPropsRecord,\n SlotRenderFunction,\n SlotShorthandValue,\n UnknownSlotProps,\n} from './types';\n\nexport { isResolvedShorthand } from './isResolvedShorthand';\nexport { SLOT_CLASS_NAME_PROP_SYMBOL, SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\nexport { isSlot } from './isSlot';\nexport { assertSlots } from './assertSlots';\nexport { getIntrinsicElementProps } from './getIntrinsicElementProps';\nexport { getSlotClassNameProp as getSlotClassNameProp_unstable } from './getSlotClassNameProp';\n\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport type { ObjectSlotProps, Slots } from './deprecated/getSlots';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { getSlots } from './deprecated/getSlots';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport type { ResolveShorthandFunction, ResolveShorthandOptions } from './deprecated/resolveShorthand';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { resolveShorthand } from './deprecated/resolveShorthand';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { getSlotsNext } from './deprecated/getSlotsNext';\n\nexport { slot };\nexport type { SlotOptions } from './slot';\nexport type { PropsWithoutChildren, PropsWithoutRef } from '../utils/types';\n"],"names":["slot","isResolvedShorthand","SLOT_CLASS_NAME_PROP_SYMBOL","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","isSlot","assertSlots","getIntrinsicElementProps","getSlotClassNameProp","getSlotClassNameProp_unstable","getSlots","resolveShorthand","getSlotsNext"],"mappings":"AAAA,YAAYA,UAAU,SAAS;AAsB/B,SAASC,mBAAmB,QAAQ,wBAAwB;AAC5D,SAASC,2BAA2B,EAAEC,wBAAwB,EAAEC,2BAA2B,QAAQ,cAAc;AACjH,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,wBAAwB,QAAQ,6BAA6B;AACtE,SAASC,wBAAwBC,6BAA6B,QAAQ,yBAAyB;AAI/F,4DAA4D;AAC5D,SAASC,QAAQ,QAAQ,wBAAwB;AAGjD,4DAA4D;AAC5D,SAASC,gBAAgB,QAAQ,gCAAgC;AACjE,4DAA4D;AAC5D,SAASC,YAAY,QAAQ,4BAA4B;AAEzD,SAASZ,IAAI,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compose/isResolvedShorthand.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ExtractSlotProps, Slot, UnknownSlotProps } from './types';\n\n/**\n * Guard method that validates if a shorthand is a slot\n * can be used to extends properties provided by a slot\n *\n * @example\n * ```\n * const backdropSlot = resolveShorthand(backdrop, {\n * defaultProps: {\n * onClick: useEventCallback(event => {\n * if (isResolvedShorthand(backdrop)) {\n * backdrop.onClick?.(event)\n * }\n * // do something after passing click down the line\n * }),\n * },\n * })\n * ```\n * @example\n * ```\n * const handleBackDropClick = (event) => {\n * // do your thing\n * }\n * const backdropSlot = resolveShorthand(backdrop, {\n * defaultProps: {\n * onClick: useEventCallback(\n * mergeCallbacks(isResolvedShorthand(backdrop) ? backdrop.onClick : undefined, handleBackdropClick)\n * )\n * })\n * ```\n */\nexport function isResolvedShorthand<Shorthand extends Slot<UnknownSlotProps>>(\n shorthand?: Shorthand,\n): shorthand is ExtractSlotProps<Shorthand> {\n return (\n shorthand !== null && typeof shorthand === 'object' && !Array.isArray(shorthand) && !React.isValidElement(shorthand)\n );\n}\n"],"names":["React","isResolvedShorthand","shorthand","Array","isArray","isValidElement"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAG/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BC,GACD,OAAO,SAASC,oBACdC,SAAqB;IAErB,OACEA,cAAc,QAAQ,OAAOA,cAAc,YAAY,CAACC,MAAMC,OAAO,CAACF,cAAc,CAACF,MAAMK,cAAc,CAACH;AAE9G"}
1
+ {"version":3,"sources":["../src/compose/isResolvedShorthand.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ExtractSlotProps, Slot, UnknownSlotProps } from './types';\n\n/**\n * Guard method that validates if a shorthand is a slot\n * can be used to extends properties provided by a slot\n *\n * @example\n * ```\n * const backdropSlot = resolveShorthand(backdrop, {\n * defaultProps: {\n * onClick: useEventCallback(event => {\n * if (isResolvedShorthand(backdrop)) {\n * backdrop.onClick?.(event)\n * }\n * // do something after passing click down the line\n * }),\n * },\n * })\n * ```\n * @example\n * ```\n * const handleBackDropClick = (event) => {\n * // do your thing\n * }\n * const backdropSlot = resolveShorthand(backdrop, {\n * defaultProps: {\n * onClick: useEventCallback(\n * mergeCallbacks(isResolvedShorthand(backdrop) ? backdrop.onClick : undefined, handleBackdropClick)\n * )\n * })\n * ```\n */\nexport function isResolvedShorthand<Shorthand extends Slot<UnknownSlotProps>>(\n shorthand?: Shorthand,\n): shorthand is ExtractSlotProps<Shorthand> {\n return (\n shorthand !== null && typeof shorthand === 'object' && !Array.isArray(shorthand) && !React.isValidElement(shorthand)\n );\n}\n"],"names":["React","isResolvedShorthand","shorthand","Array","isArray","isValidElement"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAG/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BC,GACD,OAAO,SAASC,oBACdC,SAAqB;IAErB,OACEA,cAAc,QAAQ,OAAOA,cAAc,YAAY,CAACC,MAAMC,OAAO,CAACF,cAAc,CAACF,MAAMK,cAAc,CAACH;AAE9G"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compose/isSlot.ts"],"sourcesContent":["import { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { SlotComponentType } from './types';\n\n/**\n * Guard method to ensure a given element is a slot.\n * This is mainly used internally to ensure a slot is being used as a component.\n */\nexport function isSlot<Props extends {}>(element: unknown): element is SlotComponentType<Props> {\n return Boolean((element as {} | undefined)?.hasOwnProperty(SLOT_ELEMENT_TYPE_SYMBOL));\n}\n"],"names":["SLOT_ELEMENT_TYPE_SYMBOL","isSlot","element","Boolean","hasOwnProperty"],"rangeMappings":";;;;;;","mappings":"AAAA,SAASA,wBAAwB,QAAQ,cAAc;AAGvD;;;CAGC,GACD,OAAO,SAASC,OAAyBC,OAAgB;IACvD,OAAOC,QAASD,oBAAAA,8BAAD,AAACA,QAA4BE,cAAc,CAACJ;AAC7D"}
1
+ {"version":3,"sources":["../src/compose/isSlot.ts"],"sourcesContent":["import { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { SlotComponentType } from './types';\n\n/**\n * Guard method to ensure a given element is a slot.\n * This is mainly used internally to ensure a slot is being used as a component.\n */\nexport function isSlot<Props extends {}>(element: unknown): element is SlotComponentType<Props> {\n return Boolean((element as {} | undefined)?.hasOwnProperty(SLOT_ELEMENT_TYPE_SYMBOL));\n}\n"],"names":["SLOT_ELEMENT_TYPE_SYMBOL","isSlot","element","Boolean","hasOwnProperty"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,cAAc;AAGvD;;;CAGC,GACD,OAAO,SAASC,OAAyBC,OAAgB;IACvD,OAAOC,QAASD,oBAAAA,8BAAD,AAACA,QAA4BE,cAAc,CAACJ;AAC7D"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compose/slot.ts"],"sourcesContent":["import type {\n AsIntrinsicElement,\n SlotComponentType,\n SlotRenderFunction,\n SlotShorthandValue,\n UnknownSlotProps,\n} from './types';\nimport * as React from 'react';\nimport { SLOT_CLASS_NAME_PROP_SYMBOL, SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\n\nexport type SlotOptions<Props extends UnknownSlotProps> = {\n elementType:\n | React.ComponentType<Props>\n | (Props extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);\n defaultProps?: Partial<Props>;\n};\n\n/**\n * Creates a slot from a slot shorthand or properties (`props.SLOT_NAME` or `props` itself)\n * @param value - the value of the slot, it can be a slot shorthand, a slot component or a slot properties\n * @param options - values you can pass to alter the signature of a slot, those values are:\n *\n * * `elementType` - the base element type of a slot, defaults to `'div'`\n * * `defaultProps` - similar to a React component declaration, you can provide a slot default properties to be merged with the shorthand/properties provided.\n */\nexport function always<Props extends UnknownSlotProps>(\n value: Props | SlotShorthandValue | undefined,\n options: SlotOptions<Props>,\n): SlotComponentType<Props> {\n const { defaultProps, elementType } = options;\n\n const props = resolveShorthand(value);\n\n /**\n * Casting is required here as SlotComponentType is a function, not an object.\n * Although SlotComponentType has a function signature, it is still just an object.\n * This is required to make a slot callable (JSX compatible), this is the exact same approach\n * that is used on `@types/react` components\n */\n const propsWithMetadata = {\n ...defaultProps,\n ...props,\n [SLOT_ELEMENT_TYPE_SYMBOL]: elementType,\n [SLOT_CLASS_NAME_PROP_SYMBOL]: props?.className,\n } as SlotComponentType<Props>;\n\n if (props && typeof props.children === 'function') {\n propsWithMetadata[SLOT_RENDER_FUNCTION_SYMBOL] = props.children as SlotRenderFunction<Props>;\n propsWithMetadata.children = defaultProps?.children;\n }\n\n return propsWithMetadata;\n}\n\n/**\n * Creates a slot from a slot shorthand or properties (`props.SLOT_NAME` or `props` itself)\n * @param value - the value of the slot, it can be a slot shorthand, a slot component or a slot properties\n * @param options - values you can pass to alter the signature of a slot, those values are:\n *\n * * `elementType` - the base element type of a slot, defaults to `'div'`\n * * `defaultProps` - similar to a React component declaration, you can provide a slot default properties to be merged with the shorthand/properties provided\n * * `renderByDefault` - a boolean that indicates if a slot will be rendered even if it's base value is `undefined`.\n * By default if `props.SLOT_NAME` is `undefined` then `state.SLOT_NAME` becomes `undefined`\n * and nothing will be rendered, but if `renderByDefault = true` then `state.SLOT_NAME` becomes an object\n * with the values provided by `options.defaultProps` (or `{}`). This is useful for cases such as providing a default content\n * in case no shorthand is provided, like the case of the `expandIcon` slot for the `AccordionHeader`\n */\nexport function optional<Props extends UnknownSlotProps>(\n value: Props | SlotShorthandValue | undefined | null,\n options: { renderByDefault?: boolean } & SlotOptions<Props>,\n): SlotComponentType<Props> | undefined {\n if (value === null || (value === undefined && !options.renderByDefault)) {\n return undefined;\n }\n return always(value, options);\n}\n\n/**\n * Helper function that converts a slot shorthand or properties to a slot properties object\n * The main difference between this function and `slot` is that this function does not return the metadata required for a slot to be considered a properly renderable slot, it only converts the value to a slot properties object\n * @param value - the value of the slot, it can be a slot shorthand or a slot properties object\n */\nexport function resolveShorthand<Props extends UnknownSlotProps | null | undefined>(\n value: Props | SlotShorthandValue,\n): Props {\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n isIterable(value) ||\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n React.isValidElement<any>(value)\n ) {\n return { children: value } as Props;\n }\n if (value && typeof value !== 'object' && process.env.NODE_ENV !== 'production') {\n // TODO: would be nice to have a link to slot documentation in this error message\n // eslint-disable-next-line no-console\n console.error(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [slot.${resolveShorthand.name}]:\n A slot got an invalid value \"${value}\" (${typeof value}).\n A valid value for a slot is a slot shorthand or slot properties object.\n Slot shorthands can be strings, numbers, arrays or JSX elements\n `);\n }\n\n return value;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isIterable = (value: unknown): value is Iterable<any> =>\n typeof value === 'object' && value !== null && Symbol.iterator in value;\n"],"names":["React","SLOT_CLASS_NAME_PROP_SYMBOL","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","always","value","options","defaultProps","elementType","props","resolveShorthand","propsWithMetadata","className","children","optional","undefined","renderByDefault","isIterable","isValidElement","process","env","NODE_ENV","console","error","name","Symbol","iterator"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAOA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,2BAA2B,EAAEC,wBAAwB,EAAEC,2BAA2B,QAAQ,cAAc;AASjH;;;;;;;CAOC,GACD,OAAO,SAASC,OACdC,KAA6C,EAC7CC,OAA2B;IAE3B,MAAM,EAAEC,YAAY,EAAEC,WAAW,EAAE,GAAGF;IAEtC,MAAMG,QAAQC,iBAAiBL;IAE/B;;;;;GAKC,GACD,MAAMM,oBAAoB;QACxB,GAAGJ,YAAY;QACf,GAAGE,KAAK;QACR,CAACP,yBAAyB,EAAEM;QAC5B,CAACP,4BAA4B,EAAEQ,kBAAAA,4BAAAA,MAAOG,SAAS;IACjD;IAEA,IAAIH,SAAS,OAAOA,MAAMI,QAAQ,KAAK,YAAY;QACjDF,iBAAiB,CAACR,4BAA4B,GAAGM,MAAMI,QAAQ;QAC/DF,kBAAkBE,QAAQ,GAAGN,yBAAAA,mCAAAA,aAAcM,QAAQ;IACrD;IAEA,OAAOF;AACT;AAEA;;;;;;;;;;;;CAYC,GACD,OAAO,SAASG,SACdT,KAAoD,EACpDC,OAA2D;IAE3D,IAAID,UAAU,QAASA,UAAUU,aAAa,CAACT,QAAQU,eAAe,EAAG;QACvE,OAAOD;IACT;IACA,OAAOX,OAAOC,OAAOC;AACvB;AAEA;;;;CAIC,GACD,OAAO,SAASI,iBACdL,KAAiC;IAEjC,IACE,OAAOA,UAAU,YACjB,OAAOA,UAAU,YACjBY,WAAWZ,UACX,8DAA8D;IAC9DL,MAAMkB,cAAc,CAAMb,QAC1B;QACA,OAAO;YAAEQ,UAAUR;QAAM;IAC3B;IACA,IAAIA,SAAS,OAAOA,UAAU,YAAYc,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QAC/E,iFAAiF;QACjF,sCAAsC;QACtCC,QAAQC,KAAK,CAAuB,CAAC,gCACH,EAAEb,iBAAiBc,IAAI,CAAC;6BAC3B,EAAEnB,MAAM,GAAG,EAAE,OAAOA,MAAM;;+DAGzD,CAAC;IACH;IAEA,OAAOA;AACT;AAEA,8DAA8D;AAC9D,MAAMY,aAAa,CAACZ,QAClB,OAAOA,UAAU,YAAYA,UAAU,QAAQoB,OAAOC,QAAQ,IAAIrB"}
1
+ {"version":3,"sources":["../src/compose/slot.ts"],"sourcesContent":["import type {\n AsIntrinsicElement,\n SlotComponentType,\n SlotRenderFunction,\n SlotShorthandValue,\n UnknownSlotProps,\n} from './types';\nimport * as React from 'react';\nimport { SLOT_CLASS_NAME_PROP_SYMBOL, SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\nimport type { JSXIntrinsicElementKeys } from '../utils/types';\n\nexport type SlotOptions<Props extends UnknownSlotProps> = {\n elementType: React.ComponentType<Props> | (Props extends AsIntrinsicElement<infer As> ? As : JSXIntrinsicElementKeys);\n defaultProps?: Partial<Props>;\n};\n\n/**\n * Creates a slot from a slot shorthand or properties (`props.SLOT_NAME` or `props` itself)\n * @param value - the value of the slot, it can be a slot shorthand, a slot component or a slot properties\n * @param options - values you can pass to alter the signature of a slot, those values are:\n *\n * * `elementType` - the base element type of a slot, defaults to `'div'`\n * * `defaultProps` - similar to a React component declaration, you can provide a slot default properties to be merged with the shorthand/properties provided.\n */\nexport function always<Props extends UnknownSlotProps>(\n value: Props | SlotShorthandValue | undefined,\n options: SlotOptions<Props>,\n): SlotComponentType<Props> {\n const { defaultProps, elementType } = options;\n\n const props = resolveShorthand(value);\n\n /**\n * Casting is required here as SlotComponentType is a function, not an object.\n * Although SlotComponentType has a function signature, it is still just an object.\n * This is required to make a slot callable (JSX compatible), this is the exact same approach\n * that is used on `@types/react` components\n */\n const propsWithMetadata = {\n ...defaultProps,\n ...props,\n [SLOT_ELEMENT_TYPE_SYMBOL]: elementType,\n [SLOT_CLASS_NAME_PROP_SYMBOL]: props?.className,\n } as SlotComponentType<Props>;\n\n if (props && typeof props.children === 'function') {\n propsWithMetadata[SLOT_RENDER_FUNCTION_SYMBOL] = props.children as SlotRenderFunction<Props>;\n propsWithMetadata.children = defaultProps?.children;\n }\n\n return propsWithMetadata;\n}\n\n/**\n * Creates a slot from a slot shorthand or properties (`props.SLOT_NAME` or `props` itself)\n * @param value - the value of the slot, it can be a slot shorthand, a slot component or a slot properties\n * @param options - values you can pass to alter the signature of a slot, those values are:\n *\n * * `elementType` - the base element type of a slot, defaults to `'div'`\n * * `defaultProps` - similar to a React component declaration, you can provide a slot default properties to be merged with the shorthand/properties provided\n * * `renderByDefault` - a boolean that indicates if a slot will be rendered even if it's base value is `undefined`.\n * By default if `props.SLOT_NAME` is `undefined` then `state.SLOT_NAME` becomes `undefined`\n * and nothing will be rendered, but if `renderByDefault = true` then `state.SLOT_NAME` becomes an object\n * with the values provided by `options.defaultProps` (or `{}`). This is useful for cases such as providing a default content\n * in case no shorthand is provided, like the case of the `expandIcon` slot for the `AccordionHeader`\n */\nexport function optional<Props extends UnknownSlotProps>(\n value: Props | SlotShorthandValue | undefined | null,\n options: { renderByDefault?: boolean } & SlotOptions<Props>,\n): SlotComponentType<Props> | undefined {\n if (value === null || (value === undefined && !options.renderByDefault)) {\n return undefined;\n }\n return always(value, options);\n}\n\n/**\n * Helper function that converts a slot shorthand or properties to a slot properties object\n * The main difference between this function and `slot` is that this function does not return the metadata required for a slot to be considered a properly renderable slot, it only converts the value to a slot properties object\n * @param value - the value of the slot, it can be a slot shorthand or a slot properties object\n */\nexport function resolveShorthand<Props extends UnknownSlotProps | null | undefined>(\n value: Props | SlotShorthandValue,\n): Props {\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n isIterable(value) ||\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n React.isValidElement<any>(value)\n ) {\n return { children: value } as Props;\n }\n if (value && typeof value !== 'object' && process.env.NODE_ENV !== 'production') {\n // TODO: would be nice to have a link to slot documentation in this error message\n // eslint-disable-next-line no-console\n console.error(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [slot.${resolveShorthand.name}]:\n A slot got an invalid value \"${value}\" (${typeof value}).\n A valid value for a slot is a slot shorthand or slot properties object.\n Slot shorthands can be strings, numbers, arrays or JSX elements\n `);\n }\n\n return value;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isIterable = (value: unknown): value is Iterable<any> =>\n typeof value === 'object' && value !== null && Symbol.iterator in value;\n"],"names":["React","SLOT_CLASS_NAME_PROP_SYMBOL","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","always","value","options","defaultProps","elementType","props","resolveShorthand","propsWithMetadata","className","children","optional","undefined","renderByDefault","isIterable","isValidElement","process","env","NODE_ENV","console","error","name","Symbol","iterator"],"mappings":"AAOA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,2BAA2B,EAAEC,wBAAwB,EAAEC,2BAA2B,QAAQ,cAAc;AAQjH;;;;;;;CAOC,GACD,OAAO,SAASC,OACdC,KAA6C,EAC7CC,OAA2B;IAE3B,MAAM,EAAEC,YAAY,EAAEC,WAAW,EAAE,GAAGF;IAEtC,MAAMG,QAAQC,iBAAiBL;IAE/B;;;;;GAKC,GACD,MAAMM,oBAAoB;QACxB,GAAGJ,YAAY;QACf,GAAGE,KAAK;QACR,CAACP,yBAAyB,EAAEM;QAC5B,CAACP,4BAA4B,EAAEQ,kBAAAA,4BAAAA,MAAOG,SAAS;IACjD;IAEA,IAAIH,SAAS,OAAOA,MAAMI,QAAQ,KAAK,YAAY;QACjDF,iBAAiB,CAACR,4BAA4B,GAAGM,MAAMI,QAAQ;QAC/DF,kBAAkBE,QAAQ,GAAGN,yBAAAA,mCAAAA,aAAcM,QAAQ;IACrD;IAEA,OAAOF;AACT;AAEA;;;;;;;;;;;;CAYC,GACD,OAAO,SAASG,SACdT,KAAoD,EACpDC,OAA2D;IAE3D,IAAID,UAAU,QAASA,UAAUU,aAAa,CAACT,QAAQU,eAAe,EAAG;QACvE,OAAOD;IACT;IACA,OAAOX,OAAOC,OAAOC;AACvB;AAEA;;;;CAIC,GACD,OAAO,SAASI,iBACdL,KAAiC;IAEjC,IACE,OAAOA,UAAU,YACjB,OAAOA,UAAU,YACjBY,WAAWZ,UACX,8DAA8D;IAC9DL,MAAMkB,cAAc,CAAMb,QAC1B;QACA,OAAO;YAAEQ,UAAUR;QAAM;IAC3B;IACA,IAAIA,SAAS,OAAOA,UAAU,YAAYc,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QAC/E,iFAAiF;QACjF,sCAAsC;QACtCC,QAAQC,KAAK,CAAuB,CAAC,gCACH,EAAEb,iBAAiBc,IAAI,CAAC;6BAC3B,EAAEnB,MAAM,GAAG,EAAE,OAAOA,MAAM;;+DAGzD,CAAC;IACH;IAEA,OAAOA;AACT;AAEA,8DAA8D;AAC9D,MAAMY,aAAa,CAACZ,QAClB,OAAOA,UAAU,YAAYA,UAAU,QAAQoB,OAAOC,QAAQ,IAAIrB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compose/types.ts"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_CLASS_NAME_PROP_SYMBOL, SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\nimport type {\n ComponentType,\n FunctionComponent,\n NamedExoticComponent,\n PropsWithoutChildren,\n PropsWithoutRef,\n ReactNode,\n ReactVersionDependent,\n ReplaceNullWithUndefined,\n} from '../utils/types';\n\nexport type SlotRenderFunction<Props> = (Component: React.ElementType<Props>, props: Omit<Props, 'as'>) => ReactNode;\n\n/**\n * Matches any component's Slots type (such as ButtonSlots).\n *\n * This should ONLY be used in type templates as in `extends SlotPropsRecord`;\n * it shouldn't be used as a component's Slots type.\n */\nexport type SlotPropsRecord = Record<string, UnknownSlotProps | SlotShorthandValue | null | undefined>;\n\n/**\n * The shorthand value of a slot allows specifying its child\n */\nexport type SlotShorthandValue = React.ReactElement | string | number | Iterable<ReactNode> | React.ReactPortal;\n\n/**\n * Matches any slot props type.\n *\n * This should ONLY be used in type templates as in `extends UnknownSlotProps`;\n * it shouldn't be used as the type of a slot.\n */\nexport type UnknownSlotProps = Pick<React.HTMLAttributes<HTMLElement>, 'className' | 'style'> & {\n as?: keyof JSX.IntrinsicElements;\n children?: ReactNode;\n};\n\n/**\n * Helper type for {@link Slot}. Adds shorthand types that are assignable to the slot's `children`.\n */\ntype WithSlotShorthandValue<Props> =\n | Props\n | ('children' extends keyof Props ? Extract<SlotShorthandValue, Props['children']> : never);\n\n/**\n * @internal\n * Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`\n * to be a render function that takes those props.\n *\n * Notes: For React 17 and earlier, `children` can be a render function that returns a ReactNode.\n * For React 18 and later, `children` can be any value, as React.ReactNode is a more strict type and does not allow functions anymore.\n * This means that the render functions need to be asserted as `SlotRenderFunction<Props>` for React 18 and later.\n *\n * @example\n * ```tsx\n * // For React 17 and earlier:\n * <Component slot={{ children: (Component, props) => <Component {...props} /> }} />\n *\n * // For React 18 and later:\n * <Component slot={{ children: (Component, props) => <Component {...props} /> as SlotRenderFunction<SlotProps> }} />\n * ```\n */\nexport type WithSlotRenderFunction<Props> = PropsWithoutChildren<Props> & {\n children?: 'children' extends keyof Props\n ? ReactVersionDependent<ReactNode, Props['children'] | SlotRenderFunction<Props>>\n : never;\n};\n\n/**\n * @internal\n */\nexport type WithoutSlotRenderFunction<Props> = Props extends unknown\n ? 'children' extends keyof Props\n ? Omit<Props, 'children'> & { children?: Exclude<Props['children'], Function> }\n : Props\n : never;\n\n/**\n * HTML element types that are not allowed to have children.\n *\n * Reference: https://developer.mozilla.org/en-US/docs/Glossary/Empty_element\n */\ntype EmptyIntrinsicElements =\n | 'area'\n | 'base'\n | 'br'\n | 'col'\n | 'embed'\n | 'hr'\n | 'img'\n | 'input'\n | 'link'\n | 'meta'\n | 'param'\n | 'source'\n | 'track'\n | 'wbr';\n\n/**\n * Helper type for {@link Slot}. Modifies `JSX.IntrinsicElements[Type]`:\n * * Removes legacy string ref.\n * * Disallows children for empty tags like 'img'.\n */\ntype IntrinsicElementProps<Type extends keyof JSX.IntrinsicElements> = Type extends EmptyIntrinsicElements\n ? PropsWithoutChildren<React.PropsWithRef<JSX.IntrinsicElements[Type]>>\n : React.PropsWithRef<JSX.IntrinsicElements[Type]>;\n\n/**\n * The props type and shorthand value for a slot. Type is either a single intrinsic element like `'div'`,\n * or a component like `typeof Button`.\n *\n * If a slot needs to support multiple intrinsic element types, use the `AlternateAs` param (see examples below).\n *\n * By default, slots can be set to `null` to prevent them from being rendered. If a slot must always be rendered,\n * wrap with `NonNullable` (see examples below).\n *\n * @example\n * ```\n * // Intrinsic element examples:\n * Slot<'div'> // Slot is always div\n * Slot<'button', 'a'> // Defaults to button, but allows as=\"a\" with anchor-specific props\n * Slot<'span', 'div' | 'pre'> // Defaults to span, but allows as=\"div\" or as=\"pre\"\n * NonNullable<Slot<'div'>> // Slot that will always be rendered (can't be set to null by the user)\n *\n * // Component examples:\n * Slot<typeof Button> // Slot is always a Button, and accepts all of Button's Props\n * NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)\n * ```\n */\nexport type Slot<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Type extends keyof JSX.IntrinsicElements | ComponentType<any> | UnknownSlotProps,\n AlternateAs extends keyof JSX.IntrinsicElements = never,\n> = IsSingleton<Extract<Type, string>> extends true\n ?\n | WithSlotShorthandValue<\n Type extends keyof JSX.IntrinsicElements // Intrinsic elements like `div`\n ? { as?: Type } & WithSlotRenderFunction<IntrinsicElementProps<Type>>\n : Type extends ComponentType<infer Props> // Component types like `typeof Button`\n ? Props extends UnknownSlotProps\n ? Props\n : WithSlotRenderFunction<Props>\n : Type // Props types like `ButtonProps`\n >\n | (AlternateAs extends unknown\n ? { as: AlternateAs } & WithSlotRenderFunction<IntrinsicElementProps<AlternateAs>>\n : never)\n | null\n : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';\n\n/**\n * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.\n *\n * ```\n * IsSingleton<'a'> // true\n * IsSingleton<'a' | 'b' | 'c'> // false\n * ```\n */\nexport type IsSingleton<T extends string> = { [K in T]: Exclude<T, K> extends never ? true : false }[T];\n\n/**\n * Helper type for inferring the type of the as prop from a Props type.\n *\n * For example:\n * ```\n * type Example<T> = T extends AsIntrinsicElement<infer As> ? As : never;\n * ```\n */\nexport type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> = { as?: As };\n\n/**\n * Removes SlotShorthandValue and null from the slot type, extracting just the slot's Props object.\n */\nexport type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;\n\n/**\n * Defines the Props type for a component given its slots and the definition of which one is the primary slot,\n * defaulting to root if one is not provided.\n */\nexport type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> =\n // Include a prop for each slot (see note below about the Omit)\n // Note: the `Omit<Slots, Primary & 'root'>` here is a little tricky. Here's what it's doing:\n // * If the Primary slot is 'root', then omit the `root` slot prop.\n // * Otherwise, don't omit any props: include *both* the Primary and `root` props.\n // We need both props to allow the user to specify native props for either slot because the `root` slot is\n // special and always gets className and style props, per RFC https://github.com/microsoft/fluentui/pull/18983\n Omit<Slots, Primary & 'root'> &\n // Include all of the props of the primary slot inline in the component's props\n PropsWithoutRef<ExtractSlotProps<Slots[Primary]>>;\n\n/**\n * Defines the State object of a component given its slots.\n */\nexport type ComponentState<Slots extends SlotPropsRecord> = {\n /**\n * @deprecated\n * The base element type for each slot.\n * This property is deprecated and will be removed in a future version.\n * The slot base element type is declared through `slot.*(slotShorthand, {elementType: ElementType})` instead.\n */\n components: {\n [Key in keyof Slots]-?: React.ElementType;\n };\n} & {\n // Include a prop for each slot, with the shorthand resolved to a props object\n // The root slot can never be null, so also exclude null from it\n [Key in keyof Slots]: ReplaceNullWithUndefined<\n WithoutSlotRenderFunction<Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>>\n >;\n};\n\n/**\n * This is part of a hack to infer the element type from a native element *props* type.\n * The only place the original element is found in a native props type (at least that's workable\n * for inference) is in the event handlers, so some of the helper types use this event handler\n * name to infer the original element type.\n *\n * Notes:\n * - Using an extremely obscure event handler reduces the likelihood that its signature will be\n * modified in any component's props.\n * - Inferring based on a single prop name instead of a larger type like `DOMAttributes<T>` should be\n * less expensive for typescript to evaluate and is less likely to result in type expansion in .d.ts.\n */\ntype ObscureEventName = 'onLostPointerCaptureCapture';\n\n/**\n * Infers the element type from props that are declared using ComponentProps.\n */\nexport type InferredElementRefType<Props> = ObscureEventName extends keyof Props\n ? Required<Props>[ObscureEventName] extends React.PointerEventHandler<infer Element>\n ? Element\n : never\n : never;\n\n/**\n * Return type for `React.forwardRef`, including inference of the proper typing for the ref.\n *\n * @remarks\n * {@link React.RefAttributes} is {@link https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/69756 | leaking string references} into `forwardRef` components\n * after introducing {@link https://github.com/DefinitelyTyped/DefinitelyTyped/pull/68720 | RefAttributes Type Extension}, which shipped in `@types/react@18.2.61`\n * - `forwardRef` component do not support string refs.\n * - uses custom `RefAttributes` which is compatible with all React versions enforcing no `string` allowance.\n */\nexport type ForwardRefComponent<Props> = NamedExoticComponent<Props & RefAttributes<InferredElementRefType<Props>>>;\n\n/**\n * Helper type to correctly define the slot class names object.\n */\nexport type SlotClassNames<Slots> = {\n [SlotName in keyof Slots]-?: string;\n};\n\n/**\n * A definition of a slot, as a component, very similar to how a React component is declared,\n * but with some additional metadata that is used to determine how to render the slot.\n */\nexport type SlotComponentType<Props> = WithoutSlotRenderFunction<Props> &\n FunctionComponent<{ children?: ReactNode }> & {\n /**\n * @internal\n */\n [SLOT_RENDER_FUNCTION_SYMBOL]?: SlotRenderFunction<Props>;\n /**\n * @internal\n */\n [SLOT_ELEMENT_TYPE_SYMBOL]:\n | ComponentType<Props>\n | (Props extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);\n /**\n * @internal\n * The original className prop for the slot, before being modified by the useStyles hook.\n */\n [SLOT_CLASS_NAME_PROP_SYMBOL]?: string;\n };\n\n/**\n * Data type for event handlers. It makes data a discriminated union, where each object requires `event` and `type` property.\n * - `event` is the specific event type\n * - `type` is a string literal. It serves as a clear identifier of the event type that reflects the component's state when the event occurred.\n * For example, the Tree component's `onNavigation` event handler has different `type` for different key presses: `{ event: React.KeyboardEvent<HTMLElement>; type: typeof ArrowRight } | { event: React.KeyboardEvent<HTMLElement>; type: typeof ArrowLeft }`.\n * Developers can use the `type` property to identify and filter events of interest.\n * See RFC event-handlers-event-type.md for more details.\n *\n * Example usage:\n * type OnOpenChangeData = (\n * | EventData\\<'click', React.MouseEvent\\<MyComponentElement\\>\\>\n * | EventData\\<'keydown', React.KeyboardEvent\\<MyComponentElement\\>\\>\n * ) & \\{ open: boolean; \\};\n */\nexport type EventData<Type extends string, TEvent> =\n | { type: undefined; event: React.SyntheticEvent | Event }\n | { type: Type; event: TEvent };\n\n/**\n * Type for props that are event handlers.\n * See RFC event-handlers-event-type.md for more details.\n *\n * Example usage:\n * type OnSomeEventData = EventData\\<'click', React.MouseEvent\\<MyComponentElement\\>\\> & \\{ open: boolean; \\};\n * type SomeProps = \\{ onSomeEvent?: EventHandler\\<OnSomeEventData\\>; \\};\n */\nexport type EventHandler<TData extends EventData<string, unknown>> = (\n ev: React.SyntheticEvent | Event,\n data: TData,\n) => void;\n\n/**\n * This type should be used in place of `React.RefAttributes<T>` in all components that specify `ref` prop.\n *\n * If user is using React 18 types `>=18.2.61`, they will run into type issues of incompatible refs, using this type mitigates this issues across react type versions.\n *\n * @remarks\n *\n * React 18 types introduced Type Expansion Change to the `RefAttributes` interface as patch release.\n * These changes were released in `@types/react@18.2.61` (replacing ref with `LegacyRef`, which leaks `string` into the union type, causing breaking changes between v8/v9 libraries):\n * - {@link https://github.com/DefinitelyTyped/DefinitelyTyped/pull/68720 | PR }\n * - {@link https://app.unpkg.com/@types/react@18.2.61/files/index.d.ts | shipped definitions }\n *\n *\n * In React 19 types this was \"reverted\" back to the original `Ref<T>` type.\n * In order to maintain compatibility with React 17,18,19, we are forced to use our own version of `RefAttributes`.\n *\n */\nexport interface RefAttributes<T> extends React.Attributes {\n ref?: React.Ref<T> | undefined;\n}\n"],"names":["React"],"rangeMappings":"","mappings":"AAAA,YAAYA,WAAW,QAAQ"}
1
+ {"version":3,"sources":["../src/compose/types.ts"],"sourcesContent":["import * as React from 'react';\nimport { SLOT_CLASS_NAME_PROP_SYMBOL, SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\nimport type {\n ComponentType,\n FunctionComponent,\n NamedExoticComponent,\n PropsWithoutChildren,\n PropsWithoutRef,\n ReactNode,\n ReactVersionDependent,\n ReplaceNullWithUndefined,\n JSXIntrinsicElementKeys,\n JSXIntrinsicElement,\n} from '../utils/types';\n\nexport type SlotRenderFunction<Props> = (Component: React.ElementType<Props>, props: Omit<Props, 'as'>) => ReactNode;\n\n/**\n * Matches any component's Slots type (such as ButtonSlots).\n *\n * This should ONLY be used in type templates as in `extends SlotPropsRecord`;\n * it shouldn't be used as a component's Slots type.\n */\nexport type SlotPropsRecord = Record<string, UnknownSlotProps | SlotShorthandValue | null | undefined>;\n\n/**\n * The shorthand value of a slot allows specifying its child\n */\nexport type SlotShorthandValue = React.ReactElement | string | number | Iterable<ReactNode> | React.ReactPortal;\n\n/**\n * Matches any slot props type.\n *\n * This should ONLY be used in type templates as in `extends UnknownSlotProps`;\n * it shouldn't be used as the type of a slot.\n */\nexport type UnknownSlotProps = Pick<React.HTMLAttributes<HTMLElement>, 'className' | 'style'> & {\n as?: JSXIntrinsicElementKeys;\n children?: ReactNode;\n};\n\n/**\n * Helper type for {@link Slot}. Adds shorthand types that are assignable to the slot's `children`.\n */\ntype WithSlotShorthandValue<Props> =\n | Props\n | ('children' extends keyof Props ? Extract<SlotShorthandValue, Props['children']> : never);\n\n/**\n * @internal\n * Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`\n * to be a render function that takes those props.\n *\n * Notes: For React 17 and earlier, `children` can be a render function that returns a ReactNode.\n * For React 18 and later, `children` can be any value, as React.ReactNode is a more strict type and does not allow functions anymore.\n * This means that the render functions need to be asserted as `SlotRenderFunction<Props>` for React 18 and later.\n *\n * @example\n * ```tsx\n * // For React 17 and earlier:\n * <Component slot={{ children: (Component, props) => <Component {...props} /> }} />\n *\n * // For React 18 and later:\n * <Component slot={{ children: (Component, props) => <Component {...props} /> as SlotRenderFunction<SlotProps> }} />\n * ```\n */\nexport type WithSlotRenderFunction<Props> = PropsWithoutChildren<Props> & {\n children?: 'children' extends keyof Props\n ? ReactVersionDependent<ReactNode, Props['children'] | SlotRenderFunction<Props>>\n : never;\n};\n\n/**\n * @internal\n */\nexport type WithoutSlotRenderFunction<Props> = Props extends unknown\n ? 'children' extends keyof Props\n ? Omit<Props, 'children'> & { children?: Exclude<Props['children'], Function> }\n : Props\n : never;\n\n/**\n * HTML element types that are not allowed to have children.\n *\n * Reference: https://developer.mozilla.org/en-US/docs/Glossary/Empty_element\n */\ntype EmptyIntrinsicElements =\n | 'area'\n | 'base'\n | 'br'\n | 'col'\n | 'embed'\n | 'hr'\n | 'img'\n | 'input'\n | 'link'\n | 'meta'\n | 'param'\n | 'source'\n | 'track'\n | 'wbr';\n\n/**\n * Helper type for {@link Slot}. Modifies `JSXIntrinsicElements<Type>`:\n * * Removes legacy string ref.\n * * Disallows children for empty tags like 'img'.\n */\ntype IntrinsicElementProps<Type extends JSXIntrinsicElementKeys> = Type extends EmptyIntrinsicElements\n ? PropsWithoutChildren<React.PropsWithRef<JSXIntrinsicElement<Type>>>\n : React.PropsWithRef<JSXIntrinsicElement<Type>>;\n\n/**\n * The props type and shorthand value for a slot. Type is either a single intrinsic element like `'div'`,\n * or a component like `typeof Button`.\n *\n * If a slot needs to support multiple intrinsic element types, use the `AlternateAs` param (see examples below).\n *\n * By default, slots can be set to `null` to prevent them from being rendered. If a slot must always be rendered,\n * wrap with `NonNullable` (see examples below).\n *\n * @example\n * ```\n * // Intrinsic element examples:\n * Slot<'div'> // Slot is always div\n * Slot<'button', 'a'> // Defaults to button, but allows as=\"a\" with anchor-specific props\n * Slot<'span', 'div' | 'pre'> // Defaults to span, but allows as=\"div\" or as=\"pre\"\n * NonNullable<Slot<'div'>> // Slot that will always be rendered (can't be set to null by the user)\n *\n * // Component examples:\n * Slot<typeof Button> // Slot is always a Button, and accepts all of Button's Props\n * NonNullable<Slot<typeof Label>> // Slot is a Label and will always be rendered (can't be set to null by the user)\n * ```\n */\nexport type Slot<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Type extends JSXIntrinsicElementKeys | ComponentType<any> | UnknownSlotProps,\n AlternateAs extends JSXIntrinsicElementKeys = never,\n> = IsSingleton<Extract<Type, string>> extends true\n ?\n | WithSlotShorthandValue<\n Type extends JSXIntrinsicElementKeys // Intrinsic elements like `div`\n ? { as?: Type } & WithSlotRenderFunction<IntrinsicElementProps<Type>>\n : Type extends ComponentType<infer Props> // Component types like `typeof Button`\n ? Props extends UnknownSlotProps\n ? Props\n : WithSlotRenderFunction<Props>\n : Type // Props types like `ButtonProps`\n >\n | (AlternateAs extends unknown\n ? { as: AlternateAs } & WithSlotRenderFunction<IntrinsicElementProps<AlternateAs>>\n : never)\n | null\n : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';\n\n/**\n * Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.\n *\n * ```\n * IsSingleton<'a'> // true\n * IsSingleton<'a' | 'b' | 'c'> // false\n * ```\n */\nexport type IsSingleton<T extends string> = { [K in T]: Exclude<T, K> extends never ? true : false }[T];\n\n/**\n * Helper type for inferring the type of the as prop from a Props type.\n *\n * For example:\n * ```\n * type Example<T> = T extends AsIntrinsicElement<infer As> ? As : never;\n * ```\n */\nexport type AsIntrinsicElement<As extends JSXIntrinsicElementKeys> = { as?: As };\n\n/**\n * Removes SlotShorthandValue and null from the slot type, extracting just the slot's Props object.\n */\nexport type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;\n\n/**\n * Defines the Props type for a component given its slots and the definition of which one is the primary slot,\n * defaulting to root if one is not provided.\n */\nexport type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> =\n // Include a prop for each slot (see note below about the Omit)\n // Note: the `Omit<Slots, Primary & 'root'>` here is a little tricky. Here's what it's doing:\n // * If the Primary slot is 'root', then omit the `root` slot prop.\n // * Otherwise, don't omit any props: include *both* the Primary and `root` props.\n // We need both props to allow the user to specify native props for either slot because the `root` slot is\n // special and always gets className and style props, per RFC https://github.com/microsoft/fluentui/pull/18983\n Omit<Slots, Primary & 'root'> &\n // Include all of the props of the primary slot inline in the component's props\n PropsWithoutRef<ExtractSlotProps<Slots[Primary]>>;\n\n/**\n * Defines the State object of a component given its slots.\n */\nexport type ComponentState<Slots extends SlotPropsRecord> = {\n /**\n * @deprecated\n * The base element type for each slot.\n * This property is deprecated and will be removed in a future version.\n * The slot base element type is declared through `slot.*(slotShorthand, {elementType: ElementType})` instead.\n */\n components: {\n [Key in keyof Slots]-?: React.ElementType;\n };\n} & {\n // Include a prop for each slot, with the shorthand resolved to a props object\n // The root slot can never be null, so also exclude null from it\n [Key in keyof Slots]: ReplaceNullWithUndefined<\n WithoutSlotRenderFunction<Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>>\n >;\n};\n\n/**\n * This is part of a hack to infer the element type from a native element *props* type.\n * The only place the original element is found in a native props type (at least that's workable\n * for inference) is in the event handlers, so some of the helper types use this event handler\n * name to infer the original element type.\n *\n * Notes:\n * - Using an extremely obscure event handler reduces the likelihood that its signature will be\n * modified in any component's props.\n * - Inferring based on a single prop name instead of a larger type like `DOMAttributes<T>` should be\n * less expensive for typescript to evaluate and is less likely to result in type expansion in .d.ts.\n */\ntype ObscureEventName = 'onLostPointerCaptureCapture';\n\n/**\n * Infers the element type from props that are declared using ComponentProps.\n */\nexport type InferredElementRefType<Props> = ObscureEventName extends keyof Props\n ? Required<Props>[ObscureEventName] extends React.PointerEventHandler<infer Element>\n ? Element\n : never\n : never;\n\n/**\n * Return type for `React.forwardRef`, including inference of the proper typing for the ref.\n *\n * @remarks\n * {@link React.RefAttributes} is {@link https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/69756 | leaking string references} into `forwardRef` components\n * after introducing {@link https://github.com/DefinitelyTyped/DefinitelyTyped/pull/68720 | RefAttributes Type Extension}, which shipped in `@types/react@18.2.61`\n * - `forwardRef` component do not support string refs.\n * - uses custom `RefAttributes` which is compatible with all React versions enforcing no `string` allowance.\n */\nexport type ForwardRefComponent<Props> = NamedExoticComponent<Props & RefAttributes<InferredElementRefType<Props>>>;\n\n/**\n * Helper type to correctly define the slot class names object.\n */\nexport type SlotClassNames<Slots> = {\n [SlotName in keyof Slots]-?: string;\n};\n\n/**\n * A definition of a slot, as a component, very similar to how a React component is declared,\n * but with some additional metadata that is used to determine how to render the slot.\n */\nexport type SlotComponentType<Props> = WithoutSlotRenderFunction<Props> &\n FunctionComponent<{ children?: ReactNode }> & {\n /**\n * @internal\n */\n [SLOT_RENDER_FUNCTION_SYMBOL]?: SlotRenderFunction<Props>;\n /**\n * @internal\n */\n [SLOT_ELEMENT_TYPE_SYMBOL]:\n | ComponentType<Props>\n | (Props extends AsIntrinsicElement<infer As> ? As : JSXIntrinsicElementKeys);\n /**\n * @internal\n * The original className prop for the slot, before being modified by the useStyles hook.\n */\n [SLOT_CLASS_NAME_PROP_SYMBOL]?: string;\n };\n\n/**\n * Data type for event handlers. It makes data a discriminated union, where each object requires `event` and `type` property.\n * - `event` is the specific event type\n * - `type` is a string literal. It serves as a clear identifier of the event type that reflects the component's state when the event occurred.\n * For example, the Tree component's `onNavigation` event handler has different `type` for different key presses: `{ event: React.KeyboardEvent<HTMLElement>; type: typeof ArrowRight } | { event: React.KeyboardEvent<HTMLElement>; type: typeof ArrowLeft }`.\n * Developers can use the `type` property to identify and filter events of interest.\n * See RFC event-handlers-event-type.md for more details.\n *\n * Example usage:\n * type OnOpenChangeData = (\n * | EventData\\<'click', React.MouseEvent\\<MyComponentElement\\>\\>\n * | EventData\\<'keydown', React.KeyboardEvent\\<MyComponentElement\\>\\>\n * ) & \\{ open: boolean; \\};\n */\nexport type EventData<Type extends string, TEvent> =\n | { type: undefined; event: React.SyntheticEvent | Event }\n | { type: Type; event: TEvent };\n\n/**\n * Type for props that are event handlers.\n * See RFC event-handlers-event-type.md for more details.\n *\n * Example usage:\n * type OnSomeEventData = EventData\\<'click', React.MouseEvent\\<MyComponentElement\\>\\> & \\{ open: boolean; \\};\n * type SomeProps = \\{ onSomeEvent?: EventHandler\\<OnSomeEventData\\>; \\};\n */\nexport type EventHandler<TData extends EventData<string, unknown>> = (\n ev: React.SyntheticEvent | Event,\n data: TData,\n) => void;\n\n/**\n * This type should be used in place of `React.RefAttributes<T>` in all components that specify `ref` prop.\n *\n * If user is using React 18 types `>=18.2.61`, they will run into type issues of incompatible refs, using this type mitigates this issues across react type versions.\n *\n * @remarks\n *\n * React 18 types introduced Type Expansion Change to the `RefAttributes` interface as patch release.\n * These changes were released in `@types/react@18.2.61` (replacing ref with `LegacyRef`, which leaks `string` into the union type, causing breaking changes between v8/v9 libraries):\n * - {@link https://github.com/DefinitelyTyped/DefinitelyTyped/pull/68720 | PR }\n * - {@link https://app.unpkg.com/@types/react@18.2.61/files/index.d.ts | shipped definitions }\n *\n *\n * In React 19 types this was \"reverted\" back to the original `Ref<T>` type.\n * In order to maintain compatibility with React 17,18,19, we are forced to use our own version of `RefAttributes`.\n *\n */\nexport interface RefAttributes<T> extends React.Attributes {\n ref?: React.Ref<T> | undefined;\n}\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/events/index.ts"],"sourcesContent":["export type { NativeTouchOrMouseEvent, ReactTouchOrMouseEvent, TouchOrMouseEvent } from './mouseTouchHelpers';\nexport { getEventClientCoords, isMouseEvent, isTouchEvent } from './mouseTouchHelpers';\n"],"names":["getEventClientCoords","isMouseEvent","isTouchEvent"],"rangeMappings":"","mappings":"AACA,SAASA,oBAAoB,EAAEC,YAAY,EAAEC,YAAY,QAAQ,sBAAsB"}
1
+ {"version":3,"sources":["../src/events/index.ts"],"sourcesContent":["export type { NativeTouchOrMouseEvent, ReactTouchOrMouseEvent, TouchOrMouseEvent } from './mouseTouchHelpers';\nexport { getEventClientCoords, isMouseEvent, isTouchEvent } from './mouseTouchHelpers';\n"],"names":["getEventClientCoords","isMouseEvent","isTouchEvent"],"mappings":"AACA,SAASA,oBAAoB,EAAEC,YAAY,EAAEC,YAAY,QAAQ,sBAAsB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/events/mouseTouchHelpers.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type NativeTouchOrMouseEvent = MouseEvent | TouchEvent;\n\nexport type ReactTouchOrMouseEvent = React.MouseEvent | React.TouchEvent;\n\nexport type TouchOrMouseEvent = NativeTouchOrMouseEvent | ReactTouchOrMouseEvent;\n\n/**\n * Returns true if event is a touch event. Useful when sharing logic between touch and mouse interactions.\n */\nexport function isTouchEvent(event: TouchOrMouseEvent): event is TouchEvent | React.TouchEvent {\n return event.type.startsWith('touch');\n}\n\n/**\n * Returns true if event is a mouse event. Useful when sharing logic between touch and mouse interactions.\n */\nexport function isMouseEvent(event: TouchOrMouseEvent): event is MouseEvent | React.MouseEvent {\n return event.type.startsWith('mouse') || ['click', 'contextmenu', 'dblclick'].indexOf(event.type) > -1;\n}\n\n/**\n * Returns an object with clientX, clientY for TouchOrMouseEvent.\n * Returns zeros in case the event is not a mouse or a touch event.\n */\nexport function getEventClientCoords(event: TouchOrMouseEvent): { clientX: number; clientY: number } {\n if (isMouseEvent(event)) {\n return { clientX: event.clientX, clientY: event.clientY };\n } else if (isTouchEvent(event)) {\n return { clientX: event.touches[0].clientX, clientY: event.touches[0].clientY };\n } else {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('@fluentui/react-utilities]: Unable to get clientX. Unknown event type.');\n }\n return { clientX: 0, clientY: 0 };\n }\n}\n"],"names":["React","isTouchEvent","event","type","startsWith","isMouseEvent","indexOf","getEventClientCoords","clientX","clientY","touches","process","env","NODE_ENV","Error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAQ/B;;CAEC,GACD,OAAO,SAASC,aAAaC,KAAwB;IACnD,OAAOA,MAAMC,IAAI,CAACC,UAAU,CAAC;AAC/B;AAEA;;CAEC,GACD,OAAO,SAASC,aAAaH,KAAwB;IACnD,OAAOA,MAAMC,IAAI,CAACC,UAAU,CAAC,YAAY;QAAC;QAAS;QAAe;KAAW,CAACE,OAAO,CAACJ,MAAMC,IAAI,IAAI,CAAC;AACvG;AAEA;;;CAGC,GACD,OAAO,SAASI,qBAAqBL,KAAwB;IAC3D,IAAIG,aAAaH,QAAQ;QACvB,OAAO;YAAEM,SAASN,MAAMM,OAAO;YAAEC,SAASP,MAAMO,OAAO;QAAC;IAC1D,OAAO,IAAIR,aAAaC,QAAQ;QAC9B,OAAO;YAAEM,SAASN,MAAMQ,OAAO,CAAC,EAAE,CAACF,OAAO;YAAEC,SAASP,MAAMQ,OAAO,CAAC,EAAE,CAACD,OAAO;QAAC;IAChF,OAAO;QACL,IAAIE,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACzC,MAAM,IAAIC,MAAM;QAClB;QACA,OAAO;YAAEN,SAAS;YAAGC,SAAS;QAAE;IAClC;AACF"}
1
+ {"version":3,"sources":["../src/events/mouseTouchHelpers.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type NativeTouchOrMouseEvent = MouseEvent | TouchEvent;\n\nexport type ReactTouchOrMouseEvent = React.MouseEvent | React.TouchEvent;\n\nexport type TouchOrMouseEvent = NativeTouchOrMouseEvent | ReactTouchOrMouseEvent;\n\n/**\n * Returns true if event is a touch event. Useful when sharing logic between touch and mouse interactions.\n */\nexport function isTouchEvent(event: TouchOrMouseEvent): event is TouchEvent | React.TouchEvent {\n return event.type.startsWith('touch');\n}\n\n/**\n * Returns true if event is a mouse event. Useful when sharing logic between touch and mouse interactions.\n */\nexport function isMouseEvent(event: TouchOrMouseEvent): event is MouseEvent | React.MouseEvent {\n return event.type.startsWith('mouse') || ['click', 'contextmenu', 'dblclick'].indexOf(event.type) > -1;\n}\n\n/**\n * Returns an object with clientX, clientY for TouchOrMouseEvent.\n * Returns zeros in case the event is not a mouse or a touch event.\n */\nexport function getEventClientCoords(event: TouchOrMouseEvent): { clientX: number; clientY: number } {\n if (isMouseEvent(event)) {\n return { clientX: event.clientX, clientY: event.clientY };\n } else if (isTouchEvent(event)) {\n return { clientX: event.touches[0].clientX, clientY: event.touches[0].clientY };\n } else {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('@fluentui/react-utilities]: Unable to get clientX. Unknown event type.');\n }\n return { clientX: 0, clientY: 0 };\n }\n}\n"],"names":["React","isTouchEvent","event","type","startsWith","isMouseEvent","indexOf","getEventClientCoords","clientX","clientY","touches","process","env","NODE_ENV","Error"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAQ/B;;CAEC,GACD,OAAO,SAASC,aAAaC,KAAwB;IACnD,OAAOA,MAAMC,IAAI,CAACC,UAAU,CAAC;AAC/B;AAEA;;CAEC,GACD,OAAO,SAASC,aAAaH,KAAwB;IACnD,OAAOA,MAAMC,IAAI,CAACC,UAAU,CAAC,YAAY;QAAC;QAAS;QAAe;KAAW,CAACE,OAAO,CAACJ,MAAMC,IAAI,IAAI,CAAC;AACvG;AAEA;;;CAGC,GACD,OAAO,SAASI,qBAAqBL,KAAwB;IAC3D,IAAIG,aAAaH,QAAQ;QACvB,OAAO;YAAEM,SAASN,MAAMM,OAAO;YAAEC,SAASP,MAAMO,OAAO;QAAC;IAC1D,OAAO,IAAIR,aAAaC,QAAQ;QAC9B,OAAO;YAAEM,SAASN,MAAMQ,OAAO,CAAC,EAAE,CAACF,OAAO;YAAEC,SAASP,MAAMQ,OAAO,CAAC,EAAE,CAACD,OAAO;QAAC;IAChF,OAAO;QACL,IAAIE,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACzC,MAAM,IAAIC,MAAM;QAClB;QACA,OAAO;YAAEN,SAAS;YAAGC,SAAS;QAAE;IAClC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/index.ts"],"sourcesContent":["export { useAnimationFrame } from './useAnimationFrame';\nexport type { UseControllableStateOptions } from './useControllableState';\nexport { useControllableState } from './useControllableState';\nexport { useEventCallback } from './useEventCallback';\nexport { useFirstMount } from './useFirstMount';\nexport { useForceUpdate } from './useForceUpdate';\nexport { IdPrefixProvider, resetIdsForTests, useId } from './useId';\nexport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\nexport type { RefObjectFunction } from './useMergedRefs';\nexport { useMergedRefs } from './useMergedRefs';\nexport type { UseOnClickOrScrollOutsideOptions } from './useOnClickOutside';\nexport { useOnClickOutside } from './useOnClickOutside';\nexport { useOnScrollOutside } from './useOnScrollOutside';\nexport { usePrevious } from './usePrevious';\nexport { useScrollbarWidth } from './useScrollbarWidth';\nexport { useTimeout } from './useTimeout';\n"],"names":["useAnimationFrame","useControllableState","useEventCallback","useFirstMount","useForceUpdate","IdPrefixProvider","resetIdsForTests","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout"],"rangeMappings":";;;;;;;;;;;;","mappings":"AAAA,SAASA,iBAAiB,QAAQ,sBAAsB;AAExD,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,gBAAgB,EAAEC,gBAAgB,EAAEC,KAAK,QAAQ,UAAU;AACpE,SAASC,yBAAyB,QAAQ,8BAA8B;AAExE,SAASC,aAAa,QAAQ,kBAAkB;AAEhD,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,kBAAkB,QAAQ,uBAAuB;AAC1D,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,UAAU,QAAQ,eAAe"}
1
+ {"version":3,"sources":["../src/hooks/index.ts"],"sourcesContent":["export { useAnimationFrame } from './useAnimationFrame';\nexport type { UseControllableStateOptions } from './useControllableState';\nexport { useControllableState } from './useControllableState';\nexport { useEventCallback } from './useEventCallback';\nexport { useFirstMount } from './useFirstMount';\nexport { useForceUpdate } from './useForceUpdate';\nexport { IdPrefixProvider, resetIdsForTests, useId } from './useId';\nexport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\nexport type { RefObjectFunction } from './useMergedRefs';\nexport { useMergedRefs } from './useMergedRefs';\nexport type { UseOnClickOrScrollOutsideOptions } from './useOnClickOutside';\nexport { useOnClickOutside } from './useOnClickOutside';\nexport { useOnScrollOutside } from './useOnScrollOutside';\nexport { usePrevious } from './usePrevious';\nexport { useScrollbarWidth } from './useScrollbarWidth';\nexport { useTimeout } from './useTimeout';\n"],"names":["useAnimationFrame","useControllableState","useEventCallback","useFirstMount","useForceUpdate","IdPrefixProvider","resetIdsForTests","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,sBAAsB;AAExD,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,gBAAgB,EAAEC,gBAAgB,EAAEC,KAAK,QAAQ,UAAU;AACpE,SAASC,yBAAyB,QAAQ,8BAA8B;AAExE,SAASC,aAAa,QAAQ,kBAAkB;AAEhD,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,kBAAkB,QAAQ,uBAAuB;AAC1D,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,UAAU,QAAQ,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useAnimationFrame.ts"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\nconst setAnimationFrameNoop = (callback: FrameRequestCallback) => {\n callback(0);\n return 0;\n};\nconst cancelAnimationFrameNoop = (handle: number) => handle;\n\n/**\n * @internal\n * Helper to manage a browser requestAnimationFrame.\n * Ensures that the requestAnimationFrame isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [requestAnimationFrame, cancelAnimationFrame] that are stable between renders.\n */\nexport function useAnimationFrame() {\n const { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\n\n const setAnimationFrame = win ? win.requestAnimationFrame : setAnimationFrameNoop;\n const clearAnimationFrame = win ? win.cancelAnimationFrame : cancelAnimationFrameNoop;\n\n return useBrowserTimer(setAnimationFrame, clearAnimationFrame);\n}\n"],"names":["useBrowserTimer","useFluent_unstable","useFluent","setAnimationFrameNoop","callback","cancelAnimationFrameNoop","handle","useAnimationFrame","targetDocument","win","defaultView","setAnimationFrame","requestAnimationFrame","clearAnimationFrame","cancelAnimationFrame"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AACpD,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAElF,MAAMC,wBAAwB,CAACC;IAC7BA,SAAS;IACT,OAAO;AACT;AACA,MAAMC,2BAA2B,CAACC,SAAmBA;AAErD;;;;;;;CAOC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,cAAc,EAAE,GAAGN;IAC3B,MAAMO,MAAMD,2BAAAA,qCAAAA,eAAgBE,WAAW;IAEvC,MAAMC,oBAAoBF,MAAMA,IAAIG,qBAAqB,GAAGT;IAC5D,MAAMU,sBAAsBJ,MAAMA,IAAIK,oBAAoB,GAAGT;IAE7D,OAAOL,gBAAgBW,mBAAmBE;AAC5C"}
1
+ {"version":3,"sources":["../src/hooks/useAnimationFrame.ts"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\nconst setAnimationFrameNoop = (callback: FrameRequestCallback) => {\n callback(0);\n return 0;\n};\nconst cancelAnimationFrameNoop = (handle: number) => handle;\n\n/**\n * @internal\n * Helper to manage a browser requestAnimationFrame.\n * Ensures that the requestAnimationFrame isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [requestAnimationFrame, cancelAnimationFrame] that are stable between renders.\n */\nexport function useAnimationFrame() {\n const { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\n\n const setAnimationFrame = win ? win.requestAnimationFrame : setAnimationFrameNoop;\n const clearAnimationFrame = win ? win.cancelAnimationFrame : cancelAnimationFrameNoop;\n\n return useBrowserTimer(setAnimationFrame, clearAnimationFrame);\n}\n"],"names":["useBrowserTimer","useFluent_unstable","useFluent","setAnimationFrameNoop","callback","cancelAnimationFrameNoop","handle","useAnimationFrame","targetDocument","win","defaultView","setAnimationFrame","requestAnimationFrame","clearAnimationFrame","cancelAnimationFrame"],"mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AACpD,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAElF,MAAMC,wBAAwB,CAACC;IAC7BA,SAAS;IACT,OAAO;AACT;AACA,MAAMC,2BAA2B,CAACC,SAAmBA;AAErD;;;;;;;CAOC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,cAAc,EAAE,GAAGN;IAC3B,MAAMO,MAAMD,2BAAAA,qCAAAA,eAAgBE,WAAW;IAEvC,MAAMC,oBAAoBF,MAAMA,IAAIG,qBAAqB,GAAGT;IAC5D,MAAMU,sBAAsBJ,MAAMA,IAAIK,oBAAoB,GAAGT;IAE7D,OAAOL,gBAAgBW,mBAAmBE;AAC5C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useBrowserTimer.ts"],"sourcesContent":["import * as React from 'react';\n\ntype BrowserTimerSetter =\n | ((fn: () => void, duration?: number, ...args: Record<string, unknown>[]) => number)\n | ((fn: () => void) => number);\n\n/**\n * @internal\n * Helper to manage a browser timer.\n * Ensures that the timer isn't set multiple times at once,\n * and is cleaned up when the component is unloaded.\n *\n * @param setTimer - The timer setter function\n * @param cancelTimer - The timer cancel function\n * @returns A pair of [setTimer, cancelTimer] that are stable between renders.\n *\n * @example\n * const [setTimer, cancelTimer] = useBrowserTimer(setTimeout, cancelTimeout);\n *\n * setTimer(() => console.log('Hello world!'), 1000);\n * cancelTimer();\n */\nexport function useBrowserTimer(setTimer: BrowserTimerSetter, cancelTimer: (id: number) => void) {\n const id = React.useRef<number | undefined>(undefined);\n\n const set = React.useCallback(\n (fn: () => void, delay?: number) => {\n if (id.current !== undefined) {\n cancelTimer(id.current);\n }\n\n id.current = setTimer(fn, delay);\n return id.current;\n },\n [cancelTimer, setTimer],\n );\n\n const cancel = React.useCallback(() => {\n if (id.current !== undefined) {\n cancelTimer(id.current);\n id.current = undefined;\n }\n }, [cancelTimer]);\n\n // Clean up the timeout when the component is unloaded\n React.useEffect(() => cancel, [cancel]);\n\n return [set, cancel] as const;\n}\n"],"names":["React","useBrowserTimer","setTimer","cancelTimer","id","useRef","undefined","set","useCallback","fn","delay","current","cancel","useEffect"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAM/B;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASC,gBAAgBC,QAA4B,EAAEC,WAAiC;IAC7F,MAAMC,KAAKJ,MAAMK,MAAM,CAAqBC;IAE5C,MAAMC,MAAMP,MAAMQ,WAAW,CAC3B,CAACC,IAAgBC;QACf,IAAIN,GAAGO,OAAO,KAAKL,WAAW;YAC5BH,YAAYC,GAAGO,OAAO;QACxB;QAEAP,GAAGO,OAAO,GAAGT,SAASO,IAAIC;QAC1B,OAAON,GAAGO,OAAO;IACnB,GACA;QAACR;QAAaD;KAAS;IAGzB,MAAMU,SAASZ,MAAMQ,WAAW,CAAC;QAC/B,IAAIJ,GAAGO,OAAO,KAAKL,WAAW;YAC5BH,YAAYC,GAAGO,OAAO;YACtBP,GAAGO,OAAO,GAAGL;QACf;IACF,GAAG;QAACH;KAAY;IAEhB,sDAAsD;IACtDH,MAAMa,SAAS,CAAC,IAAMD,QAAQ;QAACA;KAAO;IAEtC,OAAO;QAACL;QAAKK;KAAO;AACtB"}
1
+ {"version":3,"sources":["../src/hooks/useBrowserTimer.ts"],"sourcesContent":["import * as React from 'react';\n\ntype BrowserTimerSetter =\n | ((fn: () => void, duration?: number, ...args: Record<string, unknown>[]) => number)\n | ((fn: () => void) => number);\n\n/**\n * @internal\n * Helper to manage a browser timer.\n * Ensures that the timer isn't set multiple times at once,\n * and is cleaned up when the component is unloaded.\n *\n * @param setTimer - The timer setter function\n * @param cancelTimer - The timer cancel function\n * @returns A pair of [setTimer, cancelTimer] that are stable between renders.\n *\n * @example\n * const [setTimer, cancelTimer] = useBrowserTimer(setTimeout, cancelTimeout);\n *\n * setTimer(() => console.log('Hello world!'), 1000);\n * cancelTimer();\n */\nexport function useBrowserTimer(setTimer: BrowserTimerSetter, cancelTimer: (id: number) => void) {\n const id = React.useRef<number | undefined>(undefined);\n\n const set = React.useCallback(\n (fn: () => void, delay?: number) => {\n if (id.current !== undefined) {\n cancelTimer(id.current);\n }\n\n id.current = setTimer(fn, delay);\n return id.current;\n },\n [cancelTimer, setTimer],\n );\n\n const cancel = React.useCallback(() => {\n if (id.current !== undefined) {\n cancelTimer(id.current);\n id.current = undefined;\n }\n }, [cancelTimer]);\n\n // Clean up the timeout when the component is unloaded\n React.useEffect(() => cancel, [cancel]);\n\n return [set, cancel] as const;\n}\n"],"names":["React","useBrowserTimer","setTimer","cancelTimer","id","useRef","undefined","set","useCallback","fn","delay","current","cancel","useEffect"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAM/B;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASC,gBAAgBC,QAA4B,EAAEC,WAAiC;IAC7F,MAAMC,KAAKJ,MAAMK,MAAM,CAAqBC;IAE5C,MAAMC,MAAMP,MAAMQ,WAAW,CAC3B,CAACC,IAAgBC;QACf,IAAIN,GAAGO,OAAO,KAAKL,WAAW;YAC5BH,YAAYC,GAAGO,OAAO;QACxB;QAEAP,GAAGO,OAAO,GAAGT,SAASO,IAAIC;QAC1B,OAAON,GAAGO,OAAO;IACnB,GACA;QAACR;QAAaD;KAAS;IAGzB,MAAMU,SAASZ,MAAMQ,WAAW,CAAC;QAC/B,IAAIJ,GAAGO,OAAO,KAAKL,WAAW;YAC5BH,YAAYC,GAAGO,OAAO;YACtBP,GAAGO,OAAO,GAAGL;QACf;IACF,GAAG;QAACH;KAAY;IAEhB,sDAAsD;IACtDH,MAAMa,SAAS,CAAC,IAAMD,QAAQ;QAACA;KAAO;IAEtC,OAAO;QAACL;QAAKK;KAAO;AACtB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useControllableState.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n */\nexport type UseControllableStateOptions<State> = {\n /**\n * User-provided default state or initializer, for uncontrolled usage.\n */\n defaultState?: State | (() => State);\n /**\n * User-provided controlled state. `undefined` means internal state will be used.\n */\n state: State | undefined;\n /**\n * Used as the initial state if `state` and `defaultState` are both `undefined`.\n * If `undefined` is the correct initial state, pass that here.\n */\n initialState: State;\n};\n\nfunction isFactoryDispatch<State>(newState: React.SetStateAction<State>): newState is (prevState: State) => State {\n return typeof newState === 'function';\n}\n\n/**\n * @internal\n *\n * A [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate)-like hook\n * to manage a value that could be either `controlled` or `uncontrolled`,\n * such as a checked state or text input string.\n *\n * @see https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components for more details on `controlled`/`uncontrolled`\n *\n * @returns an array of the current value and an updater (dispatcher) function.\n * The updater function is referentially stable (won't change during the component's lifecycle).\n * It can take either a new value, or a function which is passed the previous value and returns the new value.\n *\n * ❗️❗️ Calls to the dispatcher will only modify the state if the state is `uncontrolled`.\n * Meaning that if a state is `controlled`, calls to the dispatcher do not modify the state.\n *\n */\nexport const useControllableState = <State>(\n options: UseControllableStateOptions<State>,\n): [State, React.Dispatch<React.SetStateAction<State>>] => {\n 'use no memo';\n\n if (process.env.NODE_ENV !== 'production') {\n if (options.state !== undefined && options.defaultState !== undefined) {\n // eslint-disable-next-line no-console\n console.error(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [useControllableState]:\n A component must be either controlled or uncontrolled (specify either the state or the defaultState, but not both).\n Decide between using a controlled or uncontrolled component and remove one of this props.\n More info: https://reactjs.org/link/controlled-components\n ${new Error().stack}\n `);\n }\n }\n const [internalState, setInternalState] = React.useState<State>(() => {\n if (options.defaultState === undefined) {\n return options.initialState;\n }\n return isInitializer(options.defaultState) ? options.defaultState() : options.defaultState;\n });\n\n // Heads up!\n // This part is specific for controlled mode and mocks behavior of React dispatcher function.\n\n const stateValueRef = React.useRef<State | undefined>(options.state);\n\n React.useEffect(() => {\n stateValueRef.current = options.state;\n }, [options.state]);\n\n const setControlledState = React.useCallback((newState: React.SetStateAction<State>) => {\n if (isFactoryDispatch(newState)) {\n newState(stateValueRef.current as State);\n }\n }, []);\n\n return useIsControlled(options.state) ? [options.state, setControlledState] : [internalState, setInternalState];\n};\n\nfunction isInitializer<State>(value: State | (() => State)): value is () => State {\n return typeof value === 'function';\n}\n\n/**\n * Helper hook to handle previous comparison of controlled/uncontrolled\n * Prints an error when isControlled value switches between subsequent renders\n * @returns - whether the value is controlled\n */\nconst useIsControlled = <V>(controlledValue: V | undefined): controlledValue is V => {\n 'use no memo';\n\n const [isControlled] = React.useState<boolean>(() => controlledValue !== undefined);\n\n if (process.env.NODE_ENV !== 'production') {\n // We don't want these warnings in production even though it is against native behaviour\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (isControlled !== (controlledValue !== undefined)) {\n const error = new Error();\n\n const controlWarning = isControlled\n ? 'a controlled value to be uncontrolled'\n : 'an uncontrolled value to be controlled';\n\n const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';\n\n // eslint-disable-next-line no-console\n console.error(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [useControllableState]:\n A component is changing ${controlWarning}. This is likely caused by the value changing from ${undefinedWarning} value, which should not happen.\n Decide between using a controlled or uncontrolled input element for the lifetime of the component.\n More info: https://reactjs.org/link/controlled-components\n ${error.stack}\n `);\n }\n }, [isControlled, controlledValue]);\n }\n\n return isControlled;\n};\n"],"names":["React","isFactoryDispatch","newState","useControllableState","options","process","env","NODE_ENV","state","undefined","defaultState","console","error","Error","stack","internalState","setInternalState","useState","initialState","isInitializer","stateValueRef","useRef","useEffect","current","setControlledState","useCallback","useIsControlled","value","controlledValue","isControlled","controlWarning","undefinedWarning"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAqB/B,SAASC,kBAAyBC,QAAqC;IACrE,OAAO,OAAOA,aAAa;AAC7B;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,uBAAuB,CAClCC;IAEA;IAEA,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAIH,QAAQI,KAAK,KAAKC,aAAaL,QAAQM,YAAY,KAAKD,WAAW;YACrE,sCAAsC;YACtCE,QAAQC,KAAK,CAAuB,CAAC;;;;AAKrC,EAAE,IAAIC,QAAQC,KAAK,CAAC,AACtB,CAAC;QACD;IACF;IACA,MAAM,CAACC,eAAeC,iBAAiB,GAAGhB,MAAMiB,QAAQ,CAAQ;QAC9D,IAAIb,QAAQM,YAAY,KAAKD,WAAW;YACtC,OAAOL,QAAQc,YAAY;QAC7B;QACA,OAAOC,cAAcf,QAAQM,YAAY,IAAIN,QAAQM,YAAY,KAAKN,QAAQM,YAAY;IAC5F;IAEA,YAAY;IACZ,6FAA6F;IAE7F,MAAMU,gBAAgBpB,MAAMqB,MAAM,CAAoBjB,QAAQI,KAAK;IAEnER,MAAMsB,SAAS,CAAC;QACdF,cAAcG,OAAO,GAAGnB,QAAQI,KAAK;IACvC,GAAG;QAACJ,QAAQI,KAAK;KAAC;IAElB,MAAMgB,qBAAqBxB,MAAMyB,WAAW,CAAC,CAACvB;QAC5C,IAAID,kBAAkBC,WAAW;YAC/BA,SAASkB,cAAcG,OAAO;QAChC;IACF,GAAG,EAAE;IAEL,OAAOG,gBAAgBtB,QAAQI,KAAK,IAAI;QAACJ,QAAQI,KAAK;QAAEgB;KAAmB,GAAG;QAACT;QAAeC;KAAiB;AACjH,EAAE;AAEF,SAASG,cAAqBQ,KAA4B;IACxD,OAAO,OAAOA,UAAU;AAC1B;AAEA;;;;CAIC,GACD,MAAMD,kBAAkB,CAAIE;IAC1B;IAEA,MAAM,CAACC,aAAa,GAAG7B,MAAMiB,QAAQ,CAAU,IAAMW,oBAAoBnB;IAEzE,IAAIJ,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,wFAAwF;QACxF,sDAAsD;QACtDP,MAAMsB,SAAS,CAAC;YACd,IAAIO,iBAAkBD,CAAAA,oBAAoBnB,SAAQ,GAAI;gBACpD,MAAMG,QAAQ,IAAIC;gBAElB,MAAMiB,iBAAiBD,eACnB,0CACA;gBAEJ,MAAME,mBAAmBF,eAAe,4BAA4B;gBAEpE,sCAAsC;gBACtClB,QAAQC,KAAK,CAAuB,CAAC;wBAEX,EAAEkB,eAAe,mDAAmD,EAAEC,iBAAiB;;;AAG/G,EAAEnB,MAAME,KAAK,CAAC,AAChB,CAAC;YACH;QACF,GAAG;YAACe;YAAcD;SAAgB;IACpC;IAEA,OAAOC;AACT"}
1
+ {"version":3,"sources":["../src/hooks/useControllableState.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n */\nexport type UseControllableStateOptions<State> = {\n /**\n * User-provided default state or initializer, for uncontrolled usage.\n */\n defaultState?: State | (() => State);\n /**\n * User-provided controlled state. `undefined` means internal state will be used.\n */\n state: State | undefined;\n /**\n * Used as the initial state if `state` and `defaultState` are both `undefined`.\n * If `undefined` is the correct initial state, pass that here.\n */\n initialState: State;\n};\n\nfunction isFactoryDispatch<State>(newState: React.SetStateAction<State>): newState is (prevState: State) => State {\n return typeof newState === 'function';\n}\n\n/**\n * @internal\n *\n * A [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate)-like hook\n * to manage a value that could be either `controlled` or `uncontrolled`,\n * such as a checked state or text input string.\n *\n * @see https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components for more details on `controlled`/`uncontrolled`\n *\n * @returns an array of the current value and an updater (dispatcher) function.\n * The updater function is referentially stable (won't change during the component's lifecycle).\n * It can take either a new value, or a function which is passed the previous value and returns the new value.\n *\n * ❗️❗️ Calls to the dispatcher will only modify the state if the state is `uncontrolled`.\n * Meaning that if a state is `controlled`, calls to the dispatcher do not modify the state.\n *\n */\nexport const useControllableState = <State>(\n options: UseControllableStateOptions<State>,\n): [State, React.Dispatch<React.SetStateAction<State>>] => {\n 'use no memo';\n\n if (process.env.NODE_ENV !== 'production') {\n if (options.state !== undefined && options.defaultState !== undefined) {\n // eslint-disable-next-line no-console\n console.error(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [useControllableState]:\n A component must be either controlled or uncontrolled (specify either the state or the defaultState, but not both).\n Decide between using a controlled or uncontrolled component and remove one of this props.\n More info: https://reactjs.org/link/controlled-components\n ${new Error().stack}\n `);\n }\n }\n const [internalState, setInternalState] = React.useState<State>(() => {\n if (options.defaultState === undefined) {\n return options.initialState;\n }\n return isInitializer(options.defaultState) ? options.defaultState() : options.defaultState;\n });\n\n // Heads up!\n // This part is specific for controlled mode and mocks behavior of React dispatcher function.\n\n const stateValueRef = React.useRef<State | undefined>(options.state);\n\n React.useEffect(() => {\n stateValueRef.current = options.state;\n }, [options.state]);\n\n const setControlledState = React.useCallback((newState: React.SetStateAction<State>) => {\n if (isFactoryDispatch(newState)) {\n newState(stateValueRef.current as State);\n }\n }, []);\n\n return useIsControlled(options.state) ? [options.state, setControlledState] : [internalState, setInternalState];\n};\n\nfunction isInitializer<State>(value: State | (() => State)): value is () => State {\n return typeof value === 'function';\n}\n\n/**\n * Helper hook to handle previous comparison of controlled/uncontrolled\n * Prints an error when isControlled value switches between subsequent renders\n * @returns - whether the value is controlled\n */\nconst useIsControlled = <V>(controlledValue: V | undefined): controlledValue is V => {\n 'use no memo';\n\n const [isControlled] = React.useState<boolean>(() => controlledValue !== undefined);\n\n if (process.env.NODE_ENV !== 'production') {\n // We don't want these warnings in production even though it is against native behaviour\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (isControlled !== (controlledValue !== undefined)) {\n const error = new Error();\n\n const controlWarning = isControlled\n ? 'a controlled value to be uncontrolled'\n : 'an uncontrolled value to be controlled';\n\n const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';\n\n // eslint-disable-next-line no-console\n console.error(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [useControllableState]:\n A component is changing ${controlWarning}. This is likely caused by the value changing from ${undefinedWarning} value, which should not happen.\n Decide between using a controlled or uncontrolled input element for the lifetime of the component.\n More info: https://reactjs.org/link/controlled-components\n ${error.stack}\n `);\n }\n }, [isControlled, controlledValue]);\n }\n\n return isControlled;\n};\n"],"names":["React","isFactoryDispatch","newState","useControllableState","options","process","env","NODE_ENV","state","undefined","defaultState","console","error","Error","stack","internalState","setInternalState","useState","initialState","isInitializer","stateValueRef","useRef","useEffect","current","setControlledState","useCallback","useIsControlled","value","controlledValue","isControlled","controlWarning","undefinedWarning"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAqB/B,SAASC,kBAAyBC,QAAqC;IACrE,OAAO,OAAOA,aAAa;AAC7B;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,uBAAuB,CAClCC;IAEA;IAEA,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAIH,QAAQI,KAAK,KAAKC,aAAaL,QAAQM,YAAY,KAAKD,WAAW;YACrE,sCAAsC;YACtCE,QAAQC,KAAK,CAAuB,CAAC;;;;AAKrC,EAAE,IAAIC,QAAQC,KAAK,EACpB;QACD;IACF;IACA,MAAM,CAACC,eAAeC,iBAAiB,GAAGhB,MAAMiB,QAAQ,CAAQ;QAC9D,IAAIb,QAAQM,YAAY,KAAKD,WAAW;YACtC,OAAOL,QAAQc,YAAY;QAC7B;QACA,OAAOC,cAAcf,QAAQM,YAAY,IAAIN,QAAQM,YAAY,KAAKN,QAAQM,YAAY;IAC5F;IAEA,YAAY;IACZ,6FAA6F;IAE7F,MAAMU,gBAAgBpB,MAAMqB,MAAM,CAAoBjB,QAAQI,KAAK;IAEnER,MAAMsB,SAAS,CAAC;QACdF,cAAcG,OAAO,GAAGnB,QAAQI,KAAK;IACvC,GAAG;QAACJ,QAAQI,KAAK;KAAC;IAElB,MAAMgB,qBAAqBxB,MAAMyB,WAAW,CAAC,CAACvB;QAC5C,IAAID,kBAAkBC,WAAW;YAC/BA,SAASkB,cAAcG,OAAO;QAChC;IACF,GAAG,EAAE;IAEL,OAAOG,gBAAgBtB,QAAQI,KAAK,IAAI;QAACJ,QAAQI,KAAK;QAAEgB;KAAmB,GAAG;QAACT;QAAeC;KAAiB;AACjH,EAAE;AAEF,SAASG,cAAqBQ,KAA4B;IACxD,OAAO,OAAOA,UAAU;AAC1B;AAEA;;;;CAIC,GACD,MAAMD,kBAAkB,CAAIE;IAC1B;IAEA,MAAM,CAACC,aAAa,GAAG7B,MAAMiB,QAAQ,CAAU,IAAMW,oBAAoBnB;IAEzE,IAAIJ,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,wFAAwF;QACxF,sDAAsD;QACtDP,MAAMsB,SAAS,CAAC;YACd,IAAIO,iBAAkBD,CAAAA,oBAAoBnB,SAAQ,GAAI;gBACpD,MAAMG,QAAQ,IAAIC;gBAElB,MAAMiB,iBAAiBD,eACnB,0CACA;gBAEJ,MAAME,mBAAmBF,eAAe,4BAA4B;gBAEpE,sCAAsC;gBACtClB,QAAQC,KAAK,CAAuB,CAAC;wBAEX,EAAEkB,eAAe,mDAAmD,EAAEC,iBAAiB;;;AAG/G,EAAEnB,MAAME,KAAK,EACd;YACH;QACF,GAAG;YAACe;YAAcD;SAAgB;IACpC;IAEA,OAAOC;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useEventCallback.ts"],"sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\n\n/**\n * @internal\n * https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback\n *\n * Modified `useCallback` that can be used when dependencies change too frequently. Can occur when\n * e.g. user props are dependencies which could change on every render\n * e.g. volatile values (i.e. useState/useDispatch) are dependencies which could change frequently\n *\n * This should not be used often, but can be a useful re-render optimization since the callback is a ref and\n * will not be invalidated between re-renders\n *\n * @param fn - The callback function that will be used\n */\nexport const useEventCallback = <Args extends unknown[], Return>(fn: (...args: Args) => Return) => {\n const callbackRef = React.useRef<typeof fn>(() => {\n throw new Error('Cannot call an event handler while rendering');\n });\n\n useIsomorphicLayoutEffect(() => {\n callbackRef.current = fn;\n }, [fn]);\n\n return React.useCallback(\n (...args: Args) => {\n const callback = callbackRef.current;\n return callback(...args);\n },\n [callbackRef],\n );\n};\n"],"names":["React","useIsomorphicLayoutEffect","useEventCallback","fn","callbackRef","useRef","Error","current","useCallback","args","callback"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,yBAAyB,QAAQ,8BAA8B;AAExE;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,mBAAmB,CAAiCC;IAC/D,MAAMC,cAAcJ,MAAMK,MAAM,CAAY;QAC1C,MAAM,IAAIC,MAAM;IAClB;IAEAL,0BAA0B;QACxBG,YAAYG,OAAO,GAAGJ;IACxB,GAAG;QAACA;KAAG;IAEP,OAAOH,MAAMQ,WAAW,CACtB,CAAC,GAAGC;QACF,MAAMC,WAAWN,YAAYG,OAAO;QACpC,OAAOG,YAAYD;IACrB,GACA;QAACL;KAAY;AAEjB,EAAE"}
1
+ {"version":3,"sources":["../src/hooks/useEventCallback.ts"],"sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\n\n/**\n * @internal\n * https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback\n *\n * Modified `useCallback` that can be used when dependencies change too frequently. Can occur when\n * e.g. user props are dependencies which could change on every render\n * e.g. volatile values (i.e. useState/useDispatch) are dependencies which could change frequently\n *\n * This should not be used often, but can be a useful re-render optimization since the callback is a ref and\n * will not be invalidated between re-renders\n *\n * @param fn - The callback function that will be used\n */\nexport const useEventCallback = <Args extends unknown[], Return>(fn: (...args: Args) => Return) => {\n const callbackRef = React.useRef<typeof fn>(() => {\n throw new Error('Cannot call an event handler while rendering');\n });\n\n useIsomorphicLayoutEffect(() => {\n callbackRef.current = fn;\n }, [fn]);\n\n return React.useCallback(\n (...args: Args) => {\n const callback = callbackRef.current;\n return callback(...args);\n },\n [callbackRef],\n );\n};\n"],"names":["React","useIsomorphicLayoutEffect","useEventCallback","fn","callbackRef","useRef","Error","current","useCallback","args","callback"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,yBAAyB,QAAQ,8BAA8B;AAExE;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,mBAAmB,CAAiCC;IAC/D,MAAMC,cAAcJ,MAAMK,MAAM,CAAY;QAC1C,MAAM,IAAIC,MAAM;IAClB;IAEAL,0BAA0B;QACxBG,YAAYG,OAAO,GAAGJ;IACxB,GAAG;QAACA;KAAG;IAEP,OAAOH,MAAMQ,WAAW,CACtB,CAAC,GAAGC;QACF,MAAMC,WAAWN,YAAYG,OAAO;QACpC,OAAOG,YAAYD;IACrB,GACA;QAACL;KAAY;AAEjB,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useFirstMount.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n * Checks if components was mounted the first time.\n * Since concurrent mode will be released in the future this needs to be verified\n * Currently (React 17) will always render the initial mount once\n * https://codesandbox.io/s/heuristic-brook-s4w0q?file=/src/App.jsx\n * https://codesandbox.io/s/holy-grass-8nieu?file=/src/App.jsx\n *\n * @example\n * const isFirstMount = useFirstMount();\n */\nexport function useFirstMount(): boolean {\n const isFirst = React.useRef(true);\n\n if (isFirst.current) {\n isFirst.current = false;\n return true;\n }\n\n return isFirst.current;\n}\n"],"names":["React","useFirstMount","isFirst","useRef","current"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B;;;;;;;;;;CAUC,GACD,OAAO,SAASC;IACd,MAAMC,UAAUF,MAAMG,MAAM,CAAC;IAE7B,IAAID,QAAQE,OAAO,EAAE;QACnBF,QAAQE,OAAO,GAAG;QAClB,OAAO;IACT;IAEA,OAAOF,QAAQE,OAAO;AACxB"}
1
+ {"version":3,"sources":["../src/hooks/useFirstMount.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n * Checks if components was mounted the first time.\n * Since concurrent mode will be released in the future this needs to be verified\n * Currently (React 17) will always render the initial mount once\n * https://codesandbox.io/s/heuristic-brook-s4w0q?file=/src/App.jsx\n * https://codesandbox.io/s/holy-grass-8nieu?file=/src/App.jsx\n *\n * @example\n * const isFirstMount = useFirstMount();\n */\nexport function useFirstMount(): boolean {\n const isFirst = React.useRef(true);\n\n if (isFirst.current) {\n isFirst.current = false;\n return true;\n }\n\n return isFirst.current;\n}\n"],"names":["React","useFirstMount","isFirst","useRef","current"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B;;;;;;;;;;CAUC,GACD,OAAO,SAASC;IACd,MAAMC,UAAUF,MAAMG,MAAM,CAAC;IAE7B,IAAID,QAAQE,OAAO,EAAE;QACnBF,QAAQE,OAAO,GAAG;QAClB,OAAO;IACT;IAEA,OAAOF,QAAQE,OAAO;AACxB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useForceUpdate.ts"],"sourcesContent":["import * as React from 'react';\n/**\n * @internal\n * Forces a re-render, similar to `forceUpdate` in class components.\n */\nexport function useForceUpdate() {\n return React.useReducer(x => x + 1, 0)[1];\n}\n"],"names":["React","useForceUpdate","useReducer","x"],"rangeMappings":";;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B;;;CAGC,GACD,OAAO,SAASC;IACd,OAAOD,MAAME,UAAU,CAACC,CAAAA,IAAKA,IAAI,GAAG,EAAE,CAAC,EAAE;AAC3C"}
1
+ {"version":3,"sources":["../src/hooks/useForceUpdate.ts"],"sourcesContent":["import * as React from 'react';\n/**\n * @internal\n * Forces a re-render, similar to `forceUpdate` in class components.\n */\nexport function useForceUpdate() {\n return React.useReducer(x => x + 1, 0)[1];\n}\n"],"names":["React","useForceUpdate","useReducer","x"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B;;;CAGC,GACD,OAAO,SAASC;IACd,OAAOD,MAAME,UAAU,CAACC,CAAAA,IAAKA,IAAI,GAAG,EAAE,CAAC,EAAE;AAC3C"}