@fluentui/react-utilities 9.7.0 → 9.7.2

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 (216) hide show
  1. package/.swcrc +30 -0
  2. package/CHANGELOG.json +49 -1
  3. package/CHANGELOG.md +23 -2
  4. package/dist/index.d.ts +16 -4
  5. package/lib/compose/getSlots.js +3 -3
  6. package/lib/compose/getSlots.js.map +1 -1
  7. package/lib/compose/index.js.map +1 -1
  8. package/lib/compose/isResolvedShorthand.js.map +1 -1
  9. package/lib/compose/resolveShorthand.js.map +1 -1
  10. package/lib/compose/types.js +1 -1
  11. package/lib/compose/types.js.map +1 -1
  12. package/lib/events/index.js.map +1 -1
  13. package/lib/events/mouseTouchHelpers.js +1 -0
  14. package/lib/events/mouseTouchHelpers.js.map +1 -1
  15. package/lib/hooks/index.js.map +1 -1
  16. package/lib/hooks/useControllableState.js.map +1 -1
  17. package/lib/hooks/useEventCallback.js.map +1 -1
  18. package/lib/hooks/useFirstMount.js.map +1 -1
  19. package/lib/hooks/useForceUpdate.js.map +1 -1
  20. package/lib/hooks/useId.js.map +1 -1
  21. package/lib/hooks/useIsomorphicLayoutEffect.js +1 -2
  22. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  23. package/lib/hooks/useMergedRefs.js.map +1 -1
  24. package/lib/hooks/useOnClickOutside.js +16 -9
  25. package/lib/hooks/useOnClickOutside.js.map +1 -1
  26. package/lib/hooks/useOnScrollOutside.js +3 -1
  27. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  28. package/lib/hooks/usePrevious.js.map +1 -1
  29. package/lib/hooks/useScrollbarWidth.js.map +1 -1
  30. package/lib/hooks/useTimeout.js.map +1 -1
  31. package/lib/index.js.map +1 -1
  32. package/lib/ssr/SSRContext.js +2 -2
  33. package/lib/ssr/SSRContext.js.map +1 -1
  34. package/lib/ssr/canUseDOM.js +1 -2
  35. package/lib/ssr/canUseDOM.js.map +1 -1
  36. package/lib/ssr/index.js.map +1 -1
  37. package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
  38. package/lib/trigger/getTriggerChild.js.map +1 -1
  39. package/lib/trigger/index.js.map +1 -1
  40. package/lib/trigger/isFluentTrigger.js +1 -0
  41. package/lib/trigger/isFluentTrigger.js.map +1 -1
  42. package/lib/trigger/types.js +1 -1
  43. package/lib/trigger/types.js.map +1 -1
  44. package/lib/utils/clamp.js +1 -2
  45. package/lib/utils/clamp.js.map +1 -1
  46. package/lib/utils/getNativeElementProps.js +2 -2
  47. package/lib/utils/getNativeElementProps.js.map +1 -1
  48. package/lib/utils/getRTLSafeKey.js +1 -2
  49. package/lib/utils/getRTLSafeKey.js.map +1 -1
  50. package/lib/utils/getReactCallbackName.js +1 -0
  51. package/lib/utils/getReactCallbackName.js.map +1 -1
  52. package/lib/utils/index.js.map +1 -1
  53. package/lib/utils/isHTMLElement.js +12 -7
  54. package/lib/utils/isHTMLElement.js.map +1 -1
  55. package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
  56. package/lib/utils/mergeCallbacks.js +1 -2
  57. package/lib/utils/mergeCallbacks.js.map +1 -1
  58. package/lib/utils/omit.js +1 -2
  59. package/lib/utils/omit.js.map +1 -1
  60. package/lib/utils/properties.js +24 -51
  61. package/lib/utils/properties.js.map +1 -1
  62. package/lib-commonjs/compose/getSlots.js +48 -55
  63. package/lib-commonjs/compose/getSlots.js.map +1 -1
  64. package/lib-commonjs/compose/index.js +8 -7
  65. package/lib-commonjs/compose/index.js.map +1 -1
  66. package/lib-commonjs/compose/isResolvedShorthand.js +9 -37
  67. package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
  68. package/lib-commonjs/compose/resolveShorthand.js +25 -32
  69. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  70. package/lib-commonjs/compose/types.js +5 -2
  71. package/lib-commonjs/compose/types.js.map +1 -1
  72. package/lib-commonjs/events/index.js +5 -4
  73. package/lib-commonjs/events/index.js.map +1 -1
  74. package/lib-commonjs/events/mouseTouchHelpers.js +40 -37
  75. package/lib-commonjs/events/mouseTouchHelpers.js.map +1 -1
  76. package/lib-commonjs/hooks/index.js +16 -15
  77. package/lib-commonjs/hooks/index.js.map +1 -1
  78. package/lib-commonjs/hooks/useControllableState.js +63 -64
  79. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  80. package/lib-commonjs/hooks/useEventCallback.js +25 -31
  81. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  82. package/lib-commonjs/hooks/useFirstMount.js +15 -23
  83. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  84. package/lib-commonjs/hooks/useForceUpdate.js +9 -11
  85. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  86. package/lib-commonjs/hooks/useId.js +47 -46
  87. package/lib-commonjs/hooks/useId.js.map +1 -1
  88. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +10 -16
  89. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  90. package/lib-commonjs/hooks/useMergedRefs.js +25 -27
  91. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  92. package/lib-commonjs/hooks/useOnClickOutside.js +118 -114
  93. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  94. package/lib-commonjs/hooks/useOnScrollOutside.js +35 -36
  95. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  96. package/lib-commonjs/hooks/usePrevious.js +17 -15
  97. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  98. package/lib-commonjs/hooks/useScrollbarWidth.js +32 -32
  99. package/lib-commonjs/hooks/useScrollbarWidth.js.map +1 -1
  100. package/lib-commonjs/hooks/useTimeout.js +30 -30
  101. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  102. package/lib-commonjs/index.js +52 -214
  103. package/lib-commonjs/index.js.map +1 -1
  104. package/lib-commonjs/ssr/SSRContext.js +57 -59
  105. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  106. package/lib-commonjs/ssr/canUseDOM.js +12 -12
  107. package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
  108. package/lib-commonjs/ssr/index.js +6 -5
  109. package/lib-commonjs/ssr/index.js.map +1 -1
  110. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js +29 -31
  111. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
  112. package/lib-commonjs/trigger/getTriggerChild.js +16 -36
  113. package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
  114. package/lib-commonjs/trigger/index.js +8 -7
  115. package/lib-commonjs/trigger/index.js.map +1 -1
  116. package/lib-commonjs/trigger/isFluentTrigger.js +10 -11
  117. package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
  118. package/lib-commonjs/trigger/types.js +5 -2
  119. package/lib-commonjs/trigger/types.js.map +1 -1
  120. package/lib-commonjs/utils/clamp.js +10 -9
  121. package/lib-commonjs/utils/clamp.js.map +1 -1
  122. package/lib-commonjs/utils/getNativeElementProps.js +54 -61
  123. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  124. package/lib-commonjs/utils/getRTLSafeKey.js +22 -21
  125. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  126. package/lib-commonjs/utils/getReactCallbackName.js +24 -24
  127. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
  128. package/lib-commonjs/utils/index.js +12 -11
  129. package/lib-commonjs/utils/index.js.map +1 -1
  130. package/lib-commonjs/utils/isHTMLElement.js +22 -15
  131. package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
  132. package/lib-commonjs/utils/isInteractiveHTMLElement.js +20 -24
  133. package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
  134. package/lib-commonjs/utils/mergeCallbacks.js +14 -13
  135. package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
  136. package/lib-commonjs/utils/omit.js +18 -17
  137. package/lib-commonjs/utils/omit.js.map +1 -1
  138. package/lib-commonjs/utils/properties.js +327 -223
  139. package/lib-commonjs/utils/properties.js.map +1 -1
  140. package/package.json +5 -4
  141. package/lib-amd/compose/getSlots.js +0 -58
  142. package/lib-amd/compose/getSlots.js.map +0 -1
  143. package/lib-amd/compose/index.js +0 -9
  144. package/lib-amd/compose/index.js.map +0 -1
  145. package/lib-amd/compose/isResolvedShorthand.js +0 -40
  146. package/lib-amd/compose/isResolvedShorthand.js.map +0 -1
  147. package/lib-amd/compose/resolveShorthand.js +0 -27
  148. package/lib-amd/compose/resolveShorthand.js.map +0 -1
  149. package/lib-amd/compose/types.js +0 -5
  150. package/lib-amd/compose/types.js.map +0 -1
  151. package/lib-amd/events/index.js +0 -6
  152. package/lib-amd/events/index.js.map +0 -1
  153. package/lib-amd/events/mouseTouchHelpers.js +0 -39
  154. package/lib-amd/events/mouseTouchHelpers.js.map +0 -1
  155. package/lib-amd/hooks/index.js +0 -17
  156. package/lib-amd/hooks/index.js.map +0 -1
  157. package/lib-amd/hooks/useControllableState.js +0 -81
  158. package/lib-amd/hooks/useControllableState.js.map +0 -1
  159. package/lib-amd/hooks/useEventCallback.js +0 -36
  160. package/lib-amd/hooks/useEventCallback.js.map +0 -1
  161. package/lib-amd/hooks/useFirstMount.js +0 -26
  162. package/lib-amd/hooks/useFirstMount.js.map +0 -1
  163. package/lib-amd/hooks/useForceUpdate.js +0 -14
  164. package/lib-amd/hooks/useForceUpdate.js.map +0 -1
  165. package/lib-amd/hooks/useId.js +0 -54
  166. package/lib-amd/hooks/useId.js.map +0 -1
  167. package/lib-amd/hooks/useIsomorphicLayoutEffect.js +0 -17
  168. package/lib-amd/hooks/useIsomorphicLayoutEffect.js.map +0 -1
  169. package/lib-amd/hooks/useMergedRefs.js +0 -34
  170. package/lib-amd/hooks/useMergedRefs.js.map +0 -1
  171. package/lib-amd/hooks/useOnClickOutside.js +0 -114
  172. package/lib-amd/hooks/useOnClickOutside.js.map +0 -1
  173. package/lib-amd/hooks/useOnScrollOutside.js +0 -31
  174. package/lib-amd/hooks/useOnScrollOutside.js.map +0 -1
  175. package/lib-amd/hooks/usePrevious.js +0 -17
  176. package/lib-amd/hooks/usePrevious.js.map +0 -1
  177. package/lib-amd/hooks/useScrollbarWidth.js +0 -32
  178. package/lib-amd/hooks/useScrollbarWidth.js.map +0 -1
  179. package/lib-amd/hooks/useTimeout.js +0 -33
  180. package/lib-amd/hooks/useTimeout.js.map +0 -1
  181. package/lib-amd/index.js +0 -40
  182. package/lib-amd/index.js.map +0 -1
  183. package/lib-amd/ssr/SSRContext.js +0 -69
  184. package/lib-amd/ssr/SSRContext.js.map +0 -1
  185. package/lib-amd/ssr/canUseDOM.js +0 -16
  186. package/lib-amd/ssr/canUseDOM.js.map +0 -1
  187. package/lib-amd/ssr/index.js +0 -7
  188. package/lib-amd/ssr/index.js.map +0 -1
  189. package/lib-amd/trigger/applyTriggerPropsToChildren.js +0 -40
  190. package/lib-amd/trigger/applyTriggerPropsToChildren.js.map +0 -1
  191. package/lib-amd/trigger/getTriggerChild.js +0 -40
  192. package/lib-amd/trigger/getTriggerChild.js.map +0 -1
  193. package/lib-amd/trigger/index.js +0 -9
  194. package/lib-amd/trigger/index.js.map +0 -1
  195. package/lib-amd/trigger/isFluentTrigger.js +0 -15
  196. package/lib-amd/trigger/isFluentTrigger.js.map +0 -1
  197. package/lib-amd/trigger/types.js +0 -5
  198. package/lib-amd/trigger/types.js.map +0 -1
  199. package/lib-amd/utils/clamp.js +0 -16
  200. package/lib-amd/utils/clamp.js.map +0 -1
  201. package/lib-amd/utils/getNativeElementProps.js +0 -64
  202. package/lib-amd/utils/getNativeElementProps.js.map +0 -1
  203. package/lib-amd/utils/getRTLSafeKey.js +0 -24
  204. package/lib-amd/utils/getRTLSafeKey.js.map +0 -1
  205. package/lib-amd/utils/index.js +0 -13
  206. package/lib-amd/utils/index.js.map +0 -1
  207. package/lib-amd/utils/isHTMLElement.js +0 -22
  208. package/lib-amd/utils/isHTMLElement.js.map +0 -1
  209. package/lib-amd/utils/isInteractiveHTMLElement.js +0 -25
  210. package/lib-amd/utils/isInteractiveHTMLElement.js.map +0 -1
  211. package/lib-amd/utils/mergeCallbacks.js +0 -40
  212. package/lib-amd/utils/mergeCallbacks.js.map +0 -1
  213. package/lib-amd/utils/omit.js +0 -31
  214. package/lib-amd/utils/omit.js.map +0 -1
  215. package/lib-amd/utils/properties.js +0 -450
  216. package/lib-amd/utils/properties.js.map +0 -1
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
5
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
6
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
7
+ //# sourceMappingURL=types.js.map
8
+
6
9
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../src/packages/react-components/react-utilities/src/compose/types.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type SlotRenderFunction<Props> = (\n Component: React.ElementType<Props>,\n props: Omit<Props, 'children' | 'as'>,\n) => React.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.ReactChild | React.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>, 'children' | 'className' | 'style'> & {\n as?: keyof JSX.IntrinsicElements;\n};\n\n/**\n * Helper type for {@link Slot}. Adds shorthand types that are assignable to the slot's `children`.\n */\ntype WithSlotShorthandValue<Props extends { children?: unknown }> =\n | Props\n | Extract<SlotShorthandValue, Props['children']>;\n\n/**\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 */\ntype WithSlotRenderFunction<Props> = Props & {\n children?: (Props extends { children?: unknown } ? Props['children'] : never) | SlotRenderFunction<Props>;\n};\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 Type extends keyof JSX.IntrinsicElements | React.ComponentType | React.VoidFunctionComponent | 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 React.ComponentType<infer Props> // Component types like `typeof Button`\n ? WithSlotRenderFunction<Props>\n : Type // Props types like `ButtonProps`\n >\n | {\n [As in AlternateAs]: { as: As } & WithSlotRenderFunction<IntrinsicElementProps<As>>;\n }[AlternateAs]\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 * Converts a union type (`A | B | C`) to an intersection type (`A & B & C`)\n */\nexport type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;\n\n/**\n * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by\n * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.\n *\n * The conditional \"extends unknown\" (always true) exploits a quirk in the way TypeScript handles conditional\n * types, to prevent unions from being expanded.\n */\nexport type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;\n\n/**\n * Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by\n * IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.\n *\n * The conditional \"extends unknown\" (always true) exploits a quirk in the way TypeScript handles conditional\n * types, to prevent unions from being expanded.\n */\nexport type PropsWithoutChildren<P> = 'children' extends keyof P ? (P extends unknown ? Omit<P, 'children'> : P) : P;\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 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// Note: the `Omit<Slots, Primary & 'root'>` above 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\n/**\n * If type T includes `null`, remove it and add `undefined` instead.\n */\nexport type ReplaceNullWithUndefined<T> = T extends null ? Exclude<T, null> | undefined : T;\n\n/**\n * Defines the State object of a component given its slots.\n */\nexport type ComponentState<Slots extends SlotPropsRecord> = {\n components: {\n [Key in keyof Slots]-?:\n | React.ComponentType<ExtractSlotProps<Slots[Key]>>\n | (ExtractSlotProps<Slots[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);\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 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 * Return type for `React.forwardRef`, including inference of the proper typing for the ref.\n */\nexport type ForwardRefComponent<Props> = ObscureEventName extends keyof Props\n ? Required<Props>[ObscureEventName] extends React.PointerEventHandler<infer Element>\n ? React.ForwardRefExoticComponent<Props & React.RefAttributes<Element>>\n : never\n : never;\n// A definition like this would also work, but typescript is more likely to unnecessarily expand\n// the props type with this version (and it's likely much more expensive to evaluate)\n// export type ForwardRefComponent<Props> = Props extends React.DOMAttributes<infer Element>\n// ? React.ForwardRefExoticComponent<Props> & React.RefAttributes<Element>\n// : never;\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"],"mappings":""}
1
+ {"version":3,"sources":["../../lib/compose/types.js"],"sourcesContent":["import * as React from 'react';\n//# sourceMappingURL=types.js.map"],"names":[],"mappings":";;;;;6DAAuB;CACvB,iCAAiC"}
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- const tslib_1 = /*#__PURE__*/require("tslib");
7
- tslib_1.__exportStar(require("./mouseTouchHelpers"), exports);
5
+ const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
6
+ _exportStar(require("./mouseTouchHelpers"), exports);
7
+ //# sourceMappingURL=index.js.map
8
+
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["tslib_1","__exportStar","require","exports"],"sources":["../src/packages/react-components/react-utilities/src/events/index.ts"],"sourcesContent":["export * from './mouseTouchHelpers';\n"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,yBAAAC,OAAA"}
1
+ {"version":3,"sources":["../../lib/events/index.js"],"sourcesContent":["export * from './mouseTouchHelpers';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;CACd,iCAAiC"}
@@ -1,47 +1,50 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ isTouchEvent: ()=>isTouchEvent,
13
+ isMouseEvent: ()=>isMouseEvent,
14
+ getEventClientCoords: ()=>getEventClientCoords
5
15
  });
