@fluentui/react-utilities 0.0.0-nightly-20221228-0425.1 → 0.0.0-nightly-20221229-0425.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/CHANGELOG.json +5 -5
  2. package/CHANGELOG.md +5 -5
  3. package/lib/compose/getSlots.js +0 -8
  4. package/lib/compose/getSlots.js.map +1 -1
  5. package/lib/compose/isResolvedShorthand.js +0 -1
  6. package/lib/compose/isResolvedShorthand.js.map +1 -1
  7. package/lib/compose/resolveShorthand.js +2 -6
  8. package/lib/compose/resolveShorthand.js.map +1 -1
  9. package/lib/hooks/useControllableState.js +6 -12
  10. package/lib/hooks/useControllableState.js.map +1 -1
  11. package/lib/hooks/useEventCallback.js +0 -1
  12. package/lib/hooks/useEventCallback.js.map +1 -1
  13. package/lib/hooks/useFirstMount.js +0 -3
  14. package/lib/hooks/useFirstMount.js.map +1 -1
  15. package/lib/hooks/useForceUpdate.js +0 -1
  16. package/lib/hooks/useForceUpdate.js.map +1 -1
  17. package/lib/hooks/useId.js +0 -3
  18. package/lib/hooks/useId.js.map +1 -1
  19. package/lib/hooks/useIsomorphicLayoutEffect.js +0 -1
  20. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  21. package/lib/hooks/useMergedRefs.js +2 -3
  22. package/lib/hooks/useMergedRefs.js.map +1 -1
  23. package/lib/hooks/useOnClickOutside.js +8 -26
  24. package/lib/hooks/useOnClickOutside.js.map +1 -1
  25. package/lib/hooks/useOnScrollOutside.js +0 -4
  26. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  27. package/lib/hooks/usePrevious.js +0 -1
  28. package/lib/hooks/usePrevious.js.map +1 -1
  29. package/lib/hooks/useTimeout.js +2 -3
  30. package/lib/hooks/useTimeout.js.map +1 -1
  31. package/lib/index.js.map +1 -1
  32. package/lib/ssr/SSRContext.js +4 -11
  33. package/lib/ssr/SSRContext.js.map +1 -1
  34. package/lib/ssr/canUseDOM.js +2 -1
  35. package/lib/ssr/canUseDOM.js.map +1 -1
  36. package/lib/trigger/applyTriggerPropsToChildren.js +2 -6
  37. package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
  38. package/lib/trigger/getTriggerChild.js +2 -3
  39. package/lib/trigger/getTriggerChild.js.map +1 -1
  40. package/lib/trigger/isFluentTrigger.js.map +1 -1
  41. package/lib/utils/getNativeElementProps.js +0 -2
  42. package/lib/utils/getNativeElementProps.js.map +1 -1
  43. package/lib/utils/getRTLSafeKey.js +0 -2
  44. package/lib/utils/getRTLSafeKey.js.map +1 -1
  45. package/lib/utils/getReactCallbackName.js +0 -3
  46. package/lib/utils/getReactCallbackName.js.map +1 -1
  47. package/lib/utils/isHTMLElement.js +0 -1
  48. package/lib/utils/isHTMLElement.js.map +1 -1
  49. package/lib/utils/isInteractiveHTMLElement.js +0 -4
  50. package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
  51. package/lib/utils/mergeCallbacks.js.map +1 -1
  52. package/lib/utils/omit.js +0 -2
  53. package/lib/utils/omit.js.map +1 -1
  54. package/lib/utils/properties.js +7 -36
  55. package/lib/utils/properties.js.map +1 -1
  56. package/lib-commonjs/compose/getSlots.js +0 -12
  57. package/lib-commonjs/compose/getSlots.js.map +1 -1
  58. package/lib-commonjs/compose/index.js +0 -5
  59. package/lib-commonjs/compose/index.js.map +1 -1
  60. package/lib-commonjs/compose/isResolvedShorthand.js +0 -4
  61. package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
  62. package/lib-commonjs/compose/resolveShorthand.js +2 -9
  63. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  64. package/lib-commonjs/compose/types.js.map +1 -1
  65. package/lib-commonjs/hooks/index.js +0 -12
  66. package/lib-commonjs/hooks/index.js.map +1 -1
  67. package/lib-commonjs/hooks/useControllableState.js +6 -14
  68. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  69. package/lib-commonjs/hooks/useEventCallback.js +0 -5
  70. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  71. package/lib-commonjs/hooks/useFirstMount.js +0 -6
  72. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  73. package/lib-commonjs/hooks/useForceUpdate.js +0 -4
  74. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  75. package/lib-commonjs/hooks/useId.js +0 -8
  76. package/lib-commonjs/hooks/useId.js.map +1 -1
  77. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +0 -4
  78. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  79. package/lib-commonjs/hooks/useMergedRefs.js +2 -6
  80. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  81. package/lib-commonjs/hooks/useOnClickOutside.js +8 -30
  82. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  83. package/lib-commonjs/hooks/useOnScrollOutside.js +0 -8
  84. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  85. package/lib-commonjs/hooks/usePrevious.js +0 -4
  86. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  87. package/lib-commonjs/hooks/useTimeout.js +2 -6
  88. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  89. package/lib-commonjs/index.js +0 -10
  90. package/lib-commonjs/index.js.map +1 -1
  91. package/lib-commonjs/ssr/SSRContext.js +4 -17
  92. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  93. package/lib-commonjs/ssr/canUseDOM.js +2 -3
  94. package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
  95. package/lib-commonjs/ssr/index.js +0 -3
  96. package/lib-commonjs/ssr/index.js.map +1 -1
  97. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js +2 -10
  98. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
  99. package/lib-commonjs/trigger/getTriggerChild.js +2 -7
  100. package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
  101. package/lib-commonjs/trigger/index.js +0 -5
  102. package/lib-commonjs/trigger/index.js.map +1 -1
  103. package/lib-commonjs/trigger/isFluentTrigger.js +0 -2
  104. package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
  105. package/lib-commonjs/trigger/types.js.map +1 -1
  106. package/lib-commonjs/utils/clamp.js +0 -2
  107. package/lib-commonjs/utils/clamp.js.map +1 -1
  108. package/lib-commonjs/utils/getNativeElementProps.js +0 -6
  109. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  110. package/lib-commonjs/utils/getRTLSafeKey.js +0 -4
  111. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  112. package/lib-commonjs/utils/getReactCallbackName.js +0 -5
  113. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
  114. package/lib-commonjs/utils/index.js +0 -9
  115. package/lib-commonjs/utils/index.js.map +1 -1
  116. package/lib-commonjs/utils/isHTMLElement.js +0 -3
  117. package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
  118. package/lib-commonjs/utils/isInteractiveHTMLElement.js +0 -7
  119. package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
  120. package/lib-commonjs/utils/mergeCallbacks.js +0 -2
  121. package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
  122. package/lib-commonjs/utils/omit.js +0 -4
  123. package/lib-commonjs/utils/omit.js.map +1 -1
  124. package/lib-commonjs/utils/properties.js +7 -38
  125. package/lib-commonjs/utils/properties.js.map +1 -1
  126. package/package.json +2 -2
