@fluentui/react-utilities 9.3.0 → 9.4.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 (143) hide show
  1. package/CHANGELOG.json +45 -1
  2. package/CHANGELOG.md +20 -2
  3. package/dist/index.d.ts +18 -2
  4. package/lib/compose/getSlots.js +0 -8
  5. package/lib/compose/getSlots.js.map +1 -1
  6. package/lib/compose/isResolvedShorthand.js +0 -1
  7. package/lib/compose/isResolvedShorthand.js.map +1 -1
  8. package/lib/compose/resolveShorthand.js +2 -6
  9. package/lib/compose/resolveShorthand.js.map +1 -1
  10. package/lib/hooks/index.js +1 -0
  11. package/lib/hooks/index.js.map +1 -1
  12. package/lib/hooks/useControllableState.js +6 -12
  13. package/lib/hooks/useControllableState.js.map +1 -1
  14. package/lib/hooks/useEventCallback.js +0 -1
  15. package/lib/hooks/useEventCallback.js.map +1 -1
  16. package/lib/hooks/useFirstMount.js +0 -3
  17. package/lib/hooks/useFirstMount.js.map +1 -1
  18. package/lib/hooks/useForceUpdate.js +0 -1
  19. package/lib/hooks/useForceUpdate.js.map +1 -1
  20. package/lib/hooks/useId.js +0 -3
  21. package/lib/hooks/useId.js.map +1 -1
  22. package/lib/hooks/useIsomorphicLayoutEffect.js +0 -1
  23. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  24. package/lib/hooks/useMergedRefs.js +2 -3
  25. package/lib/hooks/useMergedRefs.js.map +1 -1
  26. package/lib/hooks/useOnClickOutside.js +8 -26
  27. package/lib/hooks/useOnClickOutside.js.map +1 -1
  28. package/lib/hooks/useOnScrollOutside.js +0 -4
  29. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  30. package/lib/hooks/usePrevious.js +0 -1
  31. package/lib/hooks/usePrevious.js.map +1 -1
  32. package/lib/hooks/useScrollbarWidth.js +30 -0
  33. package/lib/hooks/useScrollbarWidth.js.map +1 -0
  34. package/lib/hooks/useTimeout.js +2 -3
  35. package/lib/hooks/useTimeout.js.map +1 -1
  36. package/lib/index.js +1 -1
  37. package/lib/index.js.map +1 -1
  38. package/lib/ssr/SSRContext.js +4 -11
  39. package/lib/ssr/SSRContext.js.map +1 -1
  40. package/lib/ssr/canUseDOM.js +2 -1
  41. package/lib/ssr/canUseDOM.js.map +1 -1
  42. package/lib/trigger/applyTriggerPropsToChildren.js +2 -6
  43. package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
  44. package/lib/trigger/getTriggerChild.js +2 -3
  45. package/lib/trigger/getTriggerChild.js.map +1 -1
  46. package/lib/trigger/isFluentTrigger.js.map +1 -1
  47. package/lib/utils/getNativeElementProps.js +0 -2
  48. package/lib/utils/getNativeElementProps.js.map +1 -1
  49. package/lib/utils/getRTLSafeKey.js +0 -2
  50. package/lib/utils/getRTLSafeKey.js.map +1 -1
  51. package/lib/utils/getReactCallbackName.js +0 -3
  52. package/lib/utils/getReactCallbackName.js.map +1 -1
  53. package/lib/utils/isHTMLElement.js +2 -2
  54. package/lib/utils/isHTMLElement.js.map +1 -1
  55. package/lib/utils/isInteractiveHTMLElement.js +0 -4
  56. package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
  57. package/lib/utils/mergeCallbacks.js.map +1 -1
  58. package/lib/utils/omit.js +0 -2
  59. package/lib/utils/omit.js.map +1 -1
  60. package/lib/utils/properties.js +7 -36
  61. package/lib/utils/properties.js.map +1 -1
  62. package/lib-amd/hooks/index.js +2 -1
  63. package/lib-amd/hooks/index.js.map +1 -1
  64. package/lib-amd/hooks/useScrollbarWidth.js +32 -0
  65. package/lib-amd/hooks/useScrollbarWidth.js.map +1 -0
  66. package/lib-amd/index.js +2 -1
  67. package/lib-amd/index.js.map +1 -1
  68. package/lib-amd/utils/isHTMLElement.js +4 -3
  69. package/lib-amd/utils/isHTMLElement.js.map +1 -1
  70. package/lib-amd/utils/isInteractiveHTMLElement.js.map +1 -1
  71. package/lib-commonjs/compose/getSlots.js +0 -12
  72. package/lib-commonjs/compose/getSlots.js.map +1 -1
  73. package/lib-commonjs/compose/index.js +0 -5
  74. package/lib-commonjs/compose/index.js.map +1 -1
  75. package/lib-commonjs/compose/isResolvedShorthand.js +0 -4
  76. package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
  77. package/lib-commonjs/compose/resolveShorthand.js +2 -9
  78. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  79. package/lib-commonjs/compose/types.js.map +1 -1
  80. package/lib-commonjs/hooks/index.js +1 -12
  81. package/lib-commonjs/hooks/index.js.map +1 -1
  82. package/lib-commonjs/hooks/useControllableState.js +6 -14
  83. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  84. package/lib-commonjs/hooks/useEventCallback.js +0 -5
  85. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  86. package/lib-commonjs/hooks/useFirstMount.js +0 -6
  87. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  88. package/lib-commonjs/hooks/useForceUpdate.js +0 -4
  89. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  90. package/lib-commonjs/hooks/useId.js +0 -8
  91. package/lib-commonjs/hooks/useId.js.map +1 -1
  92. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +0 -4
  93. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  94. package/lib-commonjs/hooks/useMergedRefs.js +2 -6
  95. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  96. package/lib-commonjs/hooks/useOnClickOutside.js +8 -30
  97. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  98. package/lib-commonjs/hooks/useOnScrollOutside.js +0 -8
  99. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  100. package/lib-commonjs/hooks/usePrevious.js +0 -4
  101. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  102. package/lib-commonjs/hooks/useScrollbarWidth.js +37 -0
  103. package/lib-commonjs/hooks/useScrollbarWidth.js.map +1 -0
  104. package/lib-commonjs/hooks/useTimeout.js +2 -6
  105. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  106. package/lib-commonjs/index.js +7 -11
  107. package/lib-commonjs/index.js.map +1 -1
  108. package/lib-commonjs/ssr/SSRContext.js +4 -17
  109. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  110. package/lib-commonjs/ssr/canUseDOM.js +2 -3
  111. package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
  112. package/lib-commonjs/ssr/index.js +0 -3
  113. package/lib-commonjs/ssr/index.js.map +1 -1
  114. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js +2 -10
  115. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
  116. package/lib-commonjs/trigger/getTriggerChild.js +2 -7
  117. package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
  118. package/lib-commonjs/trigger/index.js +0 -5
  119. package/lib-commonjs/trigger/index.js.map +1 -1
  120. package/lib-commonjs/trigger/isFluentTrigger.js +0 -2
  121. package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
  122. package/lib-commonjs/trigger/types.js.map +1 -1
  123. package/lib-commonjs/utils/clamp.js +0 -2
  124. package/lib-commonjs/utils/clamp.js.map +1 -1
  125. package/lib-commonjs/utils/getNativeElementProps.js +0 -6
  126. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  127. package/lib-commonjs/utils/getRTLSafeKey.js +0 -4
  128. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  129. package/lib-commonjs/utils/getReactCallbackName.js +0 -5
  130. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
  131. package/lib-commonjs/utils/index.js +0 -9
  132. package/lib-commonjs/utils/index.js.map +1 -1
  133. package/lib-commonjs/utils/isHTMLElement.js +2 -4
  134. package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
  135. package/lib-commonjs/utils/isInteractiveHTMLElement.js +0 -7
  136. package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
  137. package/lib-commonjs/utils/mergeCallbacks.js +0 -2
  138. package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
  139. package/lib-commonjs/utils/omit.js +0 -4
  140. package/lib-commonjs/utils/omit.js.map +1 -1
  141. package/lib-commonjs/utils/properties.js +7 -38
  142. package/lib-commonjs/utils/properties.js.map +1 -1
  143. package/package.json +2 -2