6
- exports.getEventClientCoords = exports.isMouseEvent = exports.isTouchEvent = void 0;
7
- /**
8
- * Returns true if event is a touch event. Useful when sharing logic between touch and mouse interactions.
9
- */
16
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
17
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
10
18
  function isTouchEvent(event) {
11
- return event.type.startsWith('touch');
19
+ return event.type.startsWith('touch');
12
20
  }
13
- exports.isTouchEvent = isTouchEvent;
14
- /**
15
- * Returns true if event is a mouse event. Useful when sharing logic between touch and mouse interactions.
16
- */
17
21
  function isMouseEvent(event) {
18
- return event.type.startsWith('mouse') || ['click', 'contextmenu', 'dblclick'].indexOf(event.type) > -1;
22
+ return event.type.startsWith('mouse') || [
23
+ 'click',
24
+ 'contextmenu',
25
+ 'dblclick'
26
+ ].indexOf(event.type) > -1;
19
27
  }
20
- exports.isMouseEvent = isMouseEvent;
21
- /**
22
- * Returns an object with clientX, clientY for TouchOrMouseEvent.
23
- * Returns zeros in case the event is not a mouse or a touch event.
24
- */
25
28
  function getEventClientCoords(event) {
26
- if (isMouseEvent(event)) {
27
- return {
28
- clientX: event.clientX,
29
- clientY: event.clientY
30
- };
31
- } else if (isTouchEvent(event)) {
32
- return {
33
- clientX: event.touches[0].clientX,
34
- clientY: event.touches[0].clientY
35
- };
36
- } else {
37
- if (process.env.NODE_ENV !== 'production') {
38
- throw new Error('@fluentui/react-utilities]: Unable to get clientX. Unknown event type.');
29
+ if (isMouseEvent(event)) {
30
+ return {
31
+ clientX: event.clientX,
32
+ clientY: event.clientY
33
+ };
34
+ } else if (isTouchEvent(event)) {
35
+ return {
36
+ clientX: event.touches[0].clientX,
37
+ clientY: event.touches[0].clientY
38
+ };
39
+ } else {
40
+ if (process.env.NODE_ENV !== 'production') {
41
+ throw new Error('@fluentui/react-utilities]: Unable to get clientX. Unknown event type.');
42
+ }
43
+ return {
44
+ clientX: 0,
45
+ clientY: 0
46
+ };
39
47
  }
40
- return {
41
- clientX: 0,
42
- clientY: 0
43
- };
44
- }
45
- }
46
- exports.getEventClientCoords = getEventClientCoords;
48
+ } //# sourceMappingURL=mouseTouchHelpers.js.map
49
+
47
50
  //# sourceMappingURL=mouseTouchHelpers.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isTouchEvent","event","type","startsWith","exports","isMouseEvent","indexOf","getEventClientCoords","clientX","clientY","touches","process","env","NODE_ENV","Error"],"sources":["../src/packages/react-components/react-utilities/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"],"mappings":";;;;;;AAQA;;;AAGA,SAAgBA,YAAYA,CAACC,KAAwB;EACnD,OAAOA,KAAK,CAACC,IAAI,CAACC,UAAU,CAAC,OAAO,CAAC;AACvC;AAFAC,OAAA,CAAAJ,YAAA,GAAAA,YAAA;AAIA;;;AAGA,SAAgBK,YAAYA,CAACJ,KAAwB;EACnD,OAAOA,KAAK,CAACC,IAAI,CAACC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,UAAU,CAAC,CAACG,OAAO,CAACL,KAAK,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxG;AAFAE,OAAA,CAAAC,YAAA,GAAAA,YAAA;AAIA;;;;AAIA,SAAgBE,oBAAoBA,CAACN,KAAwB;EAC3D,IAAII,YAAY,CAACJ,KAAK,CAAC,EAAE;IACvB,OAAO;MAAEO,OAAO,EAAEP,KAAK,CAACO,OAAO;MAAEC,OAAO,EAAER,KAAK,CAACQ;IAAO,CAAE;GAC1D,MAAM,IAAIT,YAAY,CAACC,KAAK,CAAC,EAAE;IAC9B,OAAO;MAAEO,OAAO,EAAEP,KAAK,CAACS,OAAO,CAAC,CAAC,CAAC,CAACF,OAAO;MAAEC,OAAO,EAAER,KAAK,CAACS,OAAO,CAAC,CAAC,CAAC,CAACD;IAAO,CAAE;GAChF,MAAM;IACL,IAAIE,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;MACzC,MAAM,IAAIC,KAAK,CAAC,wEAAwE,CAAC;;IAE3F,OAAO;MAAEN,OAAO,EAAE,CAAC;MAAEC,OAAO,EAAE;IAAC,CAAE;;AAErC;AAXAL,OAAA,CAAAG,oBAAA,GAAAA,oBAAA"}