package/CHANGELOG.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@fluentui/react-utilities",
3
3
  "entries": [
4
4
  {
5
- "date": "Wed, 28 Dec 2022 04:33:19 GMT",
6
- "tag": "@fluentui/react-utilities_v0.0.0-nightly-20221228-0425.1",
7
- "version": "0.0.0-nightly-20221228-0425.1",
5
+ "date": "Thu, 29 Dec 2022 04:34:30 GMT",
6
+ "tag": "@fluentui/react-utilities_v0.0.0-nightly-20221229-0425.1",
7
+ "version": "0.0.0-nightly-20221229-0425.1",
8
8
  "comments": {
9
9
  "prerelease": [
10
10
  {
@@ -16,8 +16,8 @@
16
16
  {
17
17
  "author": "beachball",
18
18
  "package": "@fluentui/react-utilities",
19
- "comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-20221228-0425.1",
20
- "commit": "3ee907a253f14ff8e15878e0ec1355e2fbfcef69"
19
+ "comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-20221229-0425.1",
20
+ "commit": "f91b275fd9b1829634e1dc1de59d8fbf68359edc"
21
21
  }
22
22
  ]
23
23
  }
package/CHANGELOG.md CHANGED
@@ -1,18 +1,18 @@
1
1
  # Change Log - @fluentui/react-utilities
2
2
 
3
- This log was last generated on Wed, 28 Dec 2022 04:33:19 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 29 Dec 2022 04:34:30 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [0.0.0-nightly-20221228-0425.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v0.0.0-nightly-20221228-0425.1)
7
+ ## [0.0.0-nightly-20221229-0425.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v0.0.0-nightly-20221229-0425.1)
8
8
 
9
- Wed, 28 Dec 2022 04:33:19 GMT
10
- [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.3.0..@fluentui/react-utilities_v0.0.0-nightly-20221228-0425.1)
9
+ Thu, 29 Dec 2022 04:34:30 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.3.0..@fluentui/react-utilities_v0.0.0-nightly-20221229-0425.1)
11
11
 
12
12
  ### Changes
13
13
 
14
14
  - Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
15
- - Bump @fluentui/keyboard-keys to v0.0.0-nightly-20221228-0425.1 ([commit](https://github.com/microsoft/fluentui/commit/3ee907a253f14ff8e15878e0ec1355e2fbfcef69) by beachball)
15
+ - Bump @fluentui/keyboard-keys to v0.0.0-nightly-20221229-0425.1 ([commit](https://github.com/microsoft/fluentui/commit/f91b275fd9b1829634e1dc1de59d8fbf68359edc) by beachball)
16
16
 
17
17
  ## [9.3.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.3.0)
18
18
 
@@ -17,45 +17,37 @@ import { omit } from '../utils/omit';
17
17
  * @param state - State including slot definitions
18
18
  * @returns An object containing the `slots` map and `slotProps` map.
19
19
  */
20
-
21
20
  export function getSlots(state) {
22
21
  const slots = {};
23
22
  const slotProps = {};
24
23
  const slotNames = Object.keys(state.components);
25
-
26
24
  for (const slotName of slotNames) {
27
25
  const [slot, props] = getSlot(state, slotName);
28
26
  slots[slotName] = slot;
29
27
  slotProps[slotName] = props;
30
28
  }
31
-
32
29
  return {
33
30
  slots,
34
31
  slotProps: slotProps
35
32
  };
36
33
  }
37
-
38
34
  function getSlot(state, slotName) {
39
35
  var _a, _b, _c;
40
-
41
36
  if (state[slotName] === undefined) {
42
37
  return [null, undefined];
43
38
  }
44
-
45
39
  const {
46
40
  children,
47
41
  as: asProp,
48
42
  ...rest
49
43
  } = state[slotName];
50
44
  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];
51
-
52
45
  if (typeof children === 'function') {
53
46
  const render = children;
54
47
  return [React.Fragment, {
55
48
  children: render(slot, rest)
56
49
  }];
57
50
  }
58
-
59
51
  const shouldOmitAsProp = typeof slot === 'string' && ((_c = state[slotName]) === null || _c === void 0 ? void 0 : _c.as);
60
52
  const slotProps = shouldOmitAsProp ? omit(state[slotName], ['as']) : state[slotName];
61
53
  return [slot, slotProps];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../packages/react-components/react-utilities/src/compose/getSlots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA,SAAS,IAAT,QAAqB,eAArB;AA6BA;;;;;;;;;;;;;;;;AAgBG;;AACH,OAAM,SAAU,QAAV,CACJ,KADI,EACoB;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;;AAED,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,IAAI,CAAC,KAAK,CAAC,QAAD,CAAN,EAAmB,CAAC,IAAD,CAAnB,CAAP,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":""}
1
+ {"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,SAASC,IAAI,QAAQ,eAAe;AA6BpC;;;;;;;;;;;;;;;;;AAiBA,OAAM,SAAUC,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;AAEA,SAASQ,OAAO,CACdV,KAAwB,EACxBO,QAAW;;EAEX,IAAIP,KAAK,CAACO,QAAQ,CAAC,KAAKI,SAAS,EAAE;IACjC,OAAO,CAAC,IAAI,EAAEA,SAAiB,CAAC;;EAElC,MAAM;IAAEC,QAAQ;IAAEC,EAAE,EAAEC,MAAM;IAAE,GAAGC;EAAI,CAAE,GAAGf,KAAK,CAACO,QAAQ,CAAE;EAE1D,MAAMC,IAAI,GAAI,YAAK,CAACF,UAAU,0CAAGC,QAAQ,CAAC,MAAKI,SAAS,IAAI,OAAOX,KAAK,CAACM,UAAU,CAACC,QAAQ,CAAC,KAAK,QAAQ,GACtGO,MAAM,KAAI,WAAK,CAACR,UAAU,0CAAGC,QAAQ,CAAC,KAAI,KAAK,GAC/CP,KAAK,CAACM,UAAU,CAACC,QAAQ,CAA6B;EAE1D,IAAI,OAAOK,QAAQ,KAAK,UAAU,EAAE;IAClC,MAAMI,MAAM,GAAGJ,QAAoC;IACnD,OAAO,CACLf,KAAK,CAACoB,QAAQ,EACb;MACCL,QAAQ,EAAEI,MAAM,CAACR,IAAI,EAAEO,IAAqC;KACzC,CACtB;;EAGH,MAAMG,gBAAgB,GAAG,OAAOV,IAAI,KAAK,QAAQ,KAAI,WAAK,CAACD,QAAQ,CAAC,0CAAEM,EAAE;EACxE,MAAMX,SAAS,GAAIgB,gBAAgB,GAAGpB,IAAI,CAACE,KAAK,CAACO,QAAQ,CAAE,EAAE,CAAC,IAAI,CAAC,CAAC,GAAGP,KAAK,CAACO,QAAQ,CAAU;EAE/F,OAAO,CAACC,IAAI,EAAEN,SAAS,CAAC;AAC1B","names":["React","omit","getSlots","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","undefined","children","as","asProp","rest","render","Fragment","shouldOmitAsProp"],"sourceRoot":"","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"]}
@@ -29,7 +29,6 @@ import { isValidElement } from 'react';
29
29
  * })
30
30
  * ```
31
31
  */
32
-
33
32
  export function isResolvedShorthand(shorthand) {
34
33
  return shorthand !== null && typeof shorthand === 'object' && !Array.isArray(shorthand) && ! /*#__PURE__*/isValidElement(shorthand);
35
34
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../packages/react-components/react-utilities/src/compose/isResolvedShorthand.ts"],"names":[],"mappings":"AAAA,SAAS,cAAT,QAA+B,OAA/B;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;;AACH,OAAM,SAAU,mBAAV,CACJ,SADI,EACiB;EAErB,OAAO,SAAS,KAAK,IAAd,IAAsB,OAAO,SAAP,KAAqB,QAA3C,IAAuD,CAAC,KAAK,CAAC,OAAN,CAAc,SAAd,CAAxD,IAAoF,eAAC,cAAc,CAAC,SAAD,CAA1G;AACD","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":""}
1
+ {"version":3,"mappings":"AAAA,SAASA,cAAc,QAAQ,OAAO;AAGtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,OAAM,SAAUC,mBAAmB,CACjCC,SAAqB;EAErB,OAAOA,SAAS,KAAK,IAAI,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,SAAS,CAAC,IAAI,eAACF,cAAc,CAACE,SAAS,CAAC;AACvH","names":["isValidElement","isResolvedShorthand","shorthand","Array","isArray"],"sourceRoot":"","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"]}
@@ -5,26 +5,22 @@ import { isValidElement } from 'react';
5
5
  * @param value - the base shorthand props
6
6
  * @param options - options to resolve shorthand props
7
7
  */
8
-
9
8
  export const resolveShorthand = (value, options) => {
10
9
  const {
11
10
  required = false,
12
11
  defaultProps
13
12
  } = options || {};
14
-
15
13
  if (value === null || value === undefined && !required) {
16
14
  return undefined;
17
15
  }
18
-
19
16
  let resolvedShorthand = {};
20
-
21
17
  if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || /*#__PURE__*/isValidElement(value)) {
22
18
  resolvedShorthand.children = value;
23
19
  } else if (typeof value === 'object') {
24
20
  resolvedShorthand = value;
25
21
  }
26
-
27
- return defaultProps ? { ...defaultProps,
22
+ return defaultProps ? {
23
+ ...defaultProps,
28
24
  ...resolvedShorthand
29
25
  } : resolvedShorthand;
30
26
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../packages/react-components/react-utilities/src/compose/resolveShorthand.ts"],"names":[],"mappings":"AAAA,SAAS,cAAT,QAA+B,OAA/B;AAkBA;;;;;AAKG;;AACH,OAAO,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,iBAAkF,cAAc,CAAC,KAAD,CAApG,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","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":""}
1
+ {"version":3,"mappings":"AAAA,SAASA,cAAc,QAAQ,OAAO;AAkBtC;;;;;;AAMA,OAAO,MAAMC,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,iBAAIF,cAAc,CAACE,KAAK,CAAC,EAAE;IAC3GK,iBAAiB,CAACG,QAAQ,GAAGR,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","names":["isValidElement","resolveShorthand","value","options","required","defaultProps","undefined","resolvedShorthand","Array","isArray","children"],"sourceRoot":"","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,5 +1,4 @@
1
1
  import * as React from 'react';
2
-
3
2
  function isFactoryDispatch(newState) {
4
3
  return typeof newState === 'function';
5
4
  }
@@ -19,8 +18,6 @@ function isFactoryDispatch(newState) {
19
18
  * to the updater function will only be respected if the component is uncontrolled.
20
19
  * @see https://reactjs.org/docs/uncontrolled-components.html
21
20
  */
22
-
23
-
24
21
  export const useControllableState = options => {
25
22
  const isControlled = useIsControlled(options.state);
26
23
  const initialState = typeof options.defaultState === 'undefined' ? options.initialState : options.defaultState;
@@ -29,9 +26,9 @@ export const useControllableState = options => {
29
26
  const stateRef = React.useRef(state);
30
27
  React.useEffect(() => {
31
28
  stateRef.current = state;
32
- }, [state]); // To match the behavior of the setter returned by React.useState, this callback's identity
29
+ }, [state]);
30
+ // To match the behavior of the setter returned by React.useState, this callback's identity
33
31
  // should never change. This means it MUST NOT directly reference variables that can change.
34
-
35
32
  const setState = React.useCallback(newState => {
36
33
  // React dispatch can use a factory
37
34
  // https://reactjs.org/docs/hooks-reference.html#functional-updates
@@ -40,7 +37,6 @@ export const useControllableState = options => {
40
37
  } else {
41
38
  stateRef.current = newState;
42
39
  }
43
-
44
40
  setInternalState(stateRef.current);
45
41
  }, []);
46
42
  return [state, setState];
@@ -50,10 +46,8 @@ export const useControllableState = options => {
50
46
  * Prints an error when isControlled value switches between subsequent renders
51
47
  * @returns - whether the value is controlled
52
48
  */
53
-
54
49
  const useIsControlled = controlledValue => {
55
50
  const [isControlled] = React.useState(() => controlledValue !== undefined);
56
-
57
51
  if (process.env.NODE_ENV !== 'production') {
58
52
  // We don't want these warnings in production even though it is against native behaviour
59
53
  // eslint-disable-next-line react-hooks/rules-of-hooks
@@ -61,14 +55,14 @@ const useIsControlled = controlledValue => {
61
55
  if (isControlled !== (controlledValue !== undefined)) {
62
56
  const error = new Error();
63
57
  const controlWarning = isControlled ? 'a controlled value to be uncontrolled' : 'an uncontrolled value to be controlled';
64
- const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined'; // eslint-disable-next-line no-console
65
-
66
- console.error([// Default react error
58
+ const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';
59
+ // eslint-disable-next-line no-console
60
+ console.error([
61
+ // Default react error
67
62
  '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(' '));
68
63
  }
69
64
  }, [isControlled, controlledValue]);
70
65
  }
71
-
72
66
  return isControlled;
73
67
  };
74
68
  //# sourceMappingURL=useControllableState.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useControllableState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;;AAqBA,SAAS,iBAAT,CAAkC,QAAlC,EAAuE;EACrE,OAAO,OAAO,QAAP,KAAoB,UAA3B;AACD;AAED;;;;;;;;;;;;;;;AAeG;;;AACH,OAAO,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;AA+BP;;;;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":""}
1
+ {"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAqB9B,SAASC,iBAAiB,CAAQC,QAAqC;EACrE,OAAO,OAAOA,QAAQ,KAAK,UAAU;AACvC;AAEA;;;;;;;;;;;;;;;;AAgBA,OAAO,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,GAAGX,KAAK,CAACY,QAAQ,CAAQJ,YAAY,CAAC;EAE7E,MAAMD,KAAK,GAAGF,YAAY,GAAID,OAAO,CAACG,KAAe,GAAGG,aAAa;EAErE,MAAMG,QAAQ,GAAGb,KAAK,CAACc,MAAM,CAACP,KAAK,CAAC;EACpCP,KAAK,CAACe,SAAS,CAAC,MAAK;IACnBF,QAAQ,CAACG,OAAO,GAAGT,KAAK;EAC1B,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX;EACA;EACA,MAAMU,QAAQ,GAAGjB,KAAK,CAACkB,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;AAED;;;;;AAKA,MAAMX,eAAe,GAAIa,eAAwB,IAAI;EACnD,MAAM,CAACd,YAAY,CAAC,GAAGL,KAAK,CAACY,QAAQ,CAAU,MAAMO,eAAe,KAAKC,SAAS,CAAC;EAEnF,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC;IACA;IACAvB,KAAK,CAACe,SAAS,CAAC,MAAK;MACnB,IAAIV,YAAY,MAAMc,eAAe,KAAKC,SAAS,CAAC,EAAE;QACpD,MAAMI,KAAK,GAAG,IAAIC,KAAK,EAAE;QAEzB,MAAMC,cAAc,GAAGrB,YAAY,GAC/B,uCAAuC,GACvC,wCAAwC;QAE5C,MAAMsB,gBAAgB,GAAGtB,YAAY,GAAG,yBAAyB,GAAG,wBAAwB;QAE5F;QACAuB,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,CAACzB,YAAY,EAAEc,eAAe,CAAC,CAAC;;EAGrC,OAAOd,YAAY;AACrB,CAAC","names":["React","isFactoryDispatch","newState","useControllableState","options","isControlled","useIsControlled","state","initialState","defaultState","internalState","setInternalState","useState","stateRef","useRef","useEffect","current","setState","useCallback","controlledValue","undefined","process","env","NODE_ENV","error","Error","controlWarning","undefinedWarning","console","stack","join"],"sourceRoot":"","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"]}
@@ -13,7 +13,6 @@ import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
13
13
  *
14
14
  * @param fn - The callback function that will be used
15
15
  */
16
-
17
16
  export const useEventCallback = fn => {
18
17
  const callbackRef = React.useRef(() => {
19
18
  throw new Error('Cannot call an event handler while rendering');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useEventCallback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,yBAAT,QAA0C,6BAA1C;AAEA;;;;;;;;;;;;AAYG;;AACH,OAAO,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,yBAAyB,CAAC,MAAK;IAC7B,WAAW,CAAC,OAAZ,GAAsB,EAAtB;EACD,CAFwB,EAEtB,CAAC,EAAD,CAFsB,CAAzB;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","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":""}
1
+ {"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,yBAAyB,QAAQ,6BAA6B;AAEvE;;;;;;;;;;;;;AAaA,OAAO,MAAMC,gBAAgB,GAAoCC,EAA6B,IAAI;EAChG,MAAMC,WAAW,GAAGJ,KAAK,CAACK,MAAM,CAAY,MAAK;IAC/C,MAAM,IAAIC,KAAK,CAAC,8CAA8C,CAAC;EACjE,CAAC,CAAC;EAEFL,yBAAyB,CAAC,MAAK;IAC7BG,WAAW,CAACG,OAAO,GAAGJ,EAAE;EAC1B,CAAC,EAAE,CAACA,EAAE,CAAC,CAAC;EAER,OAAOH,KAAK,CAACQ,WAAW,CACtB,CAAC,GAAGC,IAAU,KAAI;IAChB,MAAMC,QAAQ,GAAGN,WAAW,CAACG,OAAO;IACpC,OAAOG,QAAQ,CAAC,GAAGD,IAAI,CAAC;EAC1B,CAAC,EACD,CAACL,WAAW,CAAC,CACd;AACH,CAAC","names":["React","useIsomorphicLayoutEffect","useEventCallback","fn","callbackRef","useRef","Error","current","useCallback","args","callback"],"sourceRoot":"","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"]}
@@ -10,15 +10,12 @@ import * as React from 'react';
10
10
  * @example
11
11
  * const isFirstMount = useFirstMount();
12
12
  */
13
-
14
13
  export function useFirstMount() {
15
14
  const isFirst = React.useRef(true);
16
-
17
15
  if (isFirst.current) {
18
16
  isFirst.current = false;
19
17
  return true;
20
18
  }
21
-
22
19
  return isFirst.current;
23
20
  }
24
21
  //# sourceMappingURL=useFirstMount.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useFirstMount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA;;;;;;;;;;AAUG;;AACH,OAAM,SAAU,aAAV,GAAuB;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","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":""}
1
+ {"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B;;;;;;;;;;;AAWA,OAAM,SAAUC,aAAa;EAC3B,MAAMC,OAAO,GAAGF,KAAK,CAACG,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","names":["React","useFirstMount","isFirst","useRef","current"],"sourceRoot":"","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"]}
@@ -3,7 +3,6 @@ import { useReducer } from 'react';
3
3
  * @internal
4
4
  * Forces a re-render, similar to `forceUpdate` in class components.
5
5
  */
6
-
7
6
  export function useForceUpdate() {
8
7
  return useReducer(x => x + 1, 0)[1];
9
8
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useForceUpdate.ts"],"names":[],"mappings":"AAAA,SAAS,UAAT,QAA2B,OAA3B;AAEA;;;AAGG;;AACH,OAAM,SAAU,cAAV,GAAwB;EAC5B,OAAO,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAV,EAAa,CAAb,CAAV,CAA0B,CAA1B,CAAP;AACD","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":""}
1
+ {"version":3,"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAElC;;;;AAIA,OAAM,SAAUC,cAAc;EAC5B,OAAOD,UAAU,CAACE,CAAC,IAAIA,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC","names":["useReducer","useForceUpdate","x"],"sourceRoot":"","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"]}
@@ -3,7 +3,6 @@ import { defaultSSRContextValue, useSSRContext } from '../ssr/index';
3
3
  /**
4
4
  * Resets generated IDs, should be used only in tests.
5
5
  */
6
-
7
6
  export function resetIdsForTests() {
8
7
  defaultSSRContextValue.current = 0;
9
8
  }
@@ -15,14 +14,12 @@ export function resetIdsForTests() {
15
14
  * without conditioning the hook call
16
15
  * @returns The ID
17
16
  */
18
-
19
17
  export function useId(prefix = 'fui-', providedId) {
20
18
  const contextValue = useSSRContext();
21
19
  return React.useMemo(() => {
22
20
  if (providedId) {
23
21
  return providedId;
24
22
  }
25
-
26
23
  return `${prefix}${++contextValue.current}`;
27
24
  }, [prefix, providedId, contextValue]);
28
25
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useId.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,sBAAT,EAAiC,aAAjC,QAAsD,cAAtD;AAEA;;AAEG;;AACH,OAAM,SAAU,gBAAV,GAA0B;EAC9B,sBAAsB,CAAC,OAAvB,GAAiC,CAAjC;AACD;AAED;;;;;;;AAOG;;AACH,OAAM,SAAU,KAAV,CAAgB,MAAA,GAAiB,MAAjC,EAAyC,UAAzC,EAA4D;EAChE,MAAM,YAAY,GAAG,aAAa,EAAlC;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","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":""}
1
+ {"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,sBAAsB,EAAEC,aAAa,QAAQ,cAAc;AAEpE;;;AAGA,OAAM,SAAUC,gBAAgB;EAC9BF,sBAAsB,CAACG,OAAO,GAAG,CAAC;AACpC;AAEA;;;;;;;;AAQA,OAAM,SAAUC,KAAK,CAACC,SAAiB,MAAM,EAAEC,UAAmB;EAChE,MAAMC,YAAY,GAAGN,aAAa,EAAE;EAEpC,OAAOF,KAAK,CAACS,OAAO,CAAC,MAAK;IACxB,IAAIF,UAAU,EAAE;MACd,OAAOA,UAAU;;IAGnB,OAAO,GAAGD,MAAM,GAAG,EAAEE,YAAY,CAACJ,OAAO,EAAE;EAC7C,CAAC,EAAE,CAACE,MAAM,EAAEC,UAAU,EAAEC,YAAY,CAAC,CAAC;AACxC","names":["React","defaultSSRContextValue","useSSRContext","resetIdsForTests","current","useId","prefix","providedId","contextValue","useMemo"],"sourceRoot":"","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"]}
@@ -10,6 +10,5 @@ import { canUseDOM } from '../ssr/index';
10
10
  * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
11
11
  */
12
12
  // eslint-disable-next-line no-restricted-properties
13
-
14
13
  export const useIsomorphicLayoutEffect = /*#__PURE__*/canUseDOM() ? React.useLayoutEffect : React.useEffect;
15
14
  //# sourceMappingURL=useIsomorphicLayoutEffect.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,SAAT,QAA0B,cAA1B;AAEA;;;;;;;;AAQG;AACH;;AACA,OAAO,MAAM,yBAAyB,GAA2B,aAAA,SAAS,KAAK,KAAK,CAAC,eAAX,GAA6B,KAAK,CAAC,SAAtG","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":""}
1
+ {"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,SAAS,QAAQ,cAAc;AAExC;;;;;;;;;AASA;AACA,OAAO,MAAMC,yBAAyB,GAA2B,sBAAS,EAAE,GAAGF,KAAK,CAACG,eAAe,GAAGH,KAAK,CAACI,SAAS","names":["React","canUseDOM","useIsomorphicLayoutEffect","useLayoutEffect","useEffect"],"sourceRoot":"","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"]}
@@ -5,12 +5,10 @@ import * as React from 'react';
5
5
  * @param refs - Refs to collectively update with one ref value.
6
6
  * @returns A function with an attached "current" prop, so that it can be treated like a RefObject.
7
7
  */
8
-
9
8
  export function useMergedRefs(...refs) {
10
9
  const mergedCallback = React.useCallback(value => {
11
10
  // Update the "current" prop hanging on the function.
12
11
  mergedCallback.current = value;
13
-
14
12
  for (const ref of refs) {
15
13
  if (typeof ref === 'function') {
16
14
  ref(value);
@@ -19,7 +17,8 @@ export function useMergedRefs(...refs) {
19
17
  ref.current = value;
20
18
  }
21
19
  }
22
- }, // eslint-disable-next-line react-hooks/exhaustive-deps -- already exhaustive
20
+ },
21
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- already exhaustive
23
22
  [...refs]);
24
23
  return mergedCallback;
25
24
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useMergedRefs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAQA;;;;;AAKG;;AACH,OAAM,SAAU,aAAV,CAA2B,GAAG,IAA9B,EAAgE;EACpE,MAAM,cAAc,GAA0B,KAAK,CAAC,WAAN,CAC3C,KAAD,IAAa;IACX;IACE,cAAwD,CAAC,OAAzD,GAAmE,KAAnE;;IAEF,KAAK,MAAM,GAAX,IAAkB,IAAlB,EAAwB;MACtB,IAAI,OAAO,GAAP,KAAe,UAAnB,EAA+B;QAC7B,GAAG,CAAC,KAAD,CAAH;MACD,CAFD,MAEO,IAAI,GAAJ,EAAS;QACd;QACE,GAA6C,CAAC,OAA9C,GAAwD,KAAxD;MACH;IACF;EACF,CAb2C,EAc5C;EACA,CAAC,GAAG,IAAJ,CAf4C,CAA9C;EAkBA,OAAO,cAAP;AACD","sourcesContent":["import * as React from 'react';\n\n/**\n * A Ref function which can be treated like a ref object in that it has an attached\n * current property, which will be updated as the ref is evaluated.\n */\nexport type RefObjectFunction<T> = React.RefObject<T> & ((value: T) => void);\n\n/**\n * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that\n * updates all provided refs\n * @param refs - Refs to collectively update with one ref value.\n * @returns A function with an attached \"current\" prop, so that it can be treated like a RefObject.\n */\nexport function useMergedRefs<T>(...refs: (React.Ref<T> | undefined)[]): RefObjectFunction<T> {\n const mergedCallback: RefObjectFunction<T> = (React.useCallback(\n (value: T) => {\n // Update the \"current\" prop hanging on the function.\n ((mergedCallback as unknown) as React.MutableRefObject<T>).current = value;\n\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n // work around the immutability of the React.Ref type\n ((ref as unknown) as React.MutableRefObject<T>).current = value;\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps -- already exhaustive\n [...refs],\n ) as unknown) as RefObjectFunction<T>;\n\n return mergedCallback;\n}\n"],"sourceRoot":""}
1
+ {"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAQ9B;;;;;;AAMA,OAAM,SAAUC,aAAa,CAAI,GAAGC,IAAkC;EACpE,MAAMC,cAAc,GAA0BH,KAAK,CAACI,WAAW,CAC5DC,KAAQ,IAAI;IACX;IACEF,cAAwD,CAACG,OAAO,GAAGD,KAAK;IAE1E,KAAK,MAAME,GAAG,IAAIL,IAAI,EAAE;MACtB,IAAI,OAAOK,GAAG,KAAK,UAAU,EAAE;QAC7BA,GAAG,CAACF,KAAK,CAAC;OACX,MAAM,IAAIE,GAAG,EAAE;QACd;QACEA,GAA6C,CAACD,OAAO,GAAGD,KAAK;;;EAGrE,CAAC;EACD;EACA,CAAC,GAAGH,IAAI,CAAC,CAC0B;EAErC,OAAOC,cAAc;AACvB","names":["React","useMergedRefs","refs","mergedCallback","useCallback","value","current","ref"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useMergedRefs.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * A Ref function which can be treated like a ref object in that it has an attached\n * current property, which will be updated as the ref is evaluated.\n */\nexport type RefObjectFunction<T> = React.RefObject<T> & ((value: T) => void);\n\n/**\n * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that\n * updates all provided refs\n * @param refs - Refs to collectively update with one ref value.\n * @returns A function with an attached \"current\" prop, so that it can be treated like a RefObject.\n */\nexport function useMergedRefs<T>(...refs: (React.Ref<T> | undefined)[]): RefObjectFunction<T> {\n const mergedCallback: RefObjectFunction<T> = (React.useCallback(\n (value: T) => {\n // Update the \"current\" prop hanging on the function.\n ((mergedCallback as unknown) as React.MutableRefObject<T>).current = value;\n\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n // work around the immutability of the React.Ref type\n ((ref as unknown) as React.MutableRefObject<T>).current = value;\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps -- already exhaustive\n [...refs],\n ) as unknown) as RefObjectFunction<T>;\n\n return mergedCallback;\n}\n"]}
@@ -4,7 +4,6 @@ import { useEventCallback } from './useEventCallback';
4
4
  * @internal
5
5
  * Utility to perform checks where a click/touch event was made outside a component
6
6
  */
7
-
8
7
  export const useOnClickOutside = options => {
9
8
  const {
10
9
  refs,
@@ -17,9 +16,7 @@ export const useOnClickOutside = options => {
17
16
  useIFrameFocus(!disabled, element, callback);
18
17
  const listener = useEventCallback(ev => {
19
18
  const contains = containsProp || ((parent, child) => !!(parent === null || parent === void 0 ? void 0 : parent.contains(child)));
20
-
21
19
  const isOutside = refs.every(ref => !contains(ref.current || null, ev.target));
22
-
23
20
  if (isOutside && !disabled) {
24
21
  callback(ev);
25
22
  }
@@ -29,25 +26,21 @@ export const useOnClickOutside = options => {
29
26
  // Note this depends on a deprecated but extremely well supported quirk of the web platform
30
27
  // https://github.com/facebook/react/issues/20074
31
28
  let currentEvent = getWindowEvent(window);
32
-
33
29
  const conditionalHandler = event => {
34
30
  // Skip if this event is the same as the one running when we added the handlers
35
31
  if (event === currentEvent) {
36
32
  currentEvent = undefined;
37
33
  return;
38
34
  }
39
-
40
35
  listener(event);
41
36
  };
42
-
43
37
  if (!disabled) {
44
38
  // use capture phase because React can update DOM before the event bubbles to the document
45
39
  element === null || element === void 0 ? void 0 : element.addEventListener('click', conditionalHandler, true);
46
40
  element === null || element === void 0 ? void 0 : element.addEventListener('touchstart', conditionalHandler, true);
47
41
  element === null || element === void 0 ? void 0 : element.addEventListener('contextmenu', conditionalHandler, true);
48
- } // Garbage collect this event after it's no longer useful to avoid memory leaks
49
-
50
-
42
+ }
43
+ // Garbage collect this event after it's no longer useful to avoid memory leaks
51
44
  timeoutId.current = window.setTimeout(() => {
52
45
  currentEvent = undefined;
53
46
  }, 1);
@@ -60,23 +53,18 @@ export const useOnClickOutside = options => {
60
53
  };
61
54
  }, [listener, element, disabled]);
62
55
  };
63
-
64
56
  const getWindowEvent = target => {
65
57
  var _a, _b, _c;
66
-
67
58
  if (target) {
68
59
  if (typeof target.window === 'object' && target.window === target) {
69
60
  // eslint-disable-next-line deprecation/deprecation
70
61
  return target.event;
71
- } // eslint-disable-next-line deprecation/deprecation
72
-
73
-
62
+ }
63
+ // eslint-disable-next-line deprecation/deprecation
74
64
  return (_c = (_b = (_a = target.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.event) !== null && _c !== void 0 ? _c : undefined;
75
65
  }
76
-
77
66
  return undefined;
78
67
  };
79
-
80
68
  const FUI_FRAME_EVENT = 'fuiframefocus';
81
69
  /**
82
70
  * Since click events do not propagate past iframes, we use focus to detect if a
@@ -92,32 +80,28 @@ const FUI_FRAME_EVENT = 'fuiframefocus';
92
80
  * @param targetDocument - the document to dispatch events and set timeouts
93
81
  * @param pollDuration - in milliseconds
94
82
  */
95
-
96
83
  const useIFrameFocus = (enableFrameFocusDispatch, targetDocument, callback, pollDuration = 1000) => {
97
84
  const timeoutRef = React.useRef();
98
85
  const listener = useEventCallback(e => {
99
86
  if (callback) {
100
87
  callback(e);
101
88
  }
102
- }); // Adds listener to the custom iframe focus event
103
-
89
+ });
90
+ // Adds listener to the custom iframe focus event
104
91
  React.useEffect(() => {
105
92
  if (enableFrameFocusDispatch) {
106
93
  targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener(FUI_FRAME_EVENT, listener, true);
107
94
  }
108
-
109
95
  return () => {
110
96
  targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener(FUI_FRAME_EVENT, listener, true);
111
97
  };
112
- }, [targetDocument, enableFrameFocusDispatch, listener]); // Starts polling for the active element
113
-
98
+ }, [targetDocument, enableFrameFocusDispatch, listener]);
99
+ // Starts polling for the active element
114
100
  React.useEffect(() => {
115
101
  var _a;
116
-
117
102
  if (enableFrameFocusDispatch) {
118
103
  timeoutRef.current = (_a = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) === null || _a === void 0 ? void 0 : _a.setInterval(() => {
119
104
  const activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement;
120
-
121
105
  if ((activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'IFRAME' || (activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'WEBVIEW') {
122
106
  const event = new CustomEvent(FUI_FRAME_EVENT, {
123
107
  bubbles: true
@@ -126,10 +110,8 @@ const useIFrameFocus = (enableFrameFocusDispatch, targetDocument, callback, poll
126
110
  }
127
111
  }, pollDuration);
128
112
  }
129
-
130
113
  return () => {
131
114
  var _a;
132
-
133
115
  (_a = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) === null || _a === void 0 ? void 0 : _a.clearTimeout(timeoutRef.current);
134
116
  };
135
117
  }, [targetDocument, enableFrameFocusDispatch, pollDuration]);