@@ -13,9 +13,10 @@ define(["require", "exports"], function (require, exports) {
13
13
  */
14
14
  function isHTMLElement(element) {
15
15
  var _a;
16
- return Boolean(element !== null &&
17
- ((_a = element === null || element === void 0 ? void 0 : element.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) &&
18
- element instanceof element.ownerDocument.defaultView.HTMLElement);
16
+ var typedElement = element;
17
+ return Boolean(typedElement !== null &&
18
+ ((_a = typedElement === null || typedElement === void 0 ? void 0 : typedElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) &&
19
+ typedElement instanceof typedElement.ownerDocument.defaultView.HTMLElement);
19
20
  }
20
21
  exports.isHTMLElement = isHTMLElement;
21
22
  });
@@ -1 +1 @@
1
- {"version":3,"file":"isHTMLElement.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/isHTMLElement.ts"],"names":[],"mappings":";;;;IAAA;;;;;;;;OAQG;IACH,SAAgB,aAAa,CAAC,OAAiC;;QAC7D,OAAO,OAAO,CACZ,OAAO,KAAK,IAAI;aACd,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,0CAAE,WAAW,CAAA;YACnC,OAAO,YAAY,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,WAAW,CACnE,CAAC;IACJ,CAAC;IAND,sCAMC","sourcesContent":["/**\n * @internal\n * Verifies if a given node is an HTMLElement,\n * this method works seamlessly with frames and elements from different documents\n *\n * This is required as simply using `instanceof`\n * might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)\n *\n */\nexport function isHTMLElement(element?: Node | null | undefined): element is HTMLElement {\n return Boolean(\n element !== null &&\n element?.ownerDocument?.defaultView &&\n element instanceof element.ownerDocument.defaultView.HTMLElement,\n );\n}\n"]}
1
+ {"version":3,"file":"isHTMLElement.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/isHTMLElement.ts"],"names":[],"mappings":";;;;IAAA;;;;;;;;OAQG;IACH,SAAgB,aAAa,CAAC,OAAiB;;QAC7C,IAAM,YAAY,GAAG,OAAkC,CAAC;QACxD,OAAO,OAAO,CACZ,YAAY,KAAK,IAAI;aACnB,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,aAAa,0CAAE,WAAW,CAAA;YACxC,YAAY,YAAY,YAAY,CAAC,aAAa,CAAC,WAAW,CAAC,WAAW,CAC7E,CAAC;IACJ,CAAC;IAPD,sCAOC","sourcesContent":["/**\n * @internal\n * Verifies if a given node is an HTMLElement,\n * this method works seamlessly with frames and elements from different documents\n *\n * This is required as simply using `instanceof`\n * might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)\n *\n */\nexport function isHTMLElement(element?: unknown): element is HTMLElement {\n const typedElement = element as Node | null | undefined;\n return Boolean(\n typedElement !== null &&\n typedElement?.ownerDocument?.defaultView &&\n typedElement instanceof typedElement.ownerDocument.defaultView.HTMLElement,\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"isInteractiveHTMLElement.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/isInteractiveHTMLElement.ts"],"names":[],"mappings":";;;;IAEA;;;OAGG;IACH,SAAgB,wBAAwB,CAAC,OAAgC;QACvE,IAAI,CAAC,6BAAa,CAAC,OAAO,CAAC,EAAE;YAC3B,OAAO,KAAK,CAAC;SACd;QAEO,IAAA,OAAO,GAAK,OAAO,QAAZ,CAAa;QAC5B,QAAQ,OAAO,EAAE;YACf,KAAK,QAAQ,CAAC;YACd,KAAK,GAAG,CAAC;YACT,KAAK,OAAO,CAAC;YACb,KAAK,UAAU;gBACb,OAAO,IAAI,CAAC;SACf;QAED,OAAO,OAAO,CAAC,iBAAiB,CAAC;IACnC,CAAC;IAfD,4DAeC","sourcesContent":["import { isHTMLElement } from './isHTMLElement';\n\n/**\n * @internal\n * Checks that the element has default behaviour from user input on click or 'Enter'/'Space' keys\n */\nexport function isInteractiveHTMLElement(element: Node | null | undefined) {\n if (!isHTMLElement(element)) {\n return false;\n }\n\n const { tagName } = element;\n switch (tagName) {\n case 'BUTTON':\n case 'A':\n case 'INPUT':\n case 'TEXTAREA':\n return true;\n }\n\n return element.isContentEditable;\n}\n"]}
1
+ {"version":3,"file":"isInteractiveHTMLElement.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/isInteractiveHTMLElement.ts"],"names":[],"mappings":";;;;IAEA;;;OAGG;IACH,SAAgB,wBAAwB,CAAC,OAAgB;QACvD,IAAI,CAAC,6BAAa,CAAC,OAAO,CAAC,EAAE;YAC3B,OAAO,KAAK,CAAC;SACd;QAEO,IAAA,OAAO,GAAK,OAAO,QAAZ,CAAa;QAC5B,QAAQ,OAAO,EAAE;YACf,KAAK,QAAQ,CAAC;YACd,KAAK,GAAG,CAAC;YACT,KAAK,OAAO,CAAC;YACb,KAAK,UAAU;gBACb,OAAO,IAAI,CAAC;SACf;QAED,OAAO,OAAO,CAAC,iBAAiB,CAAC;IACnC,CAAC;IAfD,4DAeC","sourcesContent":["import { isHTMLElement } from './isHTMLElement';\n\n/**\n * @internal\n * Checks that the element has default behaviour from user input on click or 'Enter'/'Space' keys\n */\nexport function isInteractiveHTMLElement(element: unknown) {\n if (!isHTMLElement(element)) {\n return false;\n }\n\n const { tagName } = element;\n switch (tagName) {\n case 'BUTTON':\n case 'A':\n case 'INPUT':\n case 'TEXTAREA':\n return true;\n }\n\n return element.isContentEditable;\n}\n"]}
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getSlots = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
-
10
8
  const omit_1 = /*#__PURE__*/require("../utils/omit");
11
9
  /**
12
10
  * Given the state and an array of slot names, will break out `slots` and `slotProps`
@@ -25,48 +23,38 @@ const omit_1 = /*#__PURE__*/require("../utils/omit");
25
23
  * @param state - State including slot definitions
26
24
  * @returns An object containing the `slots` map and `slotProps` map.
27
25
  */
28
-
29
-
30
26
  function getSlots(state) {
31
27
  const slots = {};
32
28
  const slotProps = {};
33
29
  const slotNames = Object.keys(state.components);
34
-
35
30
  for (const slotName of slotNames) {
36
31
  const [slot, props] = getSlot(state, slotName);
37
32
  slots[slotName] = slot;
38
33
  slotProps[slotName] = props;
39
34
  }
40
-
41
35
  return {
42
36
  slots,
43
37
  slotProps: slotProps
44
38
  };
45
39
  }
46
-
47
40
  exports.getSlots = getSlots;
48
-
49
41
  function getSlot(state, slotName) {
50
42
  var _a, _b, _c;
51
-
52
43
  if (state[slotName] === undefined) {
53
44
  return [null, undefined];
54
45
  }
55
-
56
46
  const {
57
47
  children,
58
48
  as: asProp,
59
49
  ...rest
60
50
  } = state[slotName];
61
51
  const slot = ((_a = state.components) === null || _a === void 0 ? void 0 : _a[slotName]) === undefined || typeof state.components[slotName] === 'string' ? asProp || ((_b = state.components) === null || _b === void 0 ? void 0 : _b[slotName]) || 'div' : state.components[slotName];
62
-
63
52
  if (typeof children === 'function') {
64
53
  const render = children;
65
54
  return [React.Fragment, {
66
55
  children: render(slot, rest)
67
56
  }];
68
57
  }
69
-
70
58
  const shouldOmitAsProp = typeof slot === 'string' && ((_c = state[slotName]) === null || _c === void 0 ? void 0 : _c.as);
71
59
  const slotProps = shouldOmitAsProp ? omit_1.omit(state[slotName], ['as']) : state[slotName];
72
60
  return [slot, slotProps];
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-utilities/src/compose/getSlots.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAEA,MAAA,MAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;AA6BA;;;;;;;;;;;;;;;;AAgBG;;;AACH,SAAgB,QAAhB,CACE,KADF,EAC0B;EAKxB,MAAM,KAAK,GAAG,EAAd;EACA,MAAM,SAAS,GAAG,EAAlB;EAEA,MAAM,SAAS,GAAgB,MAAM,CAAC,IAAP,CAAY,KAAK,CAAC,UAAlB,CAA/B;;EACA,KAAK,MAAM,QAAX,IAAuB,SAAvB,EAAkC;IAChC,MAAM,CAAC,IAAD,EAAO,KAAP,IAAgB,OAAO,CAAC,KAAD,EAAQ,QAAR,CAA7B;IACA,KAAK,CAAC,QAAD,CAAL,GAAkB,IAAlB;IACA,SAAS,CAAC,QAAD,CAAT,GAAsB,KAAtB;EACD;;EACD,OAAO;IAAE,KAAF;IAAS,SAAS,EAAG;EAArB,CAAP;AACD;;AAhBD,OAAA,CAAA,QAAA,GAAA,QAAA;;AAkBA,SAAS,OAAT,CACE,KADF,EAEE,QAFF,EAEa;;;EAEX,IAAI,KAAK,CAAC,QAAD,CAAL,KAAoB,SAAxB,EAAmC;IACjC,OAAO,CAAC,IAAD,EAAO,SAAP,CAAP;EACD;;EACD,MAAM;IAAE,QAAF;IAAY,EAAE,EAAE,MAAhB;IAAwB,GAAG;EAA3B,IAAoC,KAAK,CAAC,QAAD,CAA/C;EAEA,MAAM,IAAI,GAAI,CAAA,CAAA,EAAA,GAAA,KAAK,CAAC,UAAN,MAAgB,IAAhB,IAAgB,EAAA,KAAA,KAAA,CAAhB,GAAgB,KAAA,CAAhB,GAAgB,EAAA,CAAG,QAAH,CAAhB,MAAiC,SAAjC,IAA8C,OAAO,KAAK,CAAC,UAAN,CAAiB,QAAjB,CAAP,KAAsC,QAApF,GACV,MAAM,KAAI,CAAA,EAAA,GAAA,KAAK,CAAC,UAAN,MAAgB,IAAhB,IAAgB,EAAA,KAAA,KAAA,CAAhB,GAAgB,KAAA,CAAhB,GAAgB,EAAA,CAAG,QAAH,CAApB,CAAN,IAA0C,KADhC,GAEV,KAAK,CAAC,UAAN,CAAiB,QAAjB,CAFJ;;EAIA,IAAI,OAAO,QAAP,KAAoB,UAAxB,EAAoC;IAClC,MAAM,MAAM,GAAG,QAAf;IACA,OAAO,CACL,KAAK,CAAC,QADD,EAEJ;MACC,QAAQ,EAAE,MAAM,CAAC,IAAD,EAAO,IAAP;IADjB,CAFI,CAAP;EAMD;;EAED,MAAM,gBAAgB,GAAG,OAAO,IAAP,KAAgB,QAAhB,KAA4B,CAAA,EAAA,GAAA,KAAK,CAAC,QAAD,CAAL,MAAe,IAAf,IAAe,EAAA,KAAA,KAAA,CAAf,GAAe,KAAA,CAAf,GAAe,EAAA,CAAE,EAA7C,CAAzB;EACA,MAAM,SAAS,GAAI,gBAAgB,GAAG,MAAA,CAAA,IAAA,CAAK,KAAK,CAAC,QAAD,CAAV,EAAuB,CAAC,IAAD,CAAvB,CAAH,GAAoC,KAAK,CAAC,QAAD,CAA5E;EAEA,OAAO,CAAC,IAAD,EAAO,SAAP,CAAP;AACD","sourcesContent":["import * as React from 'react';\n\nimport { omit } from '../utils/omit';\nimport type {\n AsIntrinsicElement,\n ComponentState,\n ExtractSlotProps,\n SlotPropsRecord,\n SlotRenderFunction,\n UnionToIntersection,\n} from './types';\n\nexport type Slots<S extends SlotPropsRecord> = {\n [K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // for slots with an `as` prop, the slot will be any one of the possible values of `as`\n As\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? React.ElementType<NonNullable<P>>\n : React.ElementType<ExtractSlotProps<S[K]>>;\n};\n\ntype ObjectSlotProps<S extends SlotPropsRecord> = {\n [K in keyof S]-?: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // For intrinsic element types, return the intersection of all possible\n // element's props, to be compatible with the As type returned by Slots<>\n UnionToIntersection<JSX.IntrinsicElements[As]>\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? P\n : never;\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 * @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: ComponentState<R>,\n): {\n slots: Slots<R>;\n slotProps: ObjectSlotProps<R>;\n} {\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n const slotNames: (keyof R)[] = Object.keys(state.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(state, slotName);\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\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 if (state[slotName] === undefined) {\n return [null, undefined as R[K]];\n }\n const { children, as: asProp, ...rest } = state[slotName]!;\n\n const slot = (state.components?.[slotName] === undefined || typeof state.components[slotName] === 'string'\n ? asProp || state.components?.[slotName] || 'div'\n : state.components[slotName]) as React.ElementType<R[K]>;\n\n if (typeof children === 'function') {\n const render = children as SlotRenderFunction<R[K]>;\n return [\n React.Fragment,\n ({\n children: render(slot, rest as Omit<R[K], 'children' | 'as'>),\n } as unknown) as R[K],\n ];\n }\n\n const shouldOmitAsProp = typeof slot === 'string' && state[slotName]?.as;\n const slotProps = (shouldOmitAsProp ? omit(state[slotName]!, ['as']) : state[slotName]) as R[K];\n\n return [slot, slotProps];\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AAEA;AA6BA;;;;;;;;;;;;;;;;;AAiBA,SAAgBA,QAAQ,CACtBC,KAAwB;EAKxB,MAAMC,KAAK,GAAG,EAAc;EAC5B,MAAMC,SAAS,GAAG,EAAO;EAEzB,MAAMC,SAAS,GAAgBC,MAAM,CAACC,IAAI,CAACL,KAAK,CAACM,UAAU,CAAC;EAC5D,KAAK,MAAMC,QAAQ,IAAIJ,SAAS,EAAE;IAChC,MAAM,CAACK,IAAI,EAAEC,KAAK,CAAC,GAAGC,OAAO,CAACV,KAAK,EAAEO,QAAQ,CAAC;IAC9CN,KAAK,CAACM,QAAQ,CAAC,GAAGC,IAAiC;IACnDN,SAAS,CAACK,QAAQ,CAAC,GAAGE,KAAK;;EAE7B,OAAO;IAAER,KAAK;IAAEC,SAAS,EAAGA;EAA2C,CAAE;AAC3E;AAhBAS;AAkBA,SAASD,OAAO,CACdV,KAAwB,EACxBO,QAAW;;EAEX,IAAIP,KAAK,CAACO,QAAQ,CAAC,KAAKK,SAAS,EAAE;IACjC,OAAO,CAAC,IAAI,EAAEA,SAAiB,CAAC;;EAElC,MAAM;IAAEC,QAAQ;IAAEC,EAAE,EAAEC,MAAM;IAAE,GAAGC;EAAI,CAAE,GAAGhB,KAAK,CAACO,QAAQ,CAAE;EAE1D,MAAMC,IAAI,GAAI,YAAK,CAACF,UAAU,0CAAGC,QAAQ,CAAC,MAAKK,SAAS,IAAI,OAAOZ,KAAK,CAACM,UAAU,CAACC,QAAQ,CAAC,KAAK,QAAQ,GACtGQ,MAAM,KAAI,WAAK,CAACT,UAAU,0CAAGC,QAAQ,CAAC,KAAI,KAAK,GAC/CP,KAAK,CAACM,UAAU,CAACC,QAAQ,CAA6B;EAE1D,IAAI,OAAOM,QAAQ,KAAK,UAAU,EAAE;IAClC,MAAMI,MAAM,GAAGJ,QAAoC;IACnD,OAAO,CACLK,KAAK,CAACC,QAAQ,EACb;MACCN,QAAQ,EAAEI,MAAM,CAACT,IAAI,EAAEQ,IAAqC;KACzC,CACtB;;EAGH,MAAMI,gBAAgB,GAAG,OAAOZ,IAAI,KAAK,QAAQ,KAAI,WAAK,CAACD,QAAQ,CAAC,0CAAEO,EAAE;EACxE,MAAMZ,SAAS,GAAIkB,gBAAgB,GAAGC,WAAI,CAACrB,KAAK,CAACO,QAAQ,CAAE,EAAE,CAAC,IAAI,CAAC,CAAC,GAAGP,KAAK,CAACO,QAAQ,CAAU;EAE/F,OAAO,CAACC,IAAI,EAAEN,SAAS,CAAC;AAC1B","names":["getSlots","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","exports","undefined","children","as","asProp","rest","render","React","Fragment","shouldOmitAsProp","omit_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/compose/getSlots.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { omit } from '../utils/omit';\nimport type {\n AsIntrinsicElement,\n ComponentState,\n ExtractSlotProps,\n SlotPropsRecord,\n SlotRenderFunction,\n UnionToIntersection,\n} from './types';\n\nexport type Slots<S extends SlotPropsRecord> = {\n [K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // for slots with an `as` prop, the slot will be any one of the possible values of `as`\n As\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? React.ElementType<NonNullable<P>>\n : React.ElementType<ExtractSlotProps<S[K]>>;\n};\n\ntype ObjectSlotProps<S extends SlotPropsRecord> = {\n [K in keyof S]-?: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // For intrinsic element types, return the intersection of all possible\n // element's props, to be compatible with the As type returned by Slots<>\n UnionToIntersection<JSX.IntrinsicElements[As]>\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? P\n : never;\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 * @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: ComponentState<R>,\n): {\n slots: Slots<R>;\n slotProps: ObjectSlotProps<R>;\n} {\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n const slotNames: (keyof R)[] = Object.keys(state.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(state, slotName);\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\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 if (state[slotName] === undefined) {\n return [null, undefined as R[K]];\n }\n const { children, as: asProp, ...rest } = state[slotName]!;\n\n const slot = (state.components?.[slotName] === undefined || typeof state.components[slotName] === 'string'\n ? asProp || state.components?.[slotName] || 'div'\n : state.components[slotName]) as React.ElementType<R[K]>;\n\n if (typeof children === 'function') {\n const render = children as SlotRenderFunction<R[K]>;\n return [\n React.Fragment,\n ({\n children: render(slot, rest as Omit<R[K], 'children' | 'as'>),\n } as unknown) as R[K],\n ];\n }\n\n const shouldOmitAsProp = typeof slot === 'string' && state[slotName]?.as;\n const slotProps = (shouldOmitAsProp ? omit(state[slotName]!, ['as']) : state[slotName]) as R[K];\n\n return [slot, slotProps];\n}\n"]}
@@ -3,14 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  const tslib_1 = /*#__PURE__*/require("tslib");
8
-
9
7
  tslib_1.__exportStar(require("./getSlots"), exports);
10
-
11
8
  tslib_1.__exportStar(require("./resolveShorthand"), exports);
12
-
13
9
  tslib_1.__exportStar(require("./types"), exports);
14
-
15
10
  tslib_1.__exportStar(require("./isResolvedShorthand"), exports);
16
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-utilities/src/compose/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,uBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './getSlots';\nexport * from './resolveShorthand';\nexport * from './types';\nexport * from './isResolvedShorthand';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/compose/index.ts"],"sourcesContent":["export * from './getSlots';\nexport * from './resolveShorthand';\nexport * from './types';\nexport * from './isResolvedShorthand';\n"]}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isResolvedShorthand = void 0;
7
-
8
7
  const react_1 = /*#__PURE__*/require("react");
9
8
  /**
10
9
  * Guard method that validates if a shorthand is a slot
@@ -36,11 +35,8 @@ const react_1 = /*#__PURE__*/require("react");
36
35
  * })
37
36
  * ```
38
37
  */
39
-
40
-
41
38
  function isResolvedShorthand(shorthand) {
42
39
  return shorthand !== null && typeof shorthand === 'object' && !Array.isArray(shorthand) && !react_1.isValidElement(shorthand);
43
40
  }
44
-
45
41
  exports.isResolvedShorthand = isResolvedShorthand;
46
42
  //# sourceMappingURL=isResolvedShorthand.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-utilities/src/compose/isResolvedShorthand.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,OAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;;;AACH,SAAgB,mBAAhB,CACE,SADF,EACuB;EAErB,OAAO,SAAS,KAAK,IAAd,IAAsB,OAAO,SAAP,KAAqB,QAA3C,IAAuD,CAAC,KAAK,CAAC,OAAN,CAAc,SAAd,CAAxD,IAAoF,CAAC,OAAA,CAAA,cAAA,CAAe,SAAf,CAA5F;AACD;;AAJD,OAAA,CAAA,mBAAA,GAAA,mBAAA","sourcesContent":["import { isValidElement } 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 shorthand !== null && typeof shorthand === 'object' && !Array.isArray(shorthand) && !isValidElement(shorthand);\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgBA,mBAAmB,CACjCC,SAAqB;EAErB,OAAOA,SAAS,KAAK,IAAI,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,SAAS,CAAC,IAAI,CAACG,sBAAc,CAACH,SAAS,CAAC;AACvH;AAJAI","names":["isResolvedShorthand","shorthand","Array","isArray","react_1","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/compose/isResolvedShorthand.ts"],"sourcesContent":["import { isValidElement } 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 shorthand !== null && typeof shorthand === 'object' && !Array.isArray(shorthand) && !isValidElement(shorthand);\n}\n"]}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.resolveShorthand = void 0;
7
-
8
7
  const react_1 = /*#__PURE__*/require("react");
9
8
  /**
10
9
  * Resolves shorthands into slot props, to ensure normalization of the signature
@@ -12,30 +11,24 @@ const react_1 = /*#__PURE__*/require("react");
12
11
  * @param value - the base shorthand props
13
12
  * @param options - options to resolve shorthand props
14
13
  */
15
-
16
-
17
14
  const resolveShorthand = (value, options) => {
18
15
  const {
19
16
  required = false,
20
17
  defaultProps
21
18
  } = options || {};
22
-
23
19
  if (value === null || value === undefined && !required) {
24
20
  return undefined;
25
21
  }
26
-
27
22
  let resolvedShorthand = {};
28
-
29
23
  if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || react_1.isValidElement(value)) {
30
24
  resolvedShorthand.children = value;
31
25
  } else if (typeof value === 'object') {
32
26
  resolvedShorthand = value;
33
27
  }
34
-
35
- return defaultProps ? { ...defaultProps,
28
+ return defaultProps ? {
29
+ ...defaultProps,
36
30
  ...resolvedShorthand
37
31
  } : resolvedShorthand;
38
32
  };
39
-
40
33
  exports.resolveShorthand = resolveShorthand;
41
34
  //# sourceMappingURL=resolveShorthand.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-utilities/src/compose/resolveShorthand.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,OAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAkBA;;;;;AAKG;;;AACI,MAAM,gBAAgB,GAA6B,CAAC,KAAD,EAAQ,OAAR,KAAmB;EAC3E,MAAM;IAAE,QAAQ,GAAG,KAAb;IAAoB;EAApB,IAAqC,OAAO,IAAI,EAAtD;;EACA,IAAI,KAAK,KAAK,IAAV,IAAmB,KAAK,KAAK,SAAV,IAAuB,CAAC,QAA/C,EAA0D;IACxD,OAAO,SAAP;EACD;;EAED,IAAI,iBAAiB,GAAG,EAAxB;;EAEA,IAAI,OAAO,KAAP,KAAiB,QAAjB,IAA6B,OAAO,KAAP,KAAiB,QAA9C,IAA0D,KAAK,CAAC,OAAN,CAAc,KAAd,CAA1D,IAAkF,OAAA,CAAA,cAAA,CAAe,KAAf,CAAtF,EAA6G;IAC3G,iBAAiB,CAAC,QAAlB,GAA6B,KAA7B;EACD,CAFD,MAEO,IAAI,OAAO,KAAP,KAAiB,QAArB,EAA+B;IACpC,iBAAiB,GAAG,KAApB;EACD;;EAED,OAAO,YAAY,GAAG,EAAE,GAAG,YAAL;IAAmB,GAAG;EAAtB,CAAH,GAA+C,iBAAlE;AACD,CAfM;;AAAM,OAAA,CAAA,gBAAA,GAAgB,gBAAhB","sourcesContent":["import { isValidElement } from 'react';\nimport type { ReplaceNullWithUndefined, SlotShorthandValue, UnknownSlotProps } from './types';\n\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = {\n required?: Required;\n defaultProps?: Props;\n};\n\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n <P extends Props | null>(\n value: P | SlotShorthandValue | undefined,\n options?: ResolveShorthandOptions<P, true>,\n ): ReplaceNullWithUndefined<P>;\n <P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | ReplaceNullWithUndefined<P>\n | undefined;\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 */\nexport const resolveShorthand: ResolveShorthandFunction = (value, options) => {\n const { required = false, defaultProps } = options || {};\n if (value === null || (value === undefined && !required)) {\n return undefined;\n }\n\n let resolvedShorthand = {} as UnknownSlotProps;\n\n if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || isValidElement(value)) {\n resolvedShorthand.children = value;\n } else if (typeof value === 'object') {\n resolvedShorthand = value;\n }\n\n return defaultProps ? { ...defaultProps, ...resolvedShorthand } : resolvedShorthand;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AAkBA;;;;;;AAMO,MAAMA,gBAAgB,GAA6B,CAACC,KAAK,EAAEC,OAAO,KAAI;EAC3E,MAAM;IAAEC,QAAQ,GAAG,KAAK;IAAEC;EAAY,CAAE,GAAGF,OAAO,IAAI,EAAE;EACxD,IAAID,KAAK,KAAK,IAAI,IAAKA,KAAK,KAAKI,SAAS,IAAI,CAACF,QAAS,EAAE;IACxD,OAAOE,SAAS;;EAGlB,IAAIC,iBAAiB,GAAG,EAAsB;EAE9C,IAAI,OAAOL,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIM,KAAK,CAACC,OAAO,CAACP,KAAK,CAAC,IAAIQ,sBAAc,CAACR,KAAK,CAAC,EAAE;IAC3GK,iBAAiB,CAACI,QAAQ,GAAGT,KAAK;GACnC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACpCK,iBAAiB,GAAGL,KAAK;;EAG3B,OAAOG,YAAY,GAAG;IAAE,GAAGA,YAAY;IAAE,GAAGE;EAAiB,CAAE,GAAGA,iBAAiB;AACrF,CAAC;AAfYK,wBAAgB","names":["resolveShorthand","value","options","required","defaultProps","undefined","resolvedShorthand","Array","isArray","react_1","children","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/compose/resolveShorthand.ts"],"sourcesContent":["import { isValidElement } from 'react';\nimport type { ReplaceNullWithUndefined, SlotShorthandValue, UnknownSlotProps } from './types';\n\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = {\n required?: Required;\n defaultProps?: Props;\n};\n\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n <P extends Props | null>(\n value: P | SlotShorthandValue | undefined,\n options?: ResolveShorthandOptions<P, true>,\n ): ReplaceNullWithUndefined<P>;\n <P extends Props | null>(value: P | SlotShorthandValue | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | ReplaceNullWithUndefined<P>\n | undefined;\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 */\nexport const resolveShorthand: ResolveShorthandFunction = (value, options) => {\n const { required = false, defaultProps } = options || {};\n if (value === null || (value === undefined && !required)) {\n return undefined;\n }\n\n let resolvedShorthand = {} as UnknownSlotProps;\n\n if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || isValidElement(value)) {\n resolvedShorthand.children = value;\n } else if (typeof value === 'object') {\n resolvedShorthand = value;\n }\n\n return defaultProps ? { ...defaultProps, ...resolvedShorthand } : resolvedShorthand;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
1
+ {"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
@@ -3,28 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  const tslib_1 = /*#__PURE__*/require("tslib");
8
-
9
7
  tslib_1.__exportStar(require("./useControllableState"), exports);
10
-
11
8
  tslib_1.__exportStar(require("./useEventCallback"), exports);
12
-
13
9
  tslib_1.__exportStar(require("./useFirstMount"), exports);
14
-
15
10
  tslib_1.__exportStar(require("./useForceUpdate"), exports);
16
-
17
11
  tslib_1.__exportStar(require("./useId"), exports);
18
-
19
12
  tslib_1.__exportStar(require("./useIsomorphicLayoutEffect"), exports);
20
-
21
13
  tslib_1.__exportStar(require("./useMergedRefs"), exports);
22
-
23
14
  tslib_1.__exportStar(require("./useOnClickOutside"), exports);
24
-
25
15
  tslib_1.__exportStar(require("./useOnScrollOutside"), exports);
26
-
27
16
  tslib_1.__exportStar(require("./usePrevious"), exports);
28
-
17
+ tslib_1.__exportStar(require("./useScrollbarWidth"), exports);
29
18
  tslib_1.__exportStar(require("./useTimeout"), exports);
30
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-utilities/src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,6BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,sBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,cAAA,CAAA,EAAA,OAAA","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 './useTimeout';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["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"]}
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useControllableState = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
-
10
8
  function isFactoryDispatch(newState) {
11
9
  return typeof newState === 'function';
12
10
  }
@@ -26,8 +24,6 @@ function isFactoryDispatch(newState) {
26
24
  * to the updater function will only be respected if the component is uncontrolled.
27
25
  * @see https://reactjs.org/docs/uncontrolled-components.html
28
26
  */
29
-
30
-
31
27
  const useControllableState = options => {
32
28
  const isControlled = useIsControlled(options.state);
33
29
  const initialState = typeof options.defaultState === 'undefined' ? options.initialState : options.defaultState;
@@ -36,9 +32,9 @@ const useControllableState = options => {
36
32
  const stateRef = React.useRef(state);
37
33
  React.useEffect(() => {
38
34
  stateRef.current = state;
39
- }, [state]); // To match the behavior of the setter returned by React.useState, this callback's identity
35
+ }, [state]);
36
+ // To match the behavior of the setter returned by React.useState, this callback's identity
40
37
  // should never change. This means it MUST NOT directly reference variables that can change.
41
-
42
38
  const setState = React.useCallback(newState => {
43
39
  // React dispatch can use a factory
44
40
  // https://reactjs.org/docs/hooks-reference.html#functional-updates
@@ -47,22 +43,18 @@ const useControllableState = options => {
47
43
  } else {
48
44
  stateRef.current = newState;
49
45
  }
50
-
51
46
  setInternalState(stateRef.current);
52
47
  }, []);
53
48
  return [state, setState];
54
49
  };
55
-
56
50
  exports.useControllableState = useControllableState;
57
51
  /**
58
52
  * Helper hook to handle previous comparison of controlled/uncontrolled
59
53
  * Prints an error when isControlled value switches between subsequent renders
60
54
  * @returns - whether the value is controlled
61
55
  */
62
-
63
56
  const useIsControlled = controlledValue => {
64
57
  const [isControlled] = React.useState(() => controlledValue !== undefined);
65
-
66
58
  if (process.env.NODE_ENV !== 'production') {
67
59
  // We don't want these warnings in production even though it is against native behaviour
68
60
  // eslint-disable-next-line react-hooks/rules-of-hooks
@@ -70,14 +62,14 @@ const useIsControlled = controlledValue => {
70
62
  if (isControlled !== (controlledValue !== undefined)) {
71
63
  const error = new Error();
72
64
  const controlWarning = isControlled ? 'a controlled value to be uncontrolled' : 'an uncontrolled value to be controlled';
73
- const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined'; // eslint-disable-next-line no-console
74
-
75
- console.error([// Default react error
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
76
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(' '));
77
70
  }
78
71
  }, [isControlled, controlledValue]);
79
72
  }
80
-
81
73
  return isControlled;
82
74
  };
83
75
  //# sourceMappingURL=useControllableState.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-utilities/src/hooks/useControllableState.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAqBA,SAAS,iBAAT,CAAkC,QAAlC,EAAuE;EACrE,OAAO,OAAO,QAAP,KAAoB,UAA3B;AACD;AAED;;;;;;;;;;;;;;;AAeG;;;AACI,MAAM,oBAAoB,GAC/B,OADkC,IAEsB;EACxD,MAAM,YAAY,GAAG,eAAe,CAAC,OAAO,CAAC,KAAT,CAApC;EACA,MAAM,YAAY,GAAG,OAAO,OAAO,CAAC,YAAf,KAAgC,WAAhC,GAA8C,OAAO,CAAC,YAAtD,GAAqE,OAAO,CAAC,YAAlG;EACA,MAAM,CAAC,aAAD,EAAgB,gBAAhB,IAAoC,KAAK,CAAC,QAAN,CAAsB,YAAtB,CAA1C;EAEA,MAAM,KAAK,GAAG,YAAY,GAAI,OAAO,CAAC,KAAZ,GAA8B,aAAxD;EAEA,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAN,CAAa,KAAb,CAAjB;EACA,KAAK,CAAC,SAAN,CAAgB,MAAK;IACnB,QAAQ,CAAC,OAAT,GAAmB,KAAnB;EACD,CAFD,EAEG,CAAC,KAAD,CAFH,EARwD,CAYxD;EACA;;EACA,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAN,CAAmB,QAAD,IAA0C;IAC3E;IACA;IACA,IAAI,iBAAiB,CAAC,QAAD,CAArB,EAAiC;MAC/B,QAAQ,CAAC,OAAT,GAAmB,QAAQ,CAAC,QAAQ,CAAC,OAAV,CAA3B;IACD,CAFD,MAEO;MACL,QAAQ,CAAC,OAAT,GAAmB,QAAnB;IACD;;IAED,gBAAgB,CAAC,QAAQ,CAAC,OAAV,CAAhB;EACD,CAVgB,EAUd,EAVc,CAAjB;EAYA,OAAO,CAAC,KAAD,EAAQ,QAAR,CAAP;AACD,CA7BM;;AAAM,OAAA,CAAA,oBAAA,GAAoB,oBAApB;AA+Bb;;;;AAIG;;AACH,MAAM,eAAe,GAAI,eAAD,IAA6B;EACnD,MAAM,CAAC,YAAD,IAAiB,KAAK,CAAC,QAAN,CAAwB,MAAM,eAAe,KAAK,SAAlD,CAAvB;;EAEA,IAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;IACzC;IACA;IACA,KAAK,CAAC,SAAN,CAAgB,MAAK;MACnB,IAAI,YAAY,MAAM,eAAe,KAAK,SAA1B,CAAhB,EAAsD;QACpD,MAAM,KAAK,GAAG,IAAI,KAAJ,EAAd;QAEA,MAAM,cAAc,GAAG,YAAY,GAC/B,uCAD+B,GAE/B,wCAFJ;QAIA,MAAM,gBAAgB,GAAG,YAAY,GAAG,yBAAH,GAA+B,wBAApE,CAPoD,CASpD;;QACA,OAAO,CAAC,KAAR,CACE,CACE;QACA,6BAA6B,cAA7B,GAA8C,sCAFhD,EAGE,mBAAmB,gBAAnB,GAAsC,kCAHxC,EAIE,oGAJF,EAKE,2DALF,EAME,KAAK,CAAC,KANR,EAOE,IAPF,CAOO,GAPP,CADF;MAUD;IACF,CAtBD,EAsBG,CAAC,YAAD,EAAe,eAAf,CAtBH;EAuBD;;EAED,OAAO,YAAP;AACD,CAhCD","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"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AAqBA,SAASA,iBAAiB,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,GAAGC,KAAK,CAACC,QAAQ,CAAQL,YAAY,CAAC;EAE7E,MAAMD,KAAK,GAAGF,YAAY,GAAID,OAAO,CAACG,KAAe,GAAGG,aAAa;EAErE,MAAMI,QAAQ,GAAGF,KAAK,CAACG,MAAM,CAACR,KAAK,CAAC;EACpCK,KAAK,CAACI,SAAS,CAAC,MAAK;IACnBF,QAAQ,CAACG,OAAO,GAAGV,KAAK;EAC1B,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX;EACA;EACA,MAAMW,QAAQ,GAAGN,KAAK,CAACO,WAAW,CAAEjB,QAAqC,IAAI;IAC3E;IACA;IACA,IAAID,iBAAiB,CAACC,QAAQ,CAAC,EAAE;MAC/BY,QAAQ,CAACG,OAAO,GAAGf,QAAQ,CAACY,QAAQ,CAACG,OAAO,CAAC;KAC9C,MAAM;MACLH,QAAQ,CAACG,OAAO,GAAGf,QAAQ;;IAG7BS,gBAAgB,CAACG,QAAQ,CAACG,OAAO,CAAC;EACpC,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO,CAACV,KAAK,EAAEW,QAAQ,CAAC;AAC1B,CAAC;AA7BYE,4BAAoB;AA+BjC;;;;;AAKA,MAAMd,eAAe,GAAIe,eAAwB,IAAI;EACnD,MAAM,CAAChB,YAAY,CAAC,GAAGO,KAAK,CAACC,QAAQ,CAAU,MAAMQ,eAAe,KAAKC,SAAS,CAAC;EAEnF,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC;IACA;IACAb,KAAK,CAACI,SAAS,CAAC,MAAK;MACnB,IAAIX,YAAY,MAAMgB,eAAe,KAAKC,SAAS,CAAC,EAAE;QACpD,MAAMI,KAAK,GAAG,IAAIC,KAAK,EAAE;QAEzB,MAAMC,cAAc,GAAGvB,YAAY,GAC/B,uCAAuC,GACvC,wCAAwC;QAE5C,MAAMwB,gBAAgB,GAAGxB,YAAY,GAAG,yBAAyB,GAAG,wBAAwB;QAE5F;QACAyB,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,CAAC3B,YAAY,EAAEgB,eAAe,CAAC,CAAC;;EAGrC,OAAOhB,YAAY;AACrB,CAAC","names":["isFactoryDispatch","newState","useControllableState","options","isControlled","useIsControlled","state","initialState","defaultState","internalState","setInternalState","React","useState","stateRef","useRef","useEffect","current","setState","useCallback","exports","controlledValue","undefined","process","env","NODE_ENV","error","Error","controlWarning","undefinedWarning","console","stack","join"],"sourceRoot":"../src/","sources":["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"]}
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useEventCallback = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
-
10
8
  const useIsomorphicLayoutEffect_1 = /*#__PURE__*/require("./useIsomorphicLayoutEffect");
11
9
  /**
12
10
  * @internal
@@ -21,8 +19,6 @@ const useIsomorphicLayoutEffect_1 = /*#__PURE__*/require("./useIsomorphicLayoutE
21
19
  *
22
20
  * @param fn - The callback function that will be used
23
21
  */
24
-
25
-
26
22
  const useEventCallback = fn => {
27
23
  const callbackRef = React.useRef(() => {
28
24
  throw new Error('Cannot call an event handler while rendering');
@@ -35,6 +31,5 @@ const useEventCallback = fn => {
35
31
  return callback(...args);
36
32
  }, [callbackRef]);
37
33
  };
38
-
39
34
  exports.useEventCallback = useEventCallback;
40
35
  //# sourceMappingURL=useEventCallback.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-utilities/src/hooks/useEventCallback.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,2BAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;AAEA;;;;;;;;;;;;AAYG;;;AACI,MAAM,gBAAgB,GAAoC,EAAjC,IAAkE;EAChG,MAAM,WAAW,GAAG,KAAK,CAAC,MAAN,CAAwB,MAAK;IAC/C,MAAM,IAAI,KAAJ,CAAU,8CAAV,CAAN;EACD,CAFmB,CAApB;EAIA,2BAAA,CAAA,yBAAA,CAA0B,MAAK;IAC7B,WAAW,CAAC,OAAZ,GAAsB,EAAtB;EACD,CAFD,EAEG,CAAC,EAAD,CAFH;EAIA,OAAO,KAAK,CAAC,WAAN,CACL,CAAC,GAAG,IAAJ,KAAkB;IAChB,MAAM,QAAQ,GAAG,WAAW,CAAC,OAA7B;IACA,OAAO,QAAQ,CAAC,GAAG,IAAJ,CAAf;EACD,CAJI,EAKL,CAAC,WAAD,CALK,CAAP;AAOD,CAhBM;;AAAM,OAAA,CAAA,gBAAA,GAAgB,gBAAhB","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"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AACA;AAEA;;;;;;;;;;;;;AAaO,MAAMA,gBAAgB,GAAoCC,EAA6B,IAAI;EAChG,MAAMC,WAAW,GAAGC,KAAK,CAACC,MAAM,CAAY,MAAK;IAC/C,MAAM,IAAIC,KAAK,CAAC,8CAA8C,CAAC;EACjE,CAAC,CAAC;EAEFC,qDAAyB,CAAC,MAAK;IAC7BJ,WAAW,CAACK,OAAO,GAAGN,EAAE;EAC1B,CAAC,EAAE,CAACA,EAAE,CAAC,CAAC;EAER,OAAOE,KAAK,CAACK,WAAW,CACtB,CAAC,GAAGC,IAAU,KAAI;IAChB,MAAMC,QAAQ,GAAGR,WAAW,CAACK,OAAO;IACpC,OAAOG,QAAQ,CAAC,GAAGD,IAAI,CAAC;EAC1B,CAAC,EACD,CAACP,WAAW,CAAC,CACd;AACH,CAAC;AAhBYS,wBAAgB","names":["useEventCallback","fn","callbackRef","React","useRef","Error","useIsomorphicLayoutEffect_1","current","useCallback","args","callback","exports"],"sourceRoot":"../src/","sources":["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"]}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useFirstMount = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
8
  /**
10
9
  * @internal
@@ -17,18 +16,13 @@ const React = /*#__PURE__*/require("react");
17
16
  * @example
18
17
  * const isFirstMount = useFirstMount();
19
18
  */
20
-
21
-
22
19
  function useFirstMount() {
23
20
  const isFirst = React.useRef(true);
24
-
25
21
  if (isFirst.current) {
26
22
  isFirst.current = false;
27
23
  return true;
28
24
  }
29
-
30
25
  return isFirst.current;
31
26
  }
32
-
33
27
  exports.useFirstMount = useFirstMount;
34
28
  //# sourceMappingURL=useFirstMount.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-utilities/src/hooks/useFirstMount.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAEA;;;;;;;;;;AAUG;;;AACH,SAAgB,aAAhB,GAA6B;EAC3B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAN,CAAa,IAAb,CAAhB;;EAEA,IAAI,OAAO,CAAC,OAAZ,EAAqB;IACnB,OAAO,CAAC,OAAR,GAAkB,KAAlB;IACA,OAAO,IAAP;EACD;;EAED,OAAO,OAAO,CAAC,OAAf;AACD;;AATD,OAAA,CAAA,aAAA,GAAA,aAAA","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"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AAEA;;;;;;;;;;;AAWA,SAAgBA,aAAa;EAC3B,MAAMC,OAAO,GAAGC,KAAK,CAACC,MAAM,CAAC,IAAI,CAAC;EAElC,IAAIF,OAAO,CAACG,OAAO,EAAE;IACnBH,OAAO,CAACG,OAAO,GAAG,KAAK;IACvB,OAAO,IAAI;;EAGb,OAAOH,OAAO,CAACG,OAAO;AACxB;AATAC","names":["useFirstMount","isFirst","React","useRef","current","exports"],"sourceRoot":"../src/","sources":["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"]}
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useForceUpdate = void 0;
7
-
8
7
  const react_1 = /*#__PURE__*/require("react");
9
8
  /**
10
9
  * @internal
11
10
  * Forces a re-render, similar to `forceUpdate` in class components.
12
11
  */
13
-
14
-
15
12
  function useForceUpdate() {
16
13
  return react_1.useReducer(x => x + 1, 0)[1];
17
14
  }
18
-
19
15
  exports.useForceUpdate = useForceUpdate;
20
16
  //# sourceMappingURL=useForceUpdate.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-utilities/src/hooks/useForceUpdate.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,OAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAEA;;;AAGG;;;AACH,SAAgB,cAAhB,GAA8B;EAC5B,OAAO,OAAA,CAAA,UAAA,CAAW,CAAC,IAAI,CAAC,GAAG,CAApB,EAAuB,CAAvB,EAA0B,CAA1B,CAAP;AACD;;AAFD,OAAA,CAAA,cAAA,GAAA,cAAA","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"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AAEA;;;;AAIA,SAAgBA,cAAc;EAC5B,OAAOC,kBAAU,CAACC,CAAC,IAAIA,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC;AAFAC","names":["useForceUpdate","react_1","x","exports"],"sourceRoot":"../src/","sources":["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"]}
@@ -4,19 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useId = exports.resetIdsForTests = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
-
10
8
  const index_1 = /*#__PURE__*/require("../ssr/index");
11
9
  /**
12
10
  * Resets generated IDs, should be used only in tests.
13
11
  */
14
-
15
-
16
12
  function resetIdsForTests() {
17
13
  index_1.defaultSSRContextValue.current = 0;
18
14
  }
19
-
20
15
  exports.resetIdsForTests = resetIdsForTests;
21
16
  /**
22
17
  * Hook to generate a unique ID.
@@ -26,17 +21,14 @@ exports.resetIdsForTests = resetIdsForTests;
26
21
  * without conditioning the hook call
27
22
  * @returns The ID
28
23
  */
29
-
30
24
  function useId(prefix = 'fui-', providedId) {
31
25
  const contextValue = index_1.useSSRContext();
32
26
  return React.useMemo(() => {
33
27
  if (providedId) {
34
28
  return providedId;
35
29
  }
36
-
37
30
  return `${prefix}${++contextValue.current}`;
38
31
  }, [prefix, providedId, contextValue]);
39
32
  }
40
-
41
33
  exports.useId = useId;
42
34
  //# sourceMappingURL=useId.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-utilities/src/hooks/useId.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;AAEA;;AAEG;;;AACH,SAAgB,gBAAhB,GAAgC;EAC9B,OAAA,CAAA,sBAAA,CAAuB,OAAvB,GAAiC,CAAjC;AACD;;AAFD,OAAA,CAAA,gBAAA,GAAA,gBAAA;AAIA;;;;;;;AAOG;;AACH,SAAgB,KAAhB,CAAsB,MAAA,GAAiB,MAAvC,EAA+C,UAA/C,EAAkE;EAChE,MAAM,YAAY,GAAG,OAAA,CAAA,aAAA,EAArB;EAEA,OAAO,KAAK,CAAC,OAAN,CAAc,MAAK;IACxB,IAAI,UAAJ,EAAgB;MACd,OAAO,UAAP;IACD;;IAED,OAAO,GAAG,MAAM,GAAG,EAAE,YAAY,CAAC,OAAO,EAAzC;EACD,CANM,EAMJ,CAAC,MAAD,EAAS,UAAT,EAAqB,YAArB,CANI,CAAP;AAOD;;AAVD,OAAA,CAAA,KAAA,GAAA,KAAA","sourcesContent":["import * as React from 'react';\nimport { defaultSSRContextValue, useSSRContext } from '../ssr/index';\n\n/**\n * Resets generated IDs, should be used only in tests.\n */\nexport function resetIdsForTests(): void {\n defaultSSRContextValue.current = 0;\n}\n\n/**\n * Hook to generate a unique ID.\n *\n * @param prefix - Optional prefix for the ID. Defaults to 'fui-'.\n * @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,\n * without conditioning the hook call\n * @returns The ID\n */\nexport function useId(prefix: string = 'fui-', providedId?: string): string {\n const contextValue = useSSRContext();\n\n return React.useMemo(() => {\n if (providedId) {\n return providedId;\n }\n\n return `${prefix}${++contextValue.current}`;\n }, [prefix, providedId, contextValue]);\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AACA;AAEA;;;AAGA,SAAgBA,gBAAgB;EAC9BC,8BAAsB,CAACC,OAAO,GAAG,CAAC;AACpC;AAFAC;AAIA;;;;;;;;AAQA,SAAgBC,KAAK,CAACC,SAAiB,MAAM,EAAEC,UAAmB;EAChE,MAAMC,YAAY,GAAGN,qBAAa,EAAE;EAEpC,OAAOO,KAAK,CAACC,OAAO,CAAC,MAAK;IACxB,IAAIH,UAAU,EAAE;MACd,OAAOA,UAAU;;IAGnB,OAAO,GAAGD,MAAM,GAAG,EAAEE,YAAY,CAACL,OAAO,EAAE;EAC7C,CAAC,EAAE,CAACG,MAAM,EAAEC,UAAU,EAAEC,YAAY,CAAC,CAAC;AACxC;AAVAJ","names":["resetIdsForTests","index_1","current","exports","useId","prefix","providedId","contextValue","React","useMemo"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/hooks/useId.ts"],"sourcesContent":["import * as React from 'react';\nimport { defaultSSRContextValue, useSSRContext } from '../ssr/index';\n\n/**\n * Resets generated IDs, should be used only in tests.\n */\nexport function resetIdsForTests(): void {\n defaultSSRContextValue.current = 0;\n}\n\n/**\n * Hook to generate a unique ID.\n *\n * @param prefix - Optional prefix for the ID. Defaults to 'fui-'.\n * @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,\n * without conditioning the hook call\n * @returns The ID\n */\nexport function useId(prefix: string = 'fui-', providedId?: string): string {\n const contextValue = useSSRContext();\n\n return React.useMemo(() => {\n if (providedId) {\n return providedId;\n }\n\n return `${prefix}${++contextValue.current}`;\n }, [prefix, providedId, contextValue]);\n}\n"]}
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useIsomorphicLayoutEffect = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
-
10
8
  const index_1 = /*#__PURE__*/require("../ssr/index");
11
9
  /**
12
10
  * React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally
@@ -18,7 +16,5 @@ const index_1 = /*#__PURE__*/require("../ssr/index");
18
16
  * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
19
17
  */
20
18
  // eslint-disable-next-line no-restricted-properties
21
-
22
-
23
19
  exports.useIsomorphicLayoutEffect = /*#__PURE__*/index_1.canUseDOM() ? React.useLayoutEffect : React.useEffect;
24
20
  //# sourceMappingURL=useIsomorphicLayoutEffect.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-utilities/src/hooks/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;AAEA;;;;;;;;AAQG;AACH;;;AACa,OAAA,CAAA,yBAAA,GAAoD,aAAA,OAAA,CAAA,SAAA,KAAc,KAAK,CAAC,eAApB,GAAsC,KAAK,CAAC,SAAhG","sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '../ssr/index';\n\n/**\n * React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally\n * useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to\n * ensure we don't get a render flash for certain operations, but we may also need affected components to render on\n * the server.\n *\n * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85\n * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js\n */\n// eslint-disable-next-line no-restricted-properties\nexport const useIsomorphicLayoutEffect: typeof React.useEffect = canUseDOM() ? React.useLayoutEffect : React.useEffect;\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AACA;AAEA;;;;;;;;;AASA;AACaA,iCAAyB,GAA2B,8BAAS,EAAE,GAAGC,KAAK,CAACC,eAAe,GAAGD,KAAK,CAACE,SAAS","names":["exports","React","useLayoutEffect","useEffect"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/hooks/useIsomorphicLayoutEffect.ts"],"sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '../ssr/index';\n\n/**\n * React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally\n * useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to\n * ensure we don't get a render flash for certain operations, but we may also need affected components to render on\n * the server.\n *\n * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85\n * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js\n */\n// eslint-disable-next-line no-restricted-properties\nexport const useIsomorphicLayoutEffect: typeof React.useEffect = canUseDOM() ? React.useLayoutEffect : React.useEffect;\n"]}