1
+ {"version":3,"sources":["../../lib/events/mouseTouchHelpers.js"],"sourcesContent":["import * as React from 'react';\n/**\n * Returns true if event is a touch event. Useful when sharing logic between touch and mouse interactions.\n */\nexport function isTouchEvent(event) {\n return event.type.startsWith('touch');\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) {\n return event.type.startsWith('mouse') || ['click', 'contextmenu', 'dblclick'].indexOf(event.type) > -1;\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) {\n if (isMouseEvent(event)) {\n return {\n clientX: event.clientX,\n clientY: event.clientY\n };\n } else if (isTouchEvent(event)) {\n return {\n clientX: event.touches[0].clientX,\n clientY: event.touches[0].clientY\n };\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 {\n clientX: 0,\n clientY: 0\n };\n }\n}\n//# sourceMappingURL=mouseTouchHelpers.js.map"],"names":["isTouchEvent","isMouseEvent","getEventClientCoords","event","type","startsWith","indexOf","clientX","clientY","touches","process","env","NODE_ENV","Error"],"mappings":";;;;;;;;;;;IAIgBA,YAAY,MAAZA;IAMAC,YAAY,MAAZA;IAOAC,oBAAoB,MAApBA;;;6DAjBO;AAIhB,SAASF,aAAaG,KAAK,EAAE;IAClC,OAAOA,MAAMC,IAAI,CAACC,UAAU,CAAC;AAC/B;AAIO,SAASJ,aAAaE,KAAK,EAAE;IAClC,OAAOA,MAAMC,IAAI,CAACC,UAAU,CAAC,YAAY;QAAC;QAAS;QAAe;KAAW,CAACC,OAAO,CAACH,MAAMC,IAAI,IAAI,CAAC;AACvG;AAKO,SAASF,qBAAqBC,KAAK,EAAE;IAC1C,IAAIF,aAAaE,QAAQ;QACvB,OAAO;YACLI,SAASJ,MAAMI,OAAO;YACtBC,SAASL,MAAMK,OAAO;QACxB;IACF,OAAO,IAAIR,aAAaG,QAAQ;QAC9B,OAAO;YACLI,SAASJ,MAAMM,OAAO,CAAC,EAAE,CAACF,OAAO;YACjCC,SAASL,MAAMM,OAAO,CAAC,EAAE,CAACD,OAAO;QACnC;IACF,OAAO;QACL,IAAIE,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACzC,MAAM,IAAIC,MAAM,0EAA0E;QAC5F,CAAC;QACD,OAAO;YACLN,SAAS;YACTC,SAAS;QACX;IACF,CAAC;AACH,EACA,6CAA6C"}
@@ -1,19 +1,20 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- const tslib_1 = /*#__PURE__*/require("tslib");
7
- tslib_1.__exportStar(require("./useControllableState"), exports);
8
- tslib_1.__exportStar(require("./useEventCallback"), exports);
9
- tslib_1.__exportStar(require("./useFirstMount"), exports);
10
- tslib_1.__exportStar(require("./useForceUpdate"), exports);
11
- tslib_1.__exportStar(require("./useId"), exports);
12
- tslib_1.__exportStar(require("./useIsomorphicLayoutEffect"), exports);
13
- tslib_1.__exportStar(require("./useMergedRefs"), exports);
14
- tslib_1.__exportStar(require("./useOnClickOutside"), exports);
15
- tslib_1.__exportStar(require("./useOnScrollOutside"), exports);
16
- tslib_1.__exportStar(require("./usePrevious"), exports);
17
- tslib_1.__exportStar(require("./useScrollbarWidth"), exports);
18
- tslib_1.__exportStar(require("./useTimeout"), exports);
5
+ const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
6
+ _exportStar(require("./useControllableState"), exports);
7
+ _exportStar(require("./useEventCallback"), exports);
8
+ _exportStar(require("./useFirstMount"), exports);
9
+ _exportStar(require("./useForceUpdate"), exports);
10
+ _exportStar(require("./useId"), exports);
11
+ _exportStar(require("./useIsomorphicLayoutEffect"), exports);
12
+ _exportStar(require("./useMergedRefs"), exports);
13
+ _exportStar(require("./useOnClickOutside"), exports);
14
+ _exportStar(require("./useOnScrollOutside"), exports);
15
+ _exportStar(require("./usePrevious"), exports);
16
+ _exportStar(require("./useScrollbarWidth"), exports);
17
+ _exportStar(require("./useTimeout"), exports);
18
+ //# sourceMappingURL=index.js.map
19
+
19
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["tslib_1","__exportStar","require","exports"],"sources":["../src/packages/react-components/react-utilities/src/hooks/index.ts"],"sourcesContent":["export * from './useControllableState';\nexport * from './useEventCallback';\nexport * from './useFirstMount';\nexport * from './useForceUpdate';\nexport * from './useId';\nexport * from './useIsomorphicLayoutEffect';\nexport * from './useMergedRefs';\nexport * from './useOnClickOutside';\nexport * from './useOnScrollOutside';\nexport * from './usePrevious';\nexport * from './useScrollbarWidth';\nexport * from './useTimeout';\n"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,4BAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,wBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,qBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,sBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,aAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,iCAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,qBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,yBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,0BAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,mBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,yBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,kBAAAC,OAAA"}
1
+ {"version":3,"sources":["../../lib/hooks/index.js"],"sourcesContent":["export * from './useControllableState';\nexport * from './useEventCallback';\nexport * from './useFirstMount';\nexport * from './useForceUpdate';\nexport * from './useId';\nexport * from './useIsomorphicLayoutEffect';\nexport * from './useMergedRefs';\nexport * from './useOnClickOutside';\nexport * from './useOnScrollOutside';\nexport * from './usePrevious';\nexport * from './useScrollbarWidth';\nexport * from './useTimeout';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;CACd,iCAAiC"}
@@ -1,75 +1,74 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useControllableState", {
6
+ enumerable: true,
7
+ get: ()=>useControllableState
5
8
  });
6
- exports.useControllableState = void 0;
7
- const React = /*#__PURE__*/require("react");
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
8
11
  function isFactoryDispatch(newState) {
9
- return typeof newState === 'function';
12
+ return typeof newState === 'function';
10
13
  }
11
- /**
12
- * @internal
13
- *
14
- * A `useState`-like hook to manage a value that could be either controlled or uncontrolled,
15
- * such as a checked state or text input string.
16
- *
17
- * Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a
18
- * controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.
19
- *
20
- * @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array
21
- * of the current value and an updater (dispatch) function. The updater function is referentially
22
- * stable (won't change during the component's lifecycle). It can take either a new value, or a
23
- * function which is passed the previous value and returns the new value. Unlike `setState`, calls
24
- * to the updater function will only be respected if the component is uncontrolled.
25
- * @see https://reactjs.org/docs/uncontrolled-components.html
26
- */
27
- const useControllableState = options => {
28
- const isControlled = useIsControlled(options.state);
29
- const initialState = typeof options.defaultState === 'undefined' ? options.initialState : options.defaultState;
30
- const [internalState, setInternalState] = React.useState(initialState);
31
- const state = isControlled ? options.state : internalState;
32
- const stateRef = React.useRef(state);
33
- React.useEffect(() => {
34
- stateRef.current = state;
35
- }, [state]);
36
- // To match the behavior of the setter returned by React.useState, this callback's identity
37
- // should never change. This means it MUST NOT directly reference variables that can change.
38
- const setState = React.useCallback(newState => {
39
- // React dispatch can use a factory
40
- // https://reactjs.org/docs/hooks-reference.html#functional-updates
41
- if (isFactoryDispatch(newState)) {
42
- stateRef.current = newState(stateRef.current);
43
- } else {
44
- stateRef.current = newState;
45
- }
46
- setInternalState(stateRef.current);
47
- }, []);
48
- return [state, setState];
14
+ const useControllableState = (options)=>{
15
+ const isControlled = useIsControlled(options.state);
16
+ const initialState = typeof options.defaultState === 'undefined' ? options.initialState : options.defaultState;
17
+ const [internalState, setInternalState] = _react.useState(initialState);
18
+ const state = isControlled ? options.state : internalState;
19
+ const stateRef = _react.useRef(state);
20
+ _react.useEffect(()=>{
21
+ stateRef.current = state;
22
+ }, [
23
+ state
24
+ ]);
25
+ // To match the behavior of the setter returned by React.useState, this callback's identity
26
+ // should never change. This means it MUST NOT directly reference variables that can change.
27
+ const setState = _react.useCallback((newState)=>{
28
+ // React dispatch can use a factory
29
+ // https://reactjs.org/docs/hooks-reference.html#functional-updates
30
+ if (isFactoryDispatch(newState)) {
31
+ stateRef.current = newState(stateRef.current);
32
+ } else {
33
+ stateRef.current = newState;
34
+ }
35
+ setInternalState(stateRef.current);
36
+ }, []);
37
+ return [
38
+ state,
39
+ setState
40
+ ];
49
41
  };
50
- exports.useControllableState = useControllableState;
51
42
  /**
52
43
  * Helper hook to handle previous comparison of controlled/uncontrolled
53
44
  * Prints an error when isControlled value switches between subsequent renders
54
45
  * @returns - whether the value is controlled
55
- */
56
- const useIsControlled = controlledValue => {
57
- const [isControlled] = React.useState(() => controlledValue !== undefined);
58
- if (process.env.NODE_ENV !== 'production') {
59
- // We don't want these warnings in production even though it is against native behaviour
60
- // eslint-disable-next-line react-hooks/rules-of-hooks
61
- React.useEffect(() => {
62
- if (isControlled !== (controlledValue !== undefined)) {
63
- const error = new Error();
64
- const controlWarning = isControlled ? 'a controlled value to be uncontrolled' : 'an uncontrolled value to be controlled';
65
- const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';
66
- // eslint-disable-next-line no-console
67
- console.error([
68
- // Default react error
69
- 'A component is changing ' + controlWarning + '. This is likely caused by the value', 'changing from ' + undefinedWarning + ' value, which should not happen.', 'Decide between using a controlled or uncontrolled input element for the lifetime of the component.', 'More info: https://reactjs.org/link/controlled-components', error.stack].join(' '));
70
- }
71
- }, [isControlled, controlledValue]);
72
- }
73
- return isControlled;
74
- };
46
+ */ const useIsControlled = (controlledValue)=>{
47
+ const [isControlled] = _react.useState(()=>controlledValue !== undefined);
48
+ if (process.env.NODE_ENV !== 'production') {
49
+ // We don't want these warnings in production even though it is against native behaviour
50
+ // eslint-disable-next-line react-hooks/rules-of-hooks
51
+ _react.useEffect(()=>{
52
+ if (isControlled !== (controlledValue !== undefined)) {
53
+ const error = new Error();
54
+ const controlWarning = isControlled ? 'a controlled value to be uncontrolled' : 'an uncontrolled value to be controlled';
55
+ const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';
56
+ // eslint-disable-next-line no-console
57
+ console.error([
58
+ // Default react error
59
+ 'A component is changing ' + controlWarning + '. This is likely caused by the value',
60
+ 'changing from ' + undefinedWarning + ' value, which should not happen.',
61
+ 'Decide between using a controlled or uncontrolled input element for the lifetime of the component.',
62
+ 'More info: https://reactjs.org/link/controlled-components',
63
+ error.stack
64
+ ].join(' '));
65
+ }
66
+ }, [
67
+ isControlled,
68
+ controlledValue
69
+ ]);
70
+ }
71
+ return isControlled;
72
+ }; //# sourceMappingURL=useControllableState.js.map
73
+
75
74
  //# sourceMappingURL=useControllableState.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","require","isFactoryDispatch","newState","useControllableState","options","isControlled","useIsControlled","state","initialState","defaultState","internalState","setInternalState","useState","stateRef","useRef","useEffect","current","setState","useCallback","exports","controlledValue","undefined","process","env","NODE_ENV","error","Error","controlWarning","undefinedWarning","console","stack","join"],"sources":["../src/packages/react-components/react-utilities/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`-like hook to manage a value that could be either controlled or uncontrolled,\n * such as a checked state or text input string.\n *\n * Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a\n * controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.\n *\n * @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array\n * of the current value and an updater (dispatch) function. The updater function is referentially\n * stable (won't change during the component's lifecycle). It can take either a new value, or a\n * function which is passed the previous value and returns the new value. Unlike `setState`, calls\n * to the updater function will only be respected if the component is uncontrolled.\n * @see https://reactjs.org/docs/uncontrolled-components.html\n */\nexport const useControllableState = <State>(\n options: UseControllableStateOptions<State>,\n): [State, React.Dispatch<React.SetStateAction<State>>] => {\n const isControlled = useIsControlled(options.state);\n const initialState = typeof options.defaultState === 'undefined' ? options.initialState : options.defaultState;\n const [internalState, setInternalState] = React.useState<State>(initialState);\n\n const state = isControlled ? (options.state as State) : internalState;\n\n const stateRef = React.useRef(state);\n React.useEffect(() => {\n stateRef.current = state;\n }, [state]);\n\n // To match the behavior of the setter returned by React.useState, this callback's identity\n // should never change. This means it MUST NOT directly reference variables that can change.\n const setState = React.useCallback((newState: React.SetStateAction<State>) => {\n // React dispatch can use a factory\n // https://reactjs.org/docs/hooks-reference.html#functional-updates\n if (isFactoryDispatch(newState)) {\n stateRef.current = newState(stateRef.current);\n } else {\n stateRef.current = newState;\n }\n\n setInternalState(stateRef.current);\n }, []);\n\n return [state, setState];\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 = (controlledValue: unknown) => {\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(\n [\n // Default react error\n 'A component is changing ' + controlWarning + '. This is likely caused by the value',\n '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 ].join(' '),\n );\n }\n }, [isControlled, controlledValue]);\n }\n\n return isControlled;\n};\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AAqBA,SAASC,iBAAiBA,CAAQC,QAAqC;EACrE,OAAO,OAAOA,QAAQ,KAAK,UAAU;AACvC;AAEA;;;;;;;;;;;;;;;;AAgBO,MAAMC,oBAAoB,GAC/BC,OAA2C,IACa;EACxD,MAAMC,YAAY,GAAGC,eAAe,CAACF,OAAO,CAACG,KAAK,CAAC;EACnD,MAAMC,YAAY,GAAG,OAAOJ,OAAO,CAACK,YAAY,KAAK,WAAW,GAAGL,OAAO,CAACI,YAAY,GAAGJ,OAAO,CAACK,YAAY;EAC9G,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGZ,KAAK,CAACa,QAAQ,CAAQJ,YAAY,CAAC;EAE7E,MAAMD,KAAK,GAAGF,YAAY,GAAID,OAAO,CAACG,KAAe,GAAGG,aAAa;EAErE,MAAMG,QAAQ,GAAGd,KAAK,CAACe,MAAM,CAACP,KAAK,CAAC;EACpCR,KAAK,CAACgB,SAAS,CAAC,MAAK;IACnBF,QAAQ,CAACG,OAAO,GAAGT,KAAK;EAC1B,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX;EACA;EACA,MAAMU,QAAQ,GAAGlB,KAAK,CAACmB,WAAW,CAAEhB,QAAqC,IAAI;IAC3E;IACA;IACA,IAAID,iBAAiB,CAACC,QAAQ,CAAC,EAAE;MAC/BW,QAAQ,CAACG,OAAO,GAAGd,QAAQ,CAACW,QAAQ,CAACG,OAAO,CAAC;KAC9C,MAAM;MACLH,QAAQ,CAACG,OAAO,GAAGd,QAAQ;;IAG7BS,gBAAgB,CAACE,QAAQ,CAACG,OAAO,CAAC;EACpC,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO,CAACT,KAAK,EAAEU,QAAQ,CAAC;AAC1B,CAAC;AA7BYE,OAAA,CAAAhB,oBAAoB,GAAAA,oBAAA;AA+BjC;;;;;AAKA,MAAMG,eAAe,GAAIc,eAAwB,IAAI;EACnD,MAAM,CAACf,YAAY,CAAC,GAAGN,KAAK,CAACa,QAAQ,CAAU,MAAMQ,eAAe,KAAKC,SAAS,CAAC;EAEnF,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC;IACA;IACAzB,KAAK,CAACgB,SAAS,CAAC,MAAK;MACnB,IAAIV,YAAY,MAAMe,eAAe,KAAKC,SAAS,CAAC,EAAE;QACpD,MAAMI,KAAK,GAAG,IAAIC,KAAK,EAAE;QAEzB,MAAMC,cAAc,GAAGtB,YAAY,GAC/B,uCAAuC,GACvC,wCAAwC;QAE5C,MAAMuB,gBAAgB,GAAGvB,YAAY,GAAG,yBAAyB,GAAG,wBAAwB;QAE5F;QACAwB,OAAO,CAACJ,KAAK,CACX;QACE;QACA,0BAA0B,GAAGE,cAAc,GAAG,sCAAsC,EACpF,gBAAgB,GAAGC,gBAAgB,GAAG,kCAAkC,EACxE,oGAAoG,EACpG,2DAA2D,EAC3DH,KAAK,CAACK,KAAK,CACZ,CAACC,IAAI,CAAC,GAAG,CAAC,CACZ;;IAEL,CAAC,EAAE,CAAC1B,YAAY,EAAEe,eAAe,CAAC,CAAC;;EAGrC,OAAOf,YAAY;AACrB,CAAC"}
1
+ {"version":3,"sources":["../../lib/hooks/useControllableState.js"],"sourcesContent":["import * as React from 'react';\nfunction isFactoryDispatch(newState) {\n return typeof newState === 'function';\n}\n/**\n * @internal\n *\n * A `useState`-like hook to manage a value that could be either controlled or uncontrolled,\n * such as a checked state or text input string.\n *\n * Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a\n * controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.\n *\n * @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array\n * of the current value and an updater (dispatch) function. The updater function is referentially\n * stable (won't change during the component's lifecycle). It can take either a new value, or a\n * function which is passed the previous value and returns the new value. Unlike `setState`, calls\n * to the updater function will only be respected if the component is uncontrolled.\n * @see https://reactjs.org/docs/uncontrolled-components.html\n */\nexport const useControllableState = options => {\n const isControlled = useIsControlled(options.state);\n const initialState = typeof options.defaultState === 'undefined' ? options.initialState : options.defaultState;\n const [internalState, setInternalState] = React.useState(initialState);\n const state = isControlled ? options.state : internalState;\n const stateRef = React.useRef(state);\n React.useEffect(() => {\n stateRef.current = state;\n }, [state]);\n // To match the behavior of the setter returned by React.useState, this callback's identity\n // should never change. This means it MUST NOT directly reference variables that can change.\n const setState = React.useCallback(newState => {\n // React dispatch can use a factory\n // https://reactjs.org/docs/hooks-reference.html#functional-updates\n if (isFactoryDispatch(newState)) {\n stateRef.current = newState(stateRef.current);\n } else {\n stateRef.current = newState;\n }\n setInternalState(stateRef.current);\n }, []);\n return [state, setState];\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 = controlledValue => {\n const [isControlled] = React.useState(() => controlledValue !== undefined);\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 const controlWarning = isControlled ? 'a controlled value to be uncontrolled' : 'an uncontrolled value to be controlled';\n const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';\n // eslint-disable-next-line no-console\n console.error([\n // Default react error\n 'A component is changing ' + controlWarning + '. This is likely caused by the value', 'changing from ' + undefinedWarning + ' value, which should not happen.', 'Decide between using a controlled or uncontrolled input element for the lifetime of the component.', 'More info: https://reactjs.org/link/controlled-components', error.stack].join(' '));\n }\n }, [isControlled, controlledValue]);\n }\n return isControlled;\n};\n//# sourceMappingURL=useControllableState.js.map"],"names":["useControllableState","isFactoryDispatch","newState","options","isControlled","useIsControlled","state","initialState","defaultState","internalState","setInternalState","React","useState","stateRef","useRef","useEffect","current","setState","useCallback","controlledValue","undefined","process","env","NODE_ENV","error","Error","controlWarning","undefinedWarning","console","stack","join"],"mappings":";;;;+BAoBaA;;aAAAA;;;6DApBU;AACvB,SAASC,kBAAkBC,QAAQ,EAAE;IACnC,OAAO,OAAOA,aAAa;AAC7B;AAiBO,MAAMF,uBAAuBG,CAAAA,UAAW;IAC7C,MAAMC,eAAeC,gBAAgBF,QAAQG,KAAK;IAClD,MAAMC,eAAe,OAAOJ,QAAQK,YAAY,KAAK,cAAcL,QAAQI,YAAY,GAAGJ,QAAQK,YAAY;IAC9G,MAAM,CAACC,eAAeC,iBAAiB,GAAGC,OAAMC,QAAQ,CAACL;IACzD,MAAMD,QAAQF,eAAeD,QAAQG,KAAK,GAAGG,aAAa;IAC1D,MAAMI,WAAWF,OAAMG,MAAM,CAACR;IAC9BK,OAAMI,SAAS,CAAC,IAAM;QACpBF,SAASG,OAAO,GAAGV;IACrB,GAAG;QAACA;KAAM;IACV,2FAA2F;IAC3F,4FAA4F;IAC5F,MAAMW,WAAWN,OAAMO,WAAW,CAAChB,CAAAA,WAAY;QAC7C,mCAAmC;QACnC,mEAAmE;QACnE,IAAID,kBAAkBC,WAAW;YAC/BW,SAASG,OAAO,GAAGd,SAASW,SAASG,OAAO;QAC9C,OAAO;YACLH,SAASG,OAAO,GAAGd;QACrB,CAAC;QACDQ,iBAAiBG,SAASG,OAAO;IACnC,GAAG,EAAE;IACL,OAAO;QAACV;QAAOW;KAAS;AAC1B;AACA;;;;CAIC,GACD,MAAMZ,kBAAkBc,CAAAA,kBAAmB;IACzC,MAAM,CAACf,aAAa,GAAGO,OAAMC,QAAQ,CAAC,IAAMO,oBAAoBC;IAChE,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,wFAAwF;QACxF,sDAAsD;QACtDZ,OAAMI,SAAS,CAAC,IAAM;YACpB,IAAIX,iBAAkBe,CAAAA,oBAAoBC,SAAQ,GAAI;gBACpD,MAAMI,QAAQ,IAAIC;gBAClB,MAAMC,iBAAiBtB,eAAe,0CAA0C,wCAAwC;gBACxH,MAAMuB,mBAAmBvB,eAAe,4BAA4B,wBAAwB;gBAC5F,sCAAsC;gBACtCwB,QAAQJ,KAAK,CAAC;oBACd,sBAAsB;oBACtB,6BAA6BE,iBAAiB;oBAAwC,mBAAmBC,mBAAmB;oBAAoC;oBAAsG;oBAA6DH,MAAMK,KAAK;iBAAC,CAACC,IAAI,CAAC;YACvV,CAAC;QACH,GAAG;YAAC1B;YAAce;SAAgB;IACpC,CAAC;IACD,OAAOf;AACT,GACA,gDAAgD"}
@@ -1,35 +1,29 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useEventCallback", {
6
+ enumerable: true,
7
+ get: ()=>useEventCallback
5
8
  });
6
- exports.useEventCallback = void 0;
7
- const React = /*#__PURE__*/require("react");
8
- const useIsomorphicLayoutEffect_1 = /*#__PURE__*/require("./useIsomorphicLayoutEffect");
9
- /**
10
- * @internal
11
- * https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
12
- *
13
- * Modified `useCallback` that can be used when dependencies change too frequently. Can occur when
14
- * e.g. user props are dependencies which could change on every render
15
- * e.g. volatile values (i.e. useState/useDispatch) are dependencies which could change frequently
16
- *
17
- * This should not be used often, but can be a useful re-render optimization since the callback is a ref and
18
- * will not be invalidated between re-renders
19
- *
20
- * @param fn - The callback function that will be used
21
- */
22
- const useEventCallback = fn => {
23
- const callbackRef = React.useRef(() => {
24
- throw new Error('Cannot call an event handler while rendering');
25
- });
26
- useIsomorphicLayoutEffect_1.useIsomorphicLayoutEffect(() => {
27
- callbackRef.current = fn;
28
- }, [fn]);
29
- return React.useCallback((...args) => {
30
- const callback = callbackRef.current;
31
- return callback(...args);
32
- }, [callbackRef]);
33
- };
34
- exports.useEventCallback = useEventCallback;
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect");
12
+ const useEventCallback = (fn)=>{
13
+ const callbackRef = _react.useRef(()=>{
14
+ throw new Error('Cannot call an event handler while rendering');
15
+ });
16
+ (0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(()=>{
17
+ callbackRef.current = fn;
18
+ }, [
19
+ fn
20
+ ]);
21
+ return _react.useCallback((...args)=>{
22
+ const callback = callbackRef.current;
23
+ return callback(...args);
24
+ }, [
25
+ callbackRef
26
+ ]);
27
+ }; //# sourceMappingURL=useEventCallback.js.map
28
+
35
29
  //# sourceMappingURL=useEventCallback.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","require","useIsomorphicLayoutEffect_1","useEventCallback","fn","callbackRef","useRef","Error","useIsomorphicLayoutEffect","current","useCallback","args","callback","exports"],"sources":["../src/packages/react-components/react-utilities/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"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,2BAAA,gBAAAD,OAAA;AAEA;;;;;;;;;;;;;AAaO,MAAME,gBAAgB,GAAoCC,EAA6B,IAAI;EAChG,MAAMC,WAAW,GAAGL,KAAK,CAACM,MAAM,CAAY,MAAK;IAC/C,MAAM,IAAIC,KAAK,CAAC,8CAA8C,CAAC;EACjE,CAAC,CAAC;EAEFL,2BAAA,CAAAM,yBAAyB,CAAC,MAAK;IAC7BH,WAAW,CAACI,OAAO,GAAGL,EAAE;EAC1B,CAAC,EAAE,CAACA,EAAE,CAAC,CAAC;EAER,OAAOJ,KAAK,CAACU,WAAW,CACtB,CAAC,GAAGC,IAAU,KAAI;IAChB,MAAMC,QAAQ,GAAGP,WAAW,CAACI,OAAO;IACpC,OAAOG,QAAQ,CAAC,GAAGD,IAAI,CAAC;EAC1B,CAAC,EACD,CAACN,WAAW,CAAC,CACd;AACH,CAAC;AAhBYQ,OAAA,CAAAV,gBAAgB,GAAAA,gBAAA"}
1
+ {"version":3,"sources":["../../lib/hooks/useEventCallback.js"],"sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\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 = fn => {\n const callbackRef = React.useRef(() => {\n throw new Error('Cannot call an event handler while rendering');\n });\n useIsomorphicLayoutEffect(() => {\n callbackRef.current = fn;\n }, [fn]);\n return React.useCallback((...args) => {\n const callback = callbackRef.current;\n return callback(...args);\n }, [callbackRef]);\n};\n//# sourceMappingURL=useEventCallback.js.map"],"names":["useEventCallback","fn","callbackRef","React","useRef","Error","useIsomorphicLayoutEffect","current","useCallback","args","callback"],"mappings":";;;;+BAeaA;;aAAAA;;;6DAfU;2CACmB;AAcnC,MAAMA,mBAAmBC,CAAAA,KAAM;IACpC,MAAMC,cAAcC,OAAMC,MAAM,CAAC,IAAM;QACrC,MAAM,IAAIC,MAAM,gDAAgD;IAClE;IACAC,IAAAA,oDAAyB,EAAC,IAAM;QAC9BJ,YAAYK,OAAO,GAAGN;IACxB,GAAG;QAACA;KAAG;IACP,OAAOE,OAAMK,WAAW,CAAC,CAAC,GAAGC,OAAS;QACpC,MAAMC,WAAWR,YAAYK,OAAO;QACpC,OAAOG,YAAYD;IACrB,GAAG;QAACP;KAAY;AAClB,GACA,4CAA4C"}
@@ -1,28 +1,20 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useFirstMount", {
6
+ enumerable: true,
7
+ get: ()=>useFirstMount
5
8
  });
6
- exports.useFirstMount = void 0;
7
- const React = /*#__PURE__*/require("react");
8
- /**
9
- * @internal
10
- * Checks if components was mounted the first time.
11
- * Since concurrent mode will be released in the future this needs to be verified
12
- * Currently (React 17) will always render the initial mount once
13
- * https://codesandbox.io/s/heuristic-brook-s4w0q?file=/src/App.jsx
14
- * https://codesandbox.io/s/holy-grass-8nieu?file=/src/App.jsx
15
- *
16
- * @example
17
- * const isFirstMount = useFirstMount();
18
- */
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
19
11
  function useFirstMount() {
20
- const isFirst = React.useRef(true);
21
- if (isFirst.current) {
22
- isFirst.current = false;
23
- return true;
24
- }
25
- return isFirst.current;
26
- }
27
- exports.useFirstMount = useFirstMount;
12
+ const isFirst = _react.useRef(true);
13
+ if (isFirst.current) {
14
+ isFirst.current = false;
15
+ return true;
16
+ }
17
+ return isFirst.current;
18
+ } //# sourceMappingURL=useFirstMount.js.map
19
+
28
20
  //# sourceMappingURL=useFirstMount.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","require","useFirstMount","isFirst","useRef","current","exports"],"sources":["../src/packages/react-components/react-utilities/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"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AAEA;;;;;;;;;;;AAWA,SAAgBC,aAAaA,CAAA;EAC3B,MAAMC,OAAO,GAAGH,KAAK,CAACI,MAAM,CAAC,IAAI,CAAC;EAElC,IAAID,OAAO,CAACE,OAAO,EAAE;IACnBF,OAAO,CAACE,OAAO,GAAG,KAAK;IACvB,OAAO,IAAI;;EAGb,OAAOF,OAAO,CAACE,OAAO;AACxB;AATAC,OAAA,CAAAJ,aAAA,GAAAA,aAAA"}
1
+ {"version":3,"sources":["../../lib/hooks/useFirstMount.js"],"sourcesContent":["import * as React from 'react';\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() {\n const isFirst = React.useRef(true);\n if (isFirst.current) {\n isFirst.current = false;\n return true;\n }\n return isFirst.current;\n}\n//# sourceMappingURL=useFirstMount.js.map"],"names":["useFirstMount","isFirst","React","useRef","current"],"mappings":";;;;+BAYgBA;;aAAAA;;;6DAZO;AAYhB,SAASA,gBAAgB;IAC9B,MAAMC,UAAUC,OAAMC,MAAM,CAAC,IAAI;IACjC,IAAIF,QAAQG,OAAO,EAAE;QACnBH,QAAQG,OAAO,GAAG,KAAK;QACvB,OAAO,IAAI;IACb,CAAC;IACD,OAAOH,QAAQG,OAAO;AACxB,EACA,yCAAyC"}
@@ -1,16 +1,14 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useForceUpdate", {
6
+ enumerable: true,
7
+ get: ()=>useForceUpdate
5
8
  });
6
- exports.useForceUpdate = void 0;
7
- const react_1 = /*#__PURE__*/require("react");
8
- /**
9
- * @internal
10
- * Forces a re-render, similar to `forceUpdate` in class components.
11
- */
9
+ const _react = require("react");
12
10
  function useForceUpdate() {
13
- return react_1.useReducer(x => x + 1, 0)[1];
14
- }
15
- exports.useForceUpdate = useForceUpdate;
11
+ return (0, _react.useReducer)((x)=>x + 1, 0)[1];
12
+ } //# sourceMappingURL=useForceUpdate.js.map
13
+
16
14
  //# sourceMappingURL=useForceUpdate.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["react_1","require","useForceUpdate","useReducer","x","exports"],"sources":["../src/packages/react-components/react-utilities/src/hooks/useForceUpdate.ts"],"sourcesContent":["import { useReducer } from 'react';\n\n/**\n * @internal\n * Forces a re-render, similar to `forceUpdate` in class components.\n */\nexport function useForceUpdate() {\n return useReducer(x => x + 1, 0)[1];\n}\n"],"mappings":";;;;;;AAAA,MAAAA,OAAA,gBAAAC,OAAA;AAEA;;;;AAIA,SAAgBC,cAAcA,CAAA;EAC5B,OAAOF,OAAA,CAAAG,UAAU,CAACC,CAAC,IAAIA,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC;AAFAC,OAAA,CAAAH,cAAA,GAAAA,cAAA"}
1
+ {"version":3,"sources":["../../lib/hooks/useForceUpdate.js"],"sourcesContent":["import { useReducer } from 'react';\n/**\n * @internal\n * Forces a re-render, similar to `forceUpdate` in class components.\n */\nexport function useForceUpdate() {\n return useReducer(x => x + 1, 0)[1];\n}\n//# sourceMappingURL=useForceUpdate.js.map"],"names":["useForceUpdate","useReducer","x"],"mappings":";;;;+BAKgBA;;aAAAA;;uBALW;AAKpB,SAASA,iBAAiB;IAC/B,OAAOC,IAAAA,iBAAU,EAACC,CAAAA,IAAKA,IAAI,GAAG,EAAE,CAAC,EAAE;AACrC,EACA,0CAA0C